PortableSerialLib  v0.2
a portable serial port lib
Defines | Typedefs | Enumerations | Functions
PortableSerialLib.h File Reference

Author:
Copyright (c) 2012 René Staffen r.sta.nosp@m.ffen.nosp@m.@gmx..nosp@m.de
Version:
Id:
PortableSerialLib.h 12 2012-03-09 20:58:40Z Vlad
#include <inttypes.h>

Go to the source code of this file.

Defines

#define PSL_NOPORT_HANDLE   ((PSerLibHandle_t)(0))
 Indicates a bad Handle.

Typedefs

typedef struct
PSerLibHandleInternal_t * 
PSerLibHandle_t
 Handle that represents a serial port object.

Enumerations

enum  PSL_Baudrates_e {
  PSL_BR_50 = 0, PSL_BR_75, PSL_BR_110, PSL_BR_134,
  PSL_BR_150, PSL_BR_200, PSL_BR_300, PSL_BR_600,
  PSL_BR_1200, PSL_BR_1800, PSL_BR_2400, PSL_BR_4800,
  PSL_BR_9600, PSL_BR_14400, PSL_BR_19200, PSL_BR_28800,
  PSL_BR_38400, PSL_BR_56000, PSL_BR_57600, PSL_BR_115200,
  PSL_BR_128000, PSL_BR_230400, PSL_BR_256000, PSL_BR_460800,
  PSL_BR_500000, PSL_BR_576000, PSL_BR_921600, PSL_BR_1000000,
  PSL_BR_1152000, PSL_BR_1500000, PSL_BR_2000000, PSL_BR_2500000,
  PSL_BR_3000000, PSL_BR_3500000, PSL_BR_4000000, PSL_BR_CONSTANTS_COUNT
}
 predefined baud rate constants More...
enum  PSL_ErrorCodes_e {
  PSL_ERROR_none = 0, PSL_ERROR_couldNotOpen, PSL_ERROR_invalidHandle, PSL_ERROR_unsupportedBitrate,
  PSL_ERROR_unsupportedConfig, PSL_ERROR_configurePort, PSL_ERROR_notYetImplemented, PSL_ERROR_bufferToSmall,
  PSL_ERROR_writeDataFailed, PSL_ERROR_readDataFailed, PSL_ERROR_START_WIN_SPECIFIC = 1000, PSL_ERROR_couldNotOpenRegistryKey = PSL_ERROR_START_WIN_SPECIFIC,
  PSL_ERROR_couldNotIterateRegistryValues, PSL_ERROR_creatingDCBA, PSL_ERROR_setComState, PSL_ERROR_START_LINUX_SPECIFIC = 2000,
  PSL_ERROR_CODES_COUNT
}
 Error codes that may be returned by the functions. More...
enum  PSL_FlowControl_e {
  PSL_FC_none = 0, PSL_FC_rts_cts, PSL_FC_xon_xoff, PSL_FC_rts_cts__xon_xoff,
  PSL_FC_CONSTANTS_COUNT
}
 Constants for configuring flow control. More...
enum  PSL_NumDataBits_e {
  PSL_DB_5 = 0, PSL_DB_6, PSL_DB_7, PSL_DB_8,
  PSL_DB_CONSTANTS_COUNT
}
 Constants for configuring number of data bits per transmitted character. More...
enum  PSL_Parity_e {
  PSL_P_none = 0, PSL_P_odd, PSL_P_even, PSL_P_mark,
  PSL_P_space, PSL_P_CONSTANTS_COUNT
}
 Constants for parity settings. More...
enum  PSL_StopBits_e { PSL_SB_1 = 0, PSL_SB_1p5, PSL_SB_2, PSL_SB_CONSTANTS_COUNT }
 Constants for configuring number of stop bits per transmitted character. More...

Functions

PSL_ErrorCodes_e PSerLib_close (PSerLibHandle_t *io_portH)
 closes and deinitializes the port
int PSerLib_getAvailablePorts (char *o_names, int i_maxlen)
 returns a list with device names of available serial ports
const char * PSerLib_getErrorMessage (PSL_ErrorCodes_e i_errorCode)
 translates an error code in something printable
PSL_ErrorCodes_e PSerLib_open (const char *i_portName, PSerLibHandle_t *o_handle)
 tries to open the specified serial port
PSL_ErrorCodes_e PSerLib_putc (PSerLibHandle_t io_port, char c)
 outputs the given character to the port
PSL_ErrorCodes_e PSerLib_puts (PSerLibHandle_t io_port, const char *i_str)
 outputs the given string to the port
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
PSL_ErrorCodes_e PSerLib_setParams (PSerLibHandle_t io_port, PSL_Baudrates_e i_baudrate, PSL_NumDataBits_e i_bits, PSL_Parity_e i_parity, PSL_StopBits_e i_stopbits, PSL_FlowControl_e i_flowControl)
 sets the port to the given configuration
PSL_ErrorCodes_e PSerLib_setTimeOuts (PSerLibHandle_t io_port)
PSL_ErrorCodes_e PSerLib_writeBinaryData (PSerLibHandle_t io_port, const uint8_t *i_data, int i_dataLen, int *o_bytesWritten)
 outputs the given data to the port

Define Documentation

#define PSL_NOPORT_HANDLE   ((PSerLibHandle_t)(0))

Indicates a bad Handle.


Typedef Documentation

typedef struct PSerLibHandleInternal_t* PSerLibHandle_t

Handle that represents a serial port object.


Enumeration Type Documentation

predefined baud rate constants

See also:
PSerLib_setParams some may not supported by different platforms
Enumerator:
PSL_BR_50 
PSL_BR_75 
PSL_BR_110 
PSL_BR_134 
PSL_BR_150 
PSL_BR_200 
PSL_BR_300 
PSL_BR_600 
PSL_BR_1200 
PSL_BR_1800 
PSL_BR_2400 
PSL_BR_4800 
PSL_BR_9600 
PSL_BR_14400 
PSL_BR_19200 
PSL_BR_28800 
PSL_BR_38400 
PSL_BR_56000 
PSL_BR_57600 
PSL_BR_115200 
PSL_BR_128000 
PSL_BR_230400 
PSL_BR_256000 
PSL_BR_460800 
PSL_BR_500000 
PSL_BR_576000 
PSL_BR_921600 
PSL_BR_1000000 
PSL_BR_1152000 
PSL_BR_1500000 
PSL_BR_2000000 
PSL_BR_2500000 
PSL_BR_3000000 
PSL_BR_3500000 
PSL_BR_4000000 
PSL_BR_CONSTANTS_COUNT 

Error codes that may be returned by the functions.

See also:
PSerLib_getErrorMessage
Enumerator:
PSL_ERROR_none 
PSL_ERROR_couldNotOpen 
PSL_ERROR_invalidHandle 
PSL_ERROR_unsupportedBitrate 
PSL_ERROR_unsupportedConfig 
PSL_ERROR_configurePort 
PSL_ERROR_notYetImplemented 
PSL_ERROR_bufferToSmall 
PSL_ERROR_writeDataFailed 
PSL_ERROR_readDataFailed 
PSL_ERROR_START_WIN_SPECIFIC 
PSL_ERROR_couldNotOpenRegistryKey 
PSL_ERROR_couldNotIterateRegistryValues 
PSL_ERROR_creatingDCBA 
PSL_ERROR_setComState 
PSL_ERROR_START_LINUX_SPECIFIC 
PSL_ERROR_CODES_COUNT 

Constants for configuring flow control.

See also:
PSerLib_setParams
Enumerator:
PSL_FC_none 
PSL_FC_rts_cts 
PSL_FC_xon_xoff 
PSL_FC_rts_cts__xon_xoff 
PSL_FC_CONSTANTS_COUNT 

Constants for configuring number of data bits per transmitted character.

See also:
PSerLib_setParams
Enumerator:
PSL_DB_5 
PSL_DB_6 
PSL_DB_7 
PSL_DB_8 
PSL_DB_CONSTANTS_COUNT 

Constants for parity settings.

See also:
PSerLib_setParams
Enumerator:
PSL_P_none 
PSL_P_odd 
PSL_P_even 
PSL_P_mark 
PSL_P_space 
PSL_P_CONSTANTS_COUNT 

Constants for configuring number of stop bits per transmitted character.

See also:
PSerLib_setParams
Enumerator:
PSL_SB_1 
PSL_SB_1p5 
PSL_SB_2 
PSL_SB_CONSTANTS_COUNT