USBUART
A library for reading/wring data via USB-UART adapters
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules
Classes | Typedefs | Enumerations | Functions | Variables
usbuart Namespace Reference

USBUART namespace.

Classes

struct  channel
 I/O channel, represented by a pair of file descriptors. More...
 
class  context
 USBUART API facade class. More...
 
struct  device_addr
 Device address in terms bus ID, device number. More...
 
struct  device_id
 Device ID (Vendor ID/Product ID). More...
 
class  driver
 USB-to-UART driver interface. More...
 
struct  eia_tia_232_info
 
class  generic
 implementation of common driver methods More...
 
struct  interface
 
class  Log
 

Typedefs

typedef uint32_t baudrate_t
 Baud rate data type. More...
 
typedef enum usbuart::parity_enum parity_t
 Parity enum. More...
 
typedef enum
usbuart::stop_bits_enum 
stop_bits_t
 Stop bits enum. More...
 
typedef enum
usbuart::flow_control_enum 
flow_control_t
 Flow control enum. More...
 
typedef enum usbuart::status_enum status_t
 Channel status flags. More...
 
typedef uint32_t time_us_t
 
typedef uint16_t size_t
 

Enumerations

enum  parity_enum {
  none, odd, even, mark,
  space
}
 Parity enum. More...
 
enum  stop_bits_enum { one, _1_5, two }
 Stop bits enum. More...
 
enum  flow_control_enum { none_, rts_cts, dtr_dsr, xon_xoff }
 Flow control enum. More...
 
enum  status_enum { read_pipe_ok = 1, write_pipe_ok = 2, usb_dev_ok = 4, alles_gute = read_pipe_ok | write_pipe_ok | usb_dev_ok }
 Channel status flags. More...
 
enum  loglevel_t {
  silent, error, warning, info,
  debug
}
 
enum  error_t {
  success, error_t::no_channels, error_t::not_implemented, error_t::invalid_param,
  error_t::no_channel, error_t::no_access, error_t::not_supported, error_t::no_device,
  error_t::no_interface, error_t::interface_busy, error_t::libusb_error, error_t::usb_error,
  error_t::device_error, error_t::bad_baudrate, error_t::probe_mismatch, error_t::control_error,
  error_t::io_error, error_t::fcntl_error, error_t::poll_error, error_t::pipe_error,
  error_t::out_of_memory, error_t::jni_error, error_t::unknown_error
}
 API Error codes. More...
 

Functions

int usbuart_pipe_byaddr (struct device_addr ba, struct channel *ch, const struct eia_tia_232_info *pi)
 Create two pipes and attach their ends to the USB device using BUS/ADDR. More...
 
struct channel usbuart_pipe_bydevid (struct device_id, struct channel *ch, const struct eia_tia_232_info *)
 Create two pipes and attach their ends to the USB device using VID/PID. More...
 
int usbuart_attach_byaddr (struct device_addr, struct channel, const struct eia_tia_232_info *)
 Attach pair of file descriptors to the USB device using BUS/ADDR. More...
 
int usbuart_attach_bydevid (struct device_id id, struct channel ch, const struct eia_tia_232_info *pi)
 Attach pair of file descriptors to the USB device using VID/PID. More...
 
int usbuart_status (struct channel)
 Returns channel status as combination of status_t bits. More...
 
void usbuart_close (struct channel)
 Close pipes and detach USB device. More...
 
void usbuart_reset (struct channel)
 Resets USB device. More...
 
void usbuart_break (struct channel)
 Send RS232 break signal to the USB device. More...
 
int usbuart_loop (int timeout)
 Run libusb and async I/O message loops. More...
 
void throw_error (const char *tag, int err) throw (error_t)
 
int safe (const char *tag, function< int()> unsafe) noexcept
 safe wrapper for unsafe calls
 

Variables

Log log
 
struct usbuart::interface __attribute__
 

Typedef Documentation

typedef uint32_t usbuart::baudrate_t

Definition at line 35 of file usbuart.h.

Enumeration Type Documentation

enum usbuart::error_t
strong
Enumerator
no_channels 

context has nor more live channels

not_implemented 

method not implemented in this lib

invalid_param 

invalid param passed to the API

no_channel 

requested channel does not exist

no_access 

access permission denied

not_supported 

device is not supported

no_device 

device does not exist

no_interface 

claim interface failed

interface_busy 

requested interface busy

libusb_error 

libusb error

usb_error 

USB level error.

device_error 

hardware level error

bad_baudrate 

unsupported baud rate

probe_mismatch 

device returned unexpected value while probing

control_error 

control transfer error

io_error 

I/O error on an attached file.

fcntl_error 

fcntl failed on an attached file

poll_error 

poll returned EINVAL

pipe_error 

failed to create a pipe

out_of_memory 

memory allocation failed

jni_error 

a JNI error occurred

unknown_error 

other errors

Definition at line 177 of file usbuart.h.

Definition at line 54 of file usbuart.h.

Definition at line 38 of file usbuart.h.

Definition at line 76 of file usbuart.h.

Definition at line 47 of file usbuart.h.

Function Documentation

int usbuart::usbuart_attach_byaddr ( struct device_addr  ,
struct channel  ,
const struct eia_tia_232_info  
)
Parameters
ba- USB bus ID/device address
ch- pair of file descriptors
pi- protocol information
Returns
0 on success or error code

Definition at line 41 of file capi.cpp.

int usbuart::usbuart_attach_bydevid ( struct device_id  id,
struct channel  ch,
const struct eia_tia_232_info *  pi 
)
Parameters
id- device VID/PID
ch- pair of file descriptors
pi- protocol information
Returns
0 on success or error code
void usbuart::usbuart_break ( struct channel  ch)

Send RS232 break signal to the USB device.

Definition at line 62 of file capi.cpp.

void usbuart::usbuart_close ( struct channel  ch)

Close pipes and detach USB device.

Definition at line 52 of file capi.cpp.

int usbuart::usbuart_loop ( int  timeout)

Run libusb and async I/O message loops.

Definition at line 66 of file capi.cpp.

int usbuart::usbuart_pipe_byaddr ( struct device_addr  ba,
struct channel ch,
const struct eia_tia_232_info pi 
)
Parameters
ba- USB bus ID/device address
ch- destination that accepts pair of file descriptors
pi- protocol information
Returns
0 on success or error code

Definition at line 31 of file capi.cpp.

struct channel usbuart::usbuart_pipe_bydevid ( struct device_id  ,
struct channel *  ch,
const struct eia_tia_232_info *   
)
Parameters
id- USB bus ID/device address
ch- destination that accepts pair of file descriptors
pi- protocol information
Returns
0 on success or error code
void usbuart::usbuart_reset ( struct channel  ch)

Resets USB device.

Definition at line 57 of file capi.cpp.

int usbuart::usbuart_status ( struct channel  )