|
fplayer
C99 Falcon Sequence (fseq) file player for Light-O-Rama hardware (like xLights)
|
Serial port communication implementation. More...
#include "serial.h"#include <assert.h>#include <stdio.h>#include <stdlib.h>#include <strings.h>#include <libserialport.h>#include "std2/errcode.h"
Data Structures | |
| struct | serialdev_s |
| Serial port communication device. More... | |
Functions | |
| static void | Serial_printError (const enum sp_return err) |
| Prints an error message to stderr for the given error code, including the libserialport error message if available. | |
| static int | Serial_openPort (struct serialdev_s **sdev, const char *const devName, const int baudRate) |
| Opens the serial port with the given device name and baud rate. | |
| int | Serial_init (struct serialdev_s **const sdev, const char *const devName, const 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. | |
| static void | Serial_writeVirtual (struct serialdev_s *const sdev, const uint8_t *const b, const unsigned long size) |
| Writes the binary data to the virtual file handle within the virtual serial device structure. | |
| static void | Serial_writeReal (struct serialdev_s *const sdev, const uint8_t *const b, const unsigned long size) |
| Writes the binary data to the "real" opened serial port handle within the virtual serial device structure. | |
| void | Serial_write (struct serialdev_s *const sdev, const uint8_t *const b, const 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 *const sdev) |
| Waits for all data to be written to the serial device. | |
| void | Serial_close (struct serialdev_s *const 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 implementation.
| void Serial_close | ( | struct serialdev_s * | sdev | ) |
Closes the open serial device and frees all resources.
| sdev | serial device to close, may be NULL |

| void Serial_drain | ( | struct serialdev_s * | sdev | ) |
Waits for all data to be written to the serial device.
| sdev | serial device to drain, must not be NULL |


| slist_t * Serial_getPorts | ( | void | ) |
Retrieves a list of available serial ports. The caller is responsible for freeing the list with slfree.

| 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.
| sdev | serial device to initialize, must not be NULL |
| devName | device name of the serial port |
| baudRate | baud rate of the serial port |


|
static |
Opens the serial port with the given device name and baud rate.
| sdev | the serial device structure to populate |
| devName | the device name to open |
| baudRate | the baud rate to configure the device connection with |


|
static |
Prints an error message to stderr for the given error code, including the libserialport error message if available.
| err | the error code to print the message for |

| 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.
| sdev | serial device to write to, must not be NULL |
| b | binary data to write |
| size | size of the binary data |


|
inlinestatic |
Writes the binary data to the "real" opened serial port handle within the virtual serial device structure.
| sdev | the virtual serial device structure |
| b | binary data to write |
| size | size of the binary data to write |
->real. 

|
inlinestatic |
Writes the binary data to the virtual file handle within the virtual serial device structure.
| sdev | the virtual serial device structure |
| b | binary data to write |
| size | size of the binary data to write |
->virtual. 