PortableSerialLib  v0.4
a portable serial port lib
Functions
Serial Port Data Receive Functions

This functions receive data.

All receive functions are blocking. Hence there is no need for polling the port → let the operating system handle the waiting for data. As a drawback you cannot do things while waiting for input. But that is no really drawback since it is better to split up the two things and use threads.
One thread waiting for data and one thread doing the rest.

Functions

PSL_ErrorCodes_e PSerLib_readBinaryData (PSerLibHandle_t io_port, uint8_t *o_data, int i_dataToRead, int *o_bytesRead)
 reads data from the port
PSL_ErrorCodes_e PSerLib_readLine (PSerLibHandle_t io_port, char *o_string, int i_bufferLength, const char *i_endLineChars)
 reads data from the port

Function Documentation

PSL_ErrorCodes_e PSerLib_readBinaryData ( PSerLibHandle_t  io_port,
uint8_t *  o_data,
int  i_dataToRead,
int *  o_bytesRead 
)

reads data from the port

Parameters:
io_porthandle of port to read from
o_datapointer to buffer where the data should be stored. Ensure that the buffer can take at least i_dataToRead bytes.
i_dataToReadnumber of bytes to read
o_bytesReadnumber of bytes actual read (May differ because of time out or error)
Can be NULL if not required.
Remarks:
see remarks of PSerLib_writeBinaryData
Returns:
PSL_ERROR_none if successful else another error code
PSL_ErrorCodes_e PSerLib_readLine ( PSerLibHandle_t  io_port,
char *  o_string,
int  i_bufferLength,
const char *  i_endLineChars 
)

reads data from the port

Parameters:
io_porthandle of port to read from
o_stringpointer to buffer where the data should be stored.
i_bufferLengthnumber of bytes the buffer can take. Remember that the buffer also have to take the end character and terminating \0 character
i_endLineChars\0 terminated string, that contains characters that indicates line end. The line end character will also be copied into output buffer.
Returns:
PSL_ERROR_none if successful else another error code