CoronisSDK_SerialDriverAPI_C  v1.0
 All Files Functions Typedefs Defines
Defines | Functions
i_serial_driver_service.h File Reference

This interface represents a Coronis SDK SerialDriver It generalizes and standardizes the available services to exchanged serial frame, throw a serial port connection, via a low level serial protocol. More...

#include <i_serial_frame.h>
#include <i_serial_driver_listener_types.h>

Go to the source code of this file.

Defines

#define WAVENIS_API   extern

Functions

WAVENIS_API void * driver_create ()
WAVENIS_API int driver_destroy (const void *driver)
WAVENIS_API int driver_init (const void *driver)
WAVENIS_API int driver_init_from_file (const void *driver, const char *file)
WAVENIS_API int driver_open (const void *driver)
WAVENIS_API int driver_close (const void *driver)
WAVENIS_API int driver_is_open (const void *driver)
WAVENIS_API int driver_get_port_id (const void *driver, char *id, int idLen)
WAVENIS_API int driver_set_port_id (const void *driver, const char *id)
WAVENIS_API int driver_set_port_params (const void *driver, int baudRate, int dataBit, int stopBit, int parity)
WAVENIS_API int driver_set_listening_period_param (const void *driver, int receiveTimeout)
WAVENIS_API int driver_set_flow_control_mode_params (const void *driver, int flowControlIn, int flowControlOut)
WAVENIS_API int driver_send (const void *driver, const pISerialFrame frame)
WAVENIS_API int driver_register_listener (const void *driver, serial_driver_listener_t receiveFrameListener, void *param)
WAVENIS_API int driver_unregister_listener (const void *driver)
WAVENIS_API int driver_register_notify_listener (const void *driver, serial_driver_listener_notify_t eventListener, void *param)
WAVENIS_API int driver_unregister_notify_listener (const void *driver)
WAVENIS_API int driver_register_spy_listener (const void *driver, serial_driver_spy_t spySentFrameListener, serial_driver_spy_t spyRecvFrameListener, void *param, int *spyIndex)
WAVENIS_API int driver_unregister_spy_listener (const void *driver, int spyIndex)

Detailed Description

This interface represents a Coronis SDK SerialDriver It generalizes and standardizes the available services to exchanged serial frame, throw a serial port connection, via a low level serial protocol.


Function Documentation

WAVENIS_API int driver_close ( const void *  driver)

Close the SerialDriver connection,

Parameters:
driverThe SerialDriver instance to close
Returns:
the close status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if closing succeed KO_SERIALPORT_UNEXPECTED_ERROR if error occurs during closing process
WAVENIS_API int driver_get_port_id ( const void *  driver,
char *  id,
int  idLen 
)

Get the serial port ID, if previously setted

Parameters:
driverThe SerialDriver instance
Settedliteral value of serial port ID (dependent from OS)
lengthof the setted literal value, 0 if not setted
WAVENIS_API int driver_init ( const void *  driver)

Initialize the serial driver settings if not already configured (serialPortId, baudRate, etc.)

Parameters:
driverThe SerialDriver instance
Returns:
the init status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if initialization succeed KO_SERIALDRIVER_ALREADY_OPEN if SerialDriver is already open
WAVENIS_API int driver_init_from_file ( const void *  driver,
const char *  file 
)

Initialize the serial driver settings if not already configured (serialPortId, baudRate, etc.)

Parameters:
driverThe SerialDriver instance
fileThe serial driver property file URL
Returns:
the init status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if initialization succeed KO_SERIALDRIVER_ALREADY_OPEN if SerialDriver is already open
WAVENIS_API int driver_is_open ( const void *  driver)

Test if the SerialDriver connection is open are not

Parameters:
driverThe SerialDriver instance
Returns:
1 if the serial driver is connected, 0 otherwise
WAVENIS_API int driver_open ( const void *  driver)

Open the SerialDriver connection with the serial port id, and configure the serial port parameters

Parameters:
driverThe SerialDriver instance to open
Returns:
the open status (serial_driver_status) OK_PROTOCOL_SUCCESS if opening succeed KO_SERIALPORTID_NOT_EXIST if id does not exist from the OS point of view KO_SERIALPORT_NOT_AVAILABLE if port is not available (already in use, broken down, etc.) KO_PARAM_XXXX_NOT_VALID if parameters configuration fails
WAVENIS_API int driver_register_listener ( const void *  driver,
serial_driver_listener_t  receiveFrameListener,
void *  param 
)

Register a listener to be notify of spontaneous received frame. The listener have to implement the serial_driver_listener_t interface. SerialDriver instance must allow only one listener.

Parameters:
driverThe SerialDriver instance
receiveFrameListenerThe listener to register
paramA user define data which is passed back to listener when a frame is received
Returns:
the registration status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if registration succeed KO_SERIALDRIVER_LISTENER_ALREADY_REGISTERED if a listener is already registered
WAVENIS_API int driver_register_notify_listener ( const void *  driver,
serial_driver_listener_notify_t  eventListener,
void *  param 
)

Register a listener to be notify of SerialDriver event. The listener have to implement the serial_driver_listener_notify_t interface. SerialDriver instance allows only one listener.

Parameters:
driverThe SerialDriver instance
eventListenerThe listener to register
paramA user define data which is passed back to listener when a frame is received
Returns:
the registration status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if registration succeed KO_SERIALDRIVER_LISTENER_ALREADY_REGISTERED if a listener is already registered
WAVENIS_API int driver_register_spy_listener ( const void *  driver,
serial_driver_spy_t  spySentFrameListener,
serial_driver_spy_t  spyRecvFrameListener,
void *  param,
int *  spyIndex 
)

Register a spy listener to be notify of sent and received frame via the SerialDriver. The listeners have to implement the serial_driver_spy_t interface. SerialDriver instance can allow many listeners.

Parameters:
driverThe SerialDriver instance
spySentFrameListenerThe listener to by notify of sent frame
spyRecvFrameListenerThe listener to by notify of received frame
paramA user define data which is passed back to listener when a frame is exchanged
spyIndexThe index of the Spy listener
Returns:
the registration status (serial_driver_status) OK_PROTOCOL_SUCCESS if registration succeed KO_SERIALDRIVER_LISTENER_ALREADY_REGISTERED if the spyIndex is already registered KO_SERIALDRIVER_MAX_SPY_LISTENER_EXCEED if the maximum number of spy listener
WAVENIS_API int driver_send ( const void *  driver,
const pISerialFrame  frame 
)

Send a serial frame via the SerialDriver

Parameters:
driverThe SerialDriver instance
frameThe ISerialFrame to send
Returns:
sending_status of the send process OK_SERIALDRIVER_SUCCESS if sending succeed KO_SERIALFRAME_REQUIRED if frame is empty KO_SERIALDRIVER_NOT_OPEN if SerialDriver is not opened KO_SENDING_FAILURE if sending failed KO_SERIALDRIVER_ALREADY_IN_USE if SerialDriver is already in process KO_SERIALPORT_DISCONNECTED if SerialDriver disconnection is observed during the process
WAVENIS_API int driver_set_flow_control_mode_params ( const void *  driver,
int  flowControlIn,
int  flowControlOut 
)

Set the flowcontrol mode parameter of the serial port Valid serial port parameters are listed in serial_port_constants.h

Parameters:
driverThe SerialDriver instance
flowControlInType of flow control for receiving (SerialPort constants)
flowControlOutType of flow control for sending (SerialPort constants)
Returns:
the set status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if setting succeed KO_SERIALDRIVER_ALREADY_OPEN if driver is already open KO_PARAM_xxx_NOT_VALID if param xxx is not valid
WAVENIS_API int driver_set_listening_period_param ( const void *  driver,
int  receiveTimeout 
)

Set the listening period parameter of the serial port listener

Parameters:
driverThe SerialDriver instance
receiveTimeoutListening period to set (between 1 ms and 100 ms)
Returns:
the set status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if setting succeed KO_SERIALDRIVER_ALREADY_OPEN if driver is already open KO_PARAM_LISTENINGPERIOD_NOT_VALID if period is not valid for the OS
WAVENIS_API int driver_set_port_id ( const void *  driver,
const char *  id 
)

Set the serial port ID to which SerialDriver must be connected

Parameters:
driverThe SerialDriver instance
idThe serial port identifier to set
Returns:
the set status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if setting succeed KO_SERIALDRIVER_ALREADY_OPEN if driver is already open KO_SERIALPORTID_NOT_EXIST if id is not valid for the OS
WAVENIS_API int driver_set_port_params ( const void *  driver,
int  baudRate,
int  dataBit,
int  stopBit,
int  parity 
)

Set the standard serial port parameters Valid serial port parameters are listed in serial_port_constants.h

Parameters:
driverThe SerialDriver instance
baudRateThe baud rate
dataBitsThe number of data bits
stopBitsThe number of stop bits
parityThe type of parity
Returns:
the set status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if setting succeed KO_SERIALDRIVER_ALREADY_OPEN if driver is already open KO_PARAM_xxx_NOT_VALID if param xxx is not valid
WAVENIS_API int driver_unregister_listener ( const void *  driver)

Unregister the listener from being notify of spontaneous received frame.

Parameters:
driverThe SerialDriver instance
Returns:
the unregistration status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if unregistration succeed KO_SERIALDRIVER_LISTENER_NOT_REGISTERED if no listener is registered
WAVENIS_API int driver_unregister_notify_listener ( const void *  driver)

Unregister the listener from being notify of SerialDriver event.

Parameters:
driverThe SerialDriver instance
Returns:
the unregistration status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if unregistration succeed KO_SERIALDRIVER_LISTENER_NOT_REGISTERED if no listener is registered
WAVENIS_API int driver_unregister_spy_listener ( const void *  driver,
int  spyIndex 
)

Unregister a spy listener from being notify of sent and received frame via the SerialDriver.

Parameters:
driverThe SerialDriver instance
spyIndexThe index of the Spy listener
Returns:
the unregistration status (serial_driver_status) OK_SERIALDRIVER_SUCCESS if unregistration succeed KO_SERIALDRIVER_LISTENER_NOT_REGISTERED if the spyIndex is not registered