Herror ::set_serial_param (
const HTuple &SerialHandle,
const HTuple &BaudRate,
const HTuple &DataBits,
const HTuple &FlowControl,
const HTuple &Parity,
const HTuple &StopBits,
const HTuple &TotalTimeOut,
const HTuple &InterCharTimeOut
)
Set the parameters of a serial device.
::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. In the latter case, a choice between
software control ('xon_xoff') and hardware control
('cts_rts', 'dtr_dsr') can be made. 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. Thus, on Windows NT systems, a total timeout
of TotalTimeOut + n InterCharTimeOut results if
n characters are to be read. On Unix 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. For each parameter, the current values can be left in
effect by passing 'unchanged'.
Parameters
SerialHandle (input_control)
|
serial_id -> HTuple.long
|
|
Serial interface handle. |
BaudRate (input_control)
|
integer -> HTuple.long / char *
|
|
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' |
DataBits (input_control)
|
integer -> HTuple.long / char *
|
|
Number of data bits of the serial interface. |
|
Default value: 'unchanged' |
|
List of values: 5, 6, 7, 8, 'unchanged' |
FlowControl (input_control)
|
string -> HTuple.char *
|
|
Type of flow control of the serial interface. |
|
Default value: 'unchanged' |
|
List of values: 'none', 'xon_xoff', 'cts_rts', 'dtr_dsr', 'unchanged' |
Parity (input_control)
|
string -> HTuple.char *
|
|
Parity of the serial interface. |
|
Default value: 'unchanged' |
|
List of values: 'none', 'odd', 'even', 'unchanged' |
StopBits (input_control)
|
integer -> HTuple.long / char *
|
|
Number of stop bits of the serial interface. |
|
Default value: 'unchanged' |
|
List of values: 1, 2, 'unchanged' |
TotalTimeOut (input_control)
|
integer -> HTuple.long / char *
|
|
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' |
InterCharTimeOut (input_control)
|
integer -> HTuple.long / char *
|
|
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' |
Result
If the parameters are correct and the parameters of the device could
be set, the operator ::set_serial_param returns the value
H_MSG_TRUE. Otherwise an exception is raised.
Possible Predecessors
::open_serial,
::get_serial_param
Possible Successors
::read_serial,
::write_serial
See also
::get_serial_param
Module
System
Copyright © 1996-2002 MVTec Software GmbH