Operators |
set_serial_param — Set the parameters of a serial device.
set_serial_param( : : SerialHandle, BaudRate, DataBits, FlowControl, Parity, StopBits, TotalTimeOut, InterCharTimeOut : )
set_serial_param can be used to set the parameters of a serial device. The parameter BaudRate determines the input and output speed of the device. It should be noted that not all devices support all possible speeds. The number of sent and received data bits is set with DataBits. The parameter FlowControl determines if and what kind of data flow control should be used. Software control ('xon_xoff' ) and hardware control ('cts_rts' and 'dtr_dsr' ) can be used. Multiple values can be set separated by a space within one string (e.g. 'cts_rts dtr_dsr' ). If and what kind of parity check of the transmitted data should be performed can be determined by Parity. The number of stop bits sent is set with StopBits. Finally, two timeout for reading from the serial device can be set. The parameter TotalTimeOut determines the maximum time, which may pass in read_serial until the first character arrives, independent of the actual number of characters requested. The parameter InterCharTimeOut determines the time which may pass between the reading of individual characters, if multiple characters are requested with read_serial. If one of the timeouts is set to -1, a read waits an arbitrary amount of time for the arrival of characters. If both timeouts are set to 0 the a read doesn't wait and returns the available or none characters. Thus, on Windows systems, a total timeout of TotalTimeOut + n InterCharTimeOut results if n characters are to be read. On Unix-like systems, only one of the two timeouts can be set. Thus, if both timeouts are passed larger than -1, only the total timeout is used. The unit of both timeouts is milliseconds. It should be noted, however, that the timeout is specified in increments of one tenths of a second on Unix-like systems, i.e., the minimum timeout that has any effect is 100. For each parameter, the current values can be left in effect by passing 'unchanged' .
This operator modifies the state of the following input parameter:
The value of this parameter may not be shared across multiple threads without external synchronization.Serial interface handle.
Speed of the serial interface.
Default value: 'unchanged'
List of values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 153600, 230400, 307200, 460800, 'unchanged'
Number of data bits of the serial interface.
Default value: 'unchanged'
List of values: 5, 6, 7, 8, 'unchanged'
Type of flow control of the serial interface.
Default value: 'unchanged'
List of values: 'cts_rts dtr_dsr xon_xoff' , 'cts_rts dtr_dsr' , 'cts_rts xon_xoff' , 'cts_rts' , 'dtr_dsr xon_xoff' , 'dtr_dsr' , 'none' , 'unchanged' , 'xon_xoff'
Parity of the serial interface.
Default value: 'unchanged'
List of values: 'even' , 'none' , 'odd' , 'unchanged'
Number of stop bits of the serial interface.
Default value: 'unchanged'
List of values: 1, 2, 'unchanged'
Total timeout of the serial interface in ms.
Default value: 'unchanged'
Suggested values: -1, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 'unchanged'
Inter-character timeout of the serial interface in ms.
Default value: 'unchanged'
Suggested values: -1, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 'unchanged'
If the parameters are correct and the parameters of the device could be set, the operator set_serial_param returns the value 2 (H_MSG_TRUE). Otherwise an exception is raised.
Foundation
Operators |