10 #ifndef SRC_IEC60870_LINK_LAYER_SERIAL_PORT_H_
11 #define SRC_IEC60870_LINK_LAYER_SERIAL_PORT_H_
39 typedef struct sSerialPort* SerialPort;
42 SERIAL_PORT_ERROR_NONE = 0,
43 SERIAL_PORT_ERROR_INVALID_ARGUMENT = 1,
44 SERIAL_PORT_ERROR_INVALID_BAUDRATE = 2,
45 SERIAL_PORT_ERROR_OPEN_FAILED = 3,
46 SERIAL_PORT_ERROR_UNKNOWN = 99
61 SerialPort_create(
const char* interfaceName,
int baudRate, uint8_t dataBits,
char parity, uint8_t stopBits);
128 PAL_API SerialPortError
PAL_API int SerialPort_getBaudRate(SerialPort self)
Get the baudrate used by the serial interface.
PAL_API void SerialPort_close(SerialPort self)
Close (release) the serial interface.
PAL_API int SerialPort_readByte(SerialPort self)
Read a byte from the interface.
PAL_API bool SerialPort_open(SerialPort self)
Open the serial interface.
PAL_API void SerialPort_setTimeout(SerialPort self, int timeout)
Set the timeout used for message reception.
PAL_API SerialPort SerialPort_create(const char *interfaceName, int baudRate, uint8_t dataBits, char parity, uint8_t stopBits)
Create a new SerialPort instance.
PAL_API int SerialPort_write(SerialPort self, uint8_t *buffer, int startPos, int numberOfBytes)
Write the number of bytes from the buffer to the serial interface.
PAL_API SerialPortError SerialPort_getLastError(SerialPort self)
Get the error code of the last operation.
PAL_API void SerialPort_destroy(SerialPort self)
Destroy the SerialPort instance and release all resources.
PAL_API void SerialPort_discardInBuffer(SerialPort self)
Discard all data in the input buffer of the serial interface.