|
enum | M_io_serial_baud {
M_IO_SERIAL_BAUD_0 = 0
,
M_IO_SERIAL_BAUD_50 = 50
,
M_IO_SERIAL_BAUD_75 = 75
,
M_IO_SERIAL_BAUD_110 = 110
,
M_IO_SERIAL_BAUD_134 = 134
,
M_IO_SERIAL_BAUD_150 = 150
,
M_IO_SERIAL_BAUD_200 = 200
,
M_IO_SERIAL_BAUD_300 = 300
,
M_IO_SERIAL_BAUD_600 = 600
,
M_IO_SERIAL_BAUD_1200 = 1200
,
M_IO_SERIAL_BAUD_1800 = 1800
,
M_IO_SERIAL_BAUD_2400 = 2400
,
M_IO_SERIAL_BAUD_4800 = 4800
,
M_IO_SERIAL_BAUD_7200 = 7200
,
M_IO_SERIAL_BAUD_9600 = 9600
,
M_IO_SERIAL_BAUD_14400 = 14400
,
M_IO_SERIAL_BAUD_19200 = 19200
,
M_IO_SERIAL_BAUD_28800 = 28800
,
M_IO_SERIAL_BAUD_38400 = 38400
,
M_IO_SERIAL_BAUD_57600 = 57600
,
M_IO_SERIAL_BAUD_115200 = 115200
,
M_IO_SERIAL_BAUD_128000 = 128000
,
M_IO_SERIAL_BAUD_230400 = 230400
,
M_IO_SERIAL_BAUD_256000 = 256000
,
M_IO_SERIAL_BAUD_460800 = 460800
,
M_IO_SERIAL_BAUD_500000 = 500000
,
M_IO_SERIAL_BAUD_576000 = 576000
,
M_IO_SERIAL_BAUD_921600 = 921600
,
M_IO_SERIAL_BAUD_1000000 = 1000000
,
M_IO_SERIAL_BAUD_1152000 = 1152000
,
M_IO_SERIAL_BAUD_1500000 = 1500000
,
M_IO_SERIAL_BAUD_2000000 = 2000000
,
M_IO_SERIAL_BAUD_2500000 = 2500000
,
M_IO_SERIAL_BAUD_3000000 = 3000000
,
M_IO_SERIAL_BAUD_3500000 = 3500000
,
M_IO_SERIAL_BAUD_4000000 = 4000000
} |
|
enum | M_io_serial_flowcontrol {
M_IO_SERIAL_FLOWCONTROL_NONE = 0
,
M_IO_SERIAL_FLOWCONTROL_HARDWARE = 1
,
M_IO_SERIAL_FLOWCONTROL_SOFTWARE = 2
} |
|
enum | M_io_serial_mode {
M_IO_SERIAL_MODE_8N1 = M_IO_SERIAL_MODE_BITS_8 | M_IO_SERIAL_MODE_PARITY_NONE | M_IO_SERIAL_MODE_STOPBITS_1
,
M_IO_SERIAL_MODE_7E1 = M_IO_SERIAL_MODE_BITS_7 | M_IO_SERIAL_MODE_PARITY_EVEN | M_IO_SERIAL_MODE_STOPBITS_1
,
M_IO_SERIAL_MODE_7O1 = M_IO_SERIAL_MODE_BITS_7 | M_IO_SERIAL_MODE_PARITY_ODD | M_IO_SERIAL_MODE_STOPBITS_1
} |
|
enum | M_io_serial_flags {
M_IO_SERIAL_FLAG_NONE = 0
,
M_IO_SERIAL_FLAG_IGNORE_TERMIOS_FAILURE = 1 << 0
,
M_IO_SERIAL_FLAG_NO_FLUSH_ON_CLOSE = 1 << 1
,
M_IO_SERIAL_FLAG_NO_RESTORE_ON_CLOSE = 1 << 2
,
M_IO_SERIAL_FLAG_ASYNC_TIMEOUT = 1 << 3
,
M_IO_SERIAL_FLAG_BUSY_POLLING = 1 << 4
} |
|
|
M_io_error_t | M_io_serial_create (M_io_t **io_out, const char *path, M_io_serial_baud_t baud, M_io_serial_flowcontrol_t flowcontrol, M_io_serial_mode_t mode, M_uint32 flags) |
|
M_io_error_t | M_io_serial_set_baud (M_io_t *io, M_io_serial_baud_t baud) |
|
M_io_error_t | M_io_serial_set_flowcontrol (M_io_t *io, M_io_serial_flowcontrol_t flowcontrol) |
|
M_io_error_t | M_io_serial_set_mode (M_io_t *io, M_io_serial_mode_t mode) |
|
M_io_error_t | M_io_serial_get_flowcontrol (M_io_t *io, M_io_serial_flowcontrol_t *flowcontrol) |
|
M_io_error_t | M_io_serial_get_mode (M_io_t *io, M_io_serial_mode_t *mode) |
|
M_io_error_t | M_io_serial_get_baud (M_io_t *io, M_io_serial_baud_t *baud) |
|
M_io_serial_enum_t * | M_io_serial_enum (M_bool include_modems) |
|
void | M_io_serial_enum_destroy (M_io_serial_enum_t *serenum) |
|
size_t | M_io_serial_enum_count (const M_io_serial_enum_t *serenum) |
|
const char * | M_io_serial_enum_path (const M_io_serial_enum_t *serenum, size_t idx) |
|
const char * | M_io_serial_enum_name (const M_io_serial_enum_t *serenum, size_t idx) |
|
Serial Port I/O functions
◆ M_IO_SERIAL_MODE_MASK_BITS
#define M_IO_SERIAL_MODE_MASK_BITS 0x000F |
◆ M_IO_SERIAL_MODE_MASK_PARITY
#define M_IO_SERIAL_MODE_MASK_PARITY 0x00F0 |
◆ M_IO_SERIAL_MODE_MASK_STOPBITS
#define M_IO_SERIAL_MODE_MASK_STOPBITS 0x0F00 |
◆ M_IO_SERIAL_MODE_BITS_8
#define M_IO_SERIAL_MODE_BITS_8 0x0000 /* CS8 */ |
◆ M_IO_SERIAL_MODE_BITS_7
#define M_IO_SERIAL_MODE_BITS_7 0x0001 /* CS7 */ |
◆ M_IO_SERIAL_MODE_PARITY_NONE
#define M_IO_SERIAL_MODE_PARITY_NONE 0x0000 /* &= ~(PARENB | PARODD | CMSPAR) */ |
◆ M_IO_SERIAL_MODE_PARITY_EVEN
#define M_IO_SERIAL_MODE_PARITY_EVEN 0x0010 /* PARENB */ |
◆ M_IO_SERIAL_MODE_PARITY_ODD
#define M_IO_SERIAL_MODE_PARITY_ODD 0x0020 /* PARENB | PARODD */ |
◆ M_IO_SERIAL_MODE_PARITY_MARK
#define M_IO_SERIAL_MODE_PARITY_MARK 0x0030 /* PARENB | CMSPAR | PARODD -- CMSPAR may be undefined */ |
◆ M_IO_SERIAL_MODE_PARITY_SPACE
#define M_IO_SERIAL_MODE_PARITY_SPACE 0x0040 /* PARENB | CMSPAR - &= ~PARODD -- CMSPAR may be undefined */ |
◆ M_IO_SERIAL_MODE_STOPBITS_1
#define M_IO_SERIAL_MODE_STOPBITS_1 0x0000 /* &= ~(CSTOPB) */ |
◆ M_IO_SERIAL_MODE_STOPBITS_2
#define M_IO_SERIAL_MODE_STOPBITS_2 0x0100 /* CSTOPB */ |
◆ M_io_serial_baud_t
◆ M_io_serial_flowcontrol_t
◆ M_io_serial_mode_t
◆ M_io_serial_flags_t
◆ M_io_serial_enum_t
◆ M_io_serial_baud
Baud rate.
Enumerator |
---|
M_IO_SERIAL_BAUD_0 | Used to terminate the connection (drop DTR)
|
M_IO_SERIAL_BAUD_50 | |
M_IO_SERIAL_BAUD_75 | |
M_IO_SERIAL_BAUD_110 | |
M_IO_SERIAL_BAUD_134 | |
M_IO_SERIAL_BAUD_150 | |
M_IO_SERIAL_BAUD_200 | |
M_IO_SERIAL_BAUD_300 | |
M_IO_SERIAL_BAUD_600 | |
M_IO_SERIAL_BAUD_1200 | |
M_IO_SERIAL_BAUD_1800 | |
M_IO_SERIAL_BAUD_2400 | |
M_IO_SERIAL_BAUD_4800 | |
M_IO_SERIAL_BAUD_7200 | |
M_IO_SERIAL_BAUD_9600 | |
M_IO_SERIAL_BAUD_14400 | |
M_IO_SERIAL_BAUD_19200 | |
M_IO_SERIAL_BAUD_28800 | |
M_IO_SERIAL_BAUD_38400 | |
M_IO_SERIAL_BAUD_57600 | |
M_IO_SERIAL_BAUD_115200 | |
M_IO_SERIAL_BAUD_128000 | |
M_IO_SERIAL_BAUD_230400 | |
M_IO_SERIAL_BAUD_256000 | |
M_IO_SERIAL_BAUD_460800 | |
M_IO_SERIAL_BAUD_500000 | |
M_IO_SERIAL_BAUD_576000 | |
M_IO_SERIAL_BAUD_921600 | |
M_IO_SERIAL_BAUD_1000000 | |
M_IO_SERIAL_BAUD_1152000 | |
M_IO_SERIAL_BAUD_1500000 | |
M_IO_SERIAL_BAUD_2000000 | |
M_IO_SERIAL_BAUD_2500000 | |
M_IO_SERIAL_BAUD_3000000 | |
M_IO_SERIAL_BAUD_3500000 | |
M_IO_SERIAL_BAUD_4000000 | |
◆ M_io_serial_flowcontrol
Types of flow control.
Enumerator |
---|
M_IO_SERIAL_FLOWCONTROL_NONE | |
M_IO_SERIAL_FLOWCONTROL_HARDWARE | |
M_IO_SERIAL_FLOWCONTROL_SOFTWARE | |
◆ M_io_serial_mode
Mode.
Enumerator |
---|
M_IO_SERIAL_MODE_8N1 | |
M_IO_SERIAL_MODE_7E1 | |
M_IO_SERIAL_MODE_7O1 | |
◆ M_io_serial_flags
Flags to control behavior.
These flags provide work around for broken system.
Enumerator |
---|
M_IO_SERIAL_FLAG_NONE | Default, assume strict and proper behavior
|
M_IO_SERIAL_FLAG_IGNORE_TERMIOS_FAILURE | Ignore any termios (baud, mode, flow) setting failures. Some serial port emulators may intentionally fail.
|
M_IO_SERIAL_FLAG_NO_FLUSH_ON_CLOSE | Do not flush any pending data on close. This may confuse or lock up some serial port emulators.
|
M_IO_SERIAL_FLAG_NO_RESTORE_ON_CLOSE | Do not restore termios (baud, mode, flow) settings on close. It is a best practice but often does not provide any real benefit.
|
M_IO_SERIAL_FLAG_ASYNC_TIMEOUT | Windows Only. For Asynchronous reads use a timeout value rather than infinite as some drivers may not allow canceling of async reads (such as Citrix serial forwarding). Not used if BUSY_POLLING is used
|
M_IO_SERIAL_FLAG_BUSY_POLLING | Windows Only. Perform busy-polling in a separate thread rather than using asynchronous reads. This may work around driver issues that do not properly support Overlapped IO.
|
◆ M_io_serial_create()
Create a serial connection.
- Parameters
-
[out] | io_out | io object for communication. |
[in] | path | Path to serial device. |
[in] | baud | Baud rate. |
[in] | flowcontrol | Flow control method. |
[in] | mode | Mode. |
[in] | flags | M_io_serial_flags_t mapping. M_IO_SERIAL_FLAG_IGNORE_TERMIOS_FAILURE may need to be enabled for some "virtual" serial ports, but the device will still open and be usable. |
- Returns
- Result.
◆ M_io_serial_set_baud()
Set the baud rate on a serial io object.
- Parameters
-
[in] | io | io object. |
[in] | baud | Baud rate. |
- Returns
- Result.
◆ M_io_serial_set_flowcontrol()
Set the flow control on a serial io object.
- Parameters
-
[in] | io | io object. |
[in] | flowcontrol | Flow control method. |
- Returns
- Result.
◆ M_io_serial_set_mode()
Set the mode on a serial io object.
- Parameters
-
[in] | io | io object. |
[in] | mode | Mode. |
- Returns
- Result.
◆ M_io_serial_get_flowcontrol()
Get the flow control of an serial io object.
- Parameters
-
[in] | io | io object. |
[out] | flowcontrol | Flow control method to return. |
- Returns
- Result.
◆ M_io_serial_get_mode()
Get the mode of an serial io object.
- Parameters
-
[in] | io | io object. |
[out] | mode | Mode to return. |
- Returns
- Result.
◆ M_io_serial_get_baud()
Get the baud rate of an serial io object.
- Parameters
-
[in] | io | io object. |
[out] | baud | Baud to return. |
- Returns
- Result.
◆ M_io_serial_enum()
Create a serial enumeration object.
Use to determine what serial devices are connected. On some OS's this may be a list of device ports and not necessarily what's connected.
- Returns
- Serial enumeration object.
◆ M_io_serial_enum_destroy()
Destroy a serial enumeration object.
- Parameters
-
[in] | serenum | Serial enumeration object. |
◆ M_io_serial_enum_count()
Number of serial objects in the enumeration.
- Parameters
-
[in] | serenum | Serial enumeration object. |
- Returns
- Count of serial devices.
◆ M_io_serial_enum_path()
Path of serial device as reported by the device.
- Parameters
-
[in] | serenum | Serial enumeration object. |
[in] | idx | Index in serial enumeration. |
- Returns
- String.
◆ M_io_serial_enum_name()
Name of serial device.
- Parameters
-
[in] | serenum | Serial enumeration object. |
[in] | idx | Index in serial enumeration. |
- Returns
- String.