|
enum | SERIAL_PORT {
PORT1 = 0,
PORT2,
PORT3,
PORT4,
PORT5,
PORT6,
PORT7,
PORT8,
PORT_AMOUNT
} |
|
enum | SERIAL_ERR_CODE {
SERIAL_ERR_OK = 0,
SERIAL_ERR_FD,
SERIAL_ERR_OPEN,
SERIAL_ERR_CLOSE,
SERIAL_ERR_PARAMETER,
SERIAL_ERR_SLOT,
SERIAL_ERR_PORT,
SERIAL_ERR_READ,
SERIAL_ERR_WRITE,
SERIAL_ERR_IOCTL,
SERIAL_ERR_MODE,
SERIAL_ERR_ttyUSB,
SERIAL_ERR_NOT_SUPPORT_PRODUCT,
SERIAL_ERR_SYSTEM_INFO,
SERIAL_ERR_HOT_PLUG,
SERIAL_ERR_FLUSH,
SERIAL_ERR_AMOUNT
} |
|
|
SERIAL_ERR_CODE | MX_RTU_SerialOpen (UINT8 slot, SERIAL_PORT port) |
|
SERIAL_ERR_CODE | MX_RTU_SerialWrite (UINT8 slot, SERIAL_PORT port, UINT32 len, UINT8 *str, UINT32 *write_bytes) |
|
SERIAL_ERR_CODE | MX_RTU_SerialNonBlockRead (UINT8 slot, SERIAL_PORT port, UINT32 len, UINT8 *buf, UINT32 *read_bytes) |
|
SERIAL_ERR_CODE | MX_RTU_SerialBlockRead (UINT8 slot, SERIAL_PORT port, UINT32 len, UINT8 *buf, UINT32 *read_bytes) |
|
SERIAL_ERR_CODE | MX_RTU_SerialClose (UINT8 slot, SERIAL_PORT port) |
|
SERIAL_ERR_CODE | MX_RTU_SerialFlowControl (UINT8 slot, SERIAL_PORT port, UINT8 control) |
|
SERIAL_ERR_CODE | MX_RTU_SerialSetSpeed (UINT8 slot, SERIAL_PORT port, UINT32 speed) |
|
SERIAL_ERR_CODE | MX_RTU_SerialSetMode (UINT8 slot, SERIAL_PORT port, UINT8 mode) |
|
SERIAL_ERR_CODE | MX_RTU_SerialGetMode (UINT8 slot, SERIAL_PORT port, UINT8 *mode) |
|
SERIAL_ERR_CODE | MX_RTU_SerialSetParam (UINT8 slot, SERIAL_PORT port, UINT8 parity, UINT8 databits, UINT8 stopbit) |
|
SERIAL_ERR_CODE | MX_RTU_SerialDataInInputQueue (UINT8 slot, SERIAL_PORT port, UINT32 *bytes) |
|
SERIAL_ERR_CODE | MX_RTU_SerialDataInOutputQueue (UINT8 slot, SERIAL_PORT port, UINT32 *bytes) |
|
SERIAL_ERR_CODE | MX_RTU_SerialInputQueueFlush (UINT8 slot, SERIAL_PORT port) |
|
SERIAL_ERR_CODE | MX_RTU_SerialOutputQueueFlush (UINT8 slot, SERIAL_PORT port) |
|
SERIAL_ERR_CODE | MX_RTU_FindFD (UINT8 slot, SERIAL_PORT port, INT32 *fd) |
|
Sample Code:
serial_echo.c
#define SERIAL_MAX_OQUEUE_LENGTH 4095 |
Enumerator |
---|
PORT1 |
0
|
PORT2 |
1
|
PORT3 |
2
|
PORT4 |
3
|
PORT5 |
4
|
PORT6 |
5
|
PORT7 |
6
|
PORT8 |
7
|
PORT_AMOUNT |
8
|
Enumerator |
---|
SERIAL_ERR_OK |
0
|
SERIAL_ERR_FD |
1
|
SERIAL_ERR_OPEN |
2
|
SERIAL_ERR_CLOSE |
3
|
SERIAL_ERR_PARAMETER |
4
|
SERIAL_ERR_SLOT |
5
|
SERIAL_ERR_PORT |
6
|
SERIAL_ERR_READ |
7
|
SERIAL_ERR_WRITE |
8
|
SERIAL_ERR_IOCTL |
9
|
SERIAL_ERR_MODE |
10
|
SERIAL_ERR_ttyUSB |
11
|
SERIAL_ERR_NOT_SUPPORT_PRODUCT |
12
|
SERIAL_ERR_SYSTEM_INFO |
13
|
SERIAL_ERR_HOT_PLUG |
14
|
SERIAL_ERR_FLUSH |
15
|
SERIAL_ERR_AMOUNT |
16
|
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
- Returns
- SERIAL_ERR_CODE
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
[in] | len | length of sent data. |
[in] | str | sent data. |
[out] | write_bytes | written bytes by serial. |
- Returns
- SERIAL_ERR_CODE
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
[in] | len | length of received buffer. |
[out] | buf | received buffer. |
[out] | read_bytes | received bytes by serial. |
- Returns
- SERIAL_ERR_CODE
- Note
- A non-blocking read will (or at least should) always return immediately, but it might not return any data, if none is available at the moment.
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
[in] | len | length of received buffer. |
[out] | buf | received buffer. |
[out] | read_bytes | received bytes by serial. |
- Returns
- SERIAL_ERR_CODE
- Note
- A blocking read will wait until there is data available (or a timeout, if any, expires), and then returns from the function call.
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
- Returns
- SERIAL_ERR_CODE
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
[in] | speed | SerialBaudRate |
- Returns
- SERIAL_ERR_CODE
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
[in] | mode | SerialMode |
- Returns
- SERIAL_ERR_CODE
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
[out] | mode | SerialMode |
- Returns
- SERIAL_ERR_CODE
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
[out] | bytes | bytes of received data in input queue. |
- Returns
- SERIAL_ERR_CODE
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
[out] | bytes | bytes of sent data in output queue. |
- Returns
- SERIAL_ERR_CODE
- Note
- Please checking (SERIAL_MAX_OQUEUE_LENGTH - bytes) > written bytes or not before calling MX_RTU_SerialWrite.
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
- Returns
- SERIAL_ERR_CODE
- Note
- Flushes data received but not read.
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
- Returns
- SERIAL_ERR_CODE
- Note
- Flushes data written but not transmitted.
- Parameters
-
[in] | slot | slot 0: Built-in COM Ports, slot 1 ~ 12: Expansion COM Ports. |
[in] | port | port 0 ~ 3. |
[out] | fd | file descriptor of slot and port. |
- Returns
- SERIAL_ERR_CODE