Serial port communication interface.
More...
#include <stdint.h>
#include "sl.h"
Go to the source code of this file.
|
int | Serial_init (struct serialdev_s **sdev, const char *devName, int baudRate) |
| Initializes a write-mode serial port with the provided device name and baud rate pre-configured for use as a LOR network connection.
|
|
void | Serial_write (struct serialdev_s *sdev, const uint8_t *b, unsigned long size) |
| Writes the binary data to the open serial port. The data is copied to an internal buffer and written to the serial port asynchronously.
|
|
void | Serial_drain (struct serialdev_s *sdev) |
| Waits for all data to be written to the serial device.
|
|
void | Serial_close (struct serialdev_s *sdev) |
| Closes the open serial device and frees all resources.
|
|
slist_t * | Serial_getPorts (void) |
| Retrieves a list of available serial ports. The caller is responsible for freeing the list with slfree .
|
|
Serial port communication interface.
◆ Serial_close()
Closes the open serial device and frees all resources.
- Parameters
-
sdev | serial device to close, may be NULL |
◆ Serial_drain()
Waits for all data to be written to the serial device.
- Parameters
-
sdev | serial device to drain, must not be NULL |
◆ Serial_getPorts()
slist_t * Serial_getPorts |
( |
void | | ) |
|
Retrieves a list of available serial ports. The caller is responsible for freeing the list with slfree
.
- Returns
- list of available serial ports, or NULL on failure or no ports found
◆ Serial_init()
int Serial_init |
( |
struct serialdev_s ** | sdev, |
|
|
const char * | devName, |
|
|
int | baudRate ) |
Initializes a write-mode serial port with the provided device name and baud rate pre-configured for use as a LOR network connection.
- Parameters
-
sdev | serial device to initialize, must not be NULL |
devName | device name of the serial port |
baudRate | baud rate of the serial port |
- Returns
- 0 on success, a negative error code on failure
◆ Serial_write()
void Serial_write |
( |
struct serialdev_s * | sdev, |
|
|
const uint8_t * | b, |
|
|
unsigned long | size ) |
Writes the binary data to the open serial port. The data is copied to an internal buffer and written to the serial port asynchronously.
- Parameters
-
sdev | serial device to write to, must not be NULL |
b | binary data to write |
size | size of the binary data |