set_serial_paramT_set_serial_paramSetSerialParamSetSerialParam (Operator)
Name
set_serial_paramT_set_serial_paramSetSerialParamSetSerialParam
— Set the parameters of a serial device.
Signature
void SetSerialParam(const HTuple& SerialHandle, const HTuple& BaudRate, const HTuple& DataBits, const HTuple& FlowControl, const HTuple& Parity, const HTuple& StopBits, const HTuple& TotalTimeOut, const HTuple& InterCharTimeOut)
void HSerial::SetSerialParam(const HTuple& BaudRate, const HTuple& DataBits, const HString& FlowControl, const HString& Parity, const HTuple& StopBits, const HTuple& TotalTimeOut, const HTuple& InterCharTimeOut) const
void HSerial::SetSerialParam(Hlong BaudRate, Hlong DataBits, const HString& FlowControl, const HString& Parity, Hlong StopBits, Hlong TotalTimeOut, Hlong InterCharTimeOut) const
void HSerial::SetSerialParam(Hlong BaudRate, Hlong DataBits, const char* FlowControl, const char* Parity, Hlong StopBits, Hlong TotalTimeOut, Hlong InterCharTimeOut) const
void HSerial::SetSerialParam(Hlong BaudRate, Hlong DataBits, const wchar_t* FlowControl, const wchar_t* Parity, Hlong StopBits, Hlong TotalTimeOut, Hlong InterCharTimeOut) const
(Windows only)
static void HOperatorSet.SetSerialParam(HTuple serialHandle, HTuple baudRate, HTuple dataBits, HTuple flowControl, HTuple parity, HTuple stopBits, HTuple totalTimeOut, HTuple interCharTimeOut)
void HSerial.SetSerialParam(HTuple baudRate, HTuple dataBits, string flowControl, string parity, HTuple stopBits, HTuple totalTimeOut, HTuple interCharTimeOut)
void HSerial.SetSerialParam(int baudRate, int dataBits, string flowControl, string parity, int stopBits, int totalTimeOut, int interCharTimeOut)
Description
set_serial_paramset_serial_paramSetSerialParamSetSerialParamSetSerialParam
can be used to set the parameters of a
serial device. The parameter BaudRateBaudRateBaudRateBaudRatebaudRate
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 DataBitsDataBitsDataBitsDataBitsdataBits
. The parameter
FlowControlFlowControlFlowControlFlowControlflowControl
determines if and what kind of data flow
control should be used. Software control ('xon_xoff'"xon_xoff""xon_xoff""xon_xoff""xon_xoff")
and hardware control ('cts_rts'"cts_rts""cts_rts""cts_rts""cts_rts" and 'dtr_dsr'"dtr_dsr""dtr_dsr""dtr_dsr""dtr_dsr")
can be used. Multiple values can be set separated by a space
within one string (e.g. 'cts_rts dtr_dsr'"cts_rts dtr_dsr""cts_rts dtr_dsr""cts_rts dtr_dsr""cts_rts dtr_dsr").
If and what
kind of parity check of the transmitted data should be performed can
be determined by ParityParityParityParityparity
. The number of stop bits sent is
set with StopBitsStopBitsStopBitsStopBitsstopBits
. Finally, two timeout for reading from
the serial device can be set. The parameter TotalTimeOutTotalTimeOutTotalTimeOutTotalTimeOuttotalTimeOut
determines the maximum time, which may pass in read_serialread_serialReadSerialReadSerialReadSerial
until the first character arrives, independent of the actual number
of characters requested. The parameter InterCharTimeOutInterCharTimeOutInterCharTimeOutInterCharTimeOutinterCharTimeOut
determines the time which may pass between the reading of individual
characters, if multiple characters are requested with
read_serialread_serialReadSerialReadSerialReadSerial
. 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 TotalTimeOutTotalTimeOutTotalTimeOutTotalTimeOuttotalTimeOut
+ n
InterCharTimeOutInterCharTimeOutInterCharTimeOutInterCharTimeOutinterCharTimeOut
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'"unchanged""unchanged""unchanged""unchanged".
Execution Information
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
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.
Parameters
SerialHandleSerialHandleSerialHandleSerialHandleserialHandle
(input_control, state is modified) serial →
HSerial, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Serial interface handle.
BaudRateBaudRateBaudRateBaudRatebaudRate
(input_control) integer →
HTupleHTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)
Speed of the serial interface.
Default value:
'unchanged'
"unchanged"
"unchanged"
"unchanged"
"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'"unchanged""unchanged""unchanged""unchanged"
DataBitsDataBitsDataBitsDataBitsdataBits
(input_control) integer →
HTupleHTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)
Number of data bits of the serial interface.
Default value:
'unchanged'
"unchanged"
"unchanged"
"unchanged"
"unchanged"
List of values: 5, 6, 7, 8, 'unchanged'"unchanged""unchanged""unchanged""unchanged"
FlowControlFlowControlFlowControlFlowControlflowControl
(input_control) string →
HTupleHTupleHtuple (string) (string) (HString) (char*)
Type of flow control of the serial interface.
Default value:
'unchanged'
"unchanged"
"unchanged"
"unchanged"
"unchanged"
List of values: 'cts_rts dtr_dsr xon_xoff'"cts_rts dtr_dsr xon_xoff""cts_rts dtr_dsr xon_xoff""cts_rts dtr_dsr xon_xoff""cts_rts dtr_dsr xon_xoff", 'cts_rts dtr_dsr'"cts_rts dtr_dsr""cts_rts dtr_dsr""cts_rts dtr_dsr""cts_rts dtr_dsr", 'cts_rts xon_xoff'"cts_rts xon_xoff""cts_rts xon_xoff""cts_rts xon_xoff""cts_rts xon_xoff", 'cts_rts'"cts_rts""cts_rts""cts_rts""cts_rts", 'dtr_dsr xon_xoff'"dtr_dsr xon_xoff""dtr_dsr xon_xoff""dtr_dsr xon_xoff""dtr_dsr xon_xoff", 'dtr_dsr'"dtr_dsr""dtr_dsr""dtr_dsr""dtr_dsr", 'none'"none""none""none""none", 'unchanged'"unchanged""unchanged""unchanged""unchanged", 'xon_xoff'"xon_xoff""xon_xoff""xon_xoff""xon_xoff"
ParityParityParityParityparity
(input_control) string →
HTupleHTupleHtuple (string) (string) (HString) (char*)
Parity of the serial interface.
Default value:
'unchanged'
"unchanged"
"unchanged"
"unchanged"
"unchanged"
List of values: 'even'"even""even""even""even", 'none'"none""none""none""none", 'odd'"odd""odd""odd""odd", 'unchanged'"unchanged""unchanged""unchanged""unchanged"
StopBitsStopBitsStopBitsStopBitsstopBits
(input_control) integer →
HTupleHTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)
Number of stop bits of the serial interface.
Default value:
'unchanged'
"unchanged"
"unchanged"
"unchanged"
"unchanged"
List of values: 1, 2, 'unchanged'"unchanged""unchanged""unchanged""unchanged"
TotalTimeOutTotalTimeOutTotalTimeOutTotalTimeOuttotalTimeOut
(input_control) integer →
HTupleHTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)
Total timeout of the serial interface in ms.
Default value:
'unchanged'
"unchanged"
"unchanged"
"unchanged"
"unchanged"
Suggested values: -1, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 'unchanged'"unchanged""unchanged""unchanged""unchanged"
InterCharTimeOutInterCharTimeOutInterCharTimeOutInterCharTimeOutinterCharTimeOut
(input_control) integer →
HTupleHTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)
Inter-character timeout of the serial interface
in ms.
Default value:
'unchanged'
"unchanged"
"unchanged"
"unchanged"
"unchanged"
Suggested values: -1, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 'unchanged'"unchanged""unchanged""unchanged""unchanged"
Result
If the parameters are correct and the parameters of the device could
be set, the operator set_serial_paramset_serial_paramSetSerialParamSetSerialParamSetSerialParam
returns the value
2 (H_MSG_TRUE). Otherwise an exception is raised.
Possible Predecessors
open_serialopen_serialOpenSerialOpenSerialOpenSerial
,
get_serial_paramget_serial_paramGetSerialParamGetSerialParamGetSerialParam
Possible Successors
read_serialread_serialReadSerialReadSerialReadSerial
,
write_serialwrite_serialWriteSerialWriteSerialWriteSerial
See also
get_serial_paramget_serial_paramGetSerialParamGetSerialParamGetSerialParam
Module
Foundation