Menu

SerialDriver Configuration functions

Configuration functions

After having instanciate a SerialDriver implementation, the created serial driver instance could be configured using the following services:

  • init method to read the configuration to used from a property file
  • get/set port id to configure the serial port id to used for the serial driver connection
  • set standard serial port parameters (baudrate, dataBit, stopBit, parity)
  • set the serial port flow control mode (flowControl IN and OUT)
  • set the listening period for the scrutation of serial port

C source API extract

/**

 * Get the serial port ID, if previously setted
 * @param driver The SerialDriver instance
 * @param Setted literal value of serial port ID (dependent from OS)
 *        Prealocated char buffer where to write port id
 * @param Size of the setted literal value, <code>0</code> if not setted
 *        Size of prealocated buffer where ID is stored
 */
WAVENIS_API int driver_get_port_id( const void* driver, char* id, int idLen );

/**

 * Set the serial port ID to which SerialDriver must be connected
 * @param driver The SerialDriver instance
 * @param id The serial port identifier to set
 * @return 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_id( const void* driver, const char* id );

/**

 * Set the standard serial port parameters
 * Valid serial port parameters are listed in serial_port_constants.h
 * @param driver The SerialDriver instance
 * @param baudRate The baud rate
 * @param dataBits The number of data bits
 * @param stopBits The number of stop bits
 * @param parity The type of parity
 * @return 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_port_params( const void* driver, int baudRate, int dataBit, int stopBit, int parity );

/**

 * Set the listening period parameter of the serial port listener
 * @param driver The SerialDriver instance
 * @param receiveTimeout Listening period to set (between 1 ms and 100 ms)
 * @return 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_listening_period_param( const void* driver, int receiveTimeout );

/**

 * Set the flowcontrol mode parameter of the serial port
 * Valid serial port parameters are listed in serial_port_constants.h
 * @param driver The SerialDriver instance
 * @param flowControlIn Type of flow control for receiving (SerialPort constants)
 * @param flowControlOut Type of flow control for sending (SerialPort constants)
 * @return 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_flow_control_mode_params( const void* driver, int flowControlIn, int flowControlOut );

Java source API extract

/**

 * Get the serial port ID, if previously setted
 * @return Literal value of serial port ID (dependent from OS), <code>null</code> if not setted
 */
public String getSerialPortId();

/**

 * Set the serial port ID to which SerialDriver must be connected
 * @param serialPortId serial port identifier (must be valid for the OS)
 * @throws SerialDriverException if setting fails
 *         SERIALDRIVER_ALREADY_OPEN if driver is already open
 *         SERIALPORTID_NOT_EXIST if id is not valid for the OS
 */
public void setSerialPortId(String serialPortId) throws SerialDriverException;

/**

 * Set the standard serial port parameters
 * Valid serial port parameters are listed in SerialPortConstants
 * @param baudRate The baud rate
 * @param dataBits The number of data bits
 * @param stopBits The number of stop bits
 * @param parity The type of parity
 * @throws SerialDriverException if setting fails
 *         SERIALDRIVER_ALREADY_OPEN if driver is already open
 *         PARAM_xxx_NOT_VALID if param xxx is not valid
 */
public void setSerialPortParams (
        int baudRate,
        int dataBits,
        int stopBits,
        int parity) throws SerialDriverException;

/**

 * Set the listening period parameter
 * @param listeningPeriod Listening period to set (between 1 ms and 100 ms)
 * @throws SerialDriverException if setting fails
 *         SERIALDRIVER_ALREADY_OPEN if driver is already open
 *         PARAM_LISTENINGPERIOD_NOT_VALID if period is not valid
 */
public void setListeningPeriodParam (
        int listeningPeriod) throws SerialDriverException;

/**

 * Set the flowControlMode parameters
 * Valid serial port parameters are listed in SerialPortConstants
 * @param flowControlIn Type of flow control for receiving (SerialPort constants)
 * @param flowControlOut Type of flow control for sending (SerialPort constants)
 * @throws SerialDriverException if setting fails
 *         SERIALDRIVER_ALREADY_OPEN if driver is already open
 *         PARAM_xxx_NOT_VALID if param xxx is not valid
 */
public void setFlowControlModeParam (
        int flowControlIn,
        int flowControlOut) throws SerialDriverException;

Related

Wiki: APIs

MongoDB Logo MongoDB