Skip to content

set_serial_paramSetSerialParamSetSerialParamset_serial_paramT_set_serial_paramπŸ”—

Short descriptionπŸ”—

set_serial_paramSetSerialParamSetSerialParamset_serial_paramT_set_serial_param β€” Set the parameters of a serial device.

SignatureπŸ”—

set_serial_param( serial SerialHandle, integer BaudRate, integer DataBits, string FlowControl, string Parity, integer StopBits, integer TotalTimeOut, integer InterCharTimeOut )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 )static void HOperatorSet.SetSerialParam( HTuple serialHandle, HTuple baudRate, HTuple dataBits, HTuple flowControl, HTuple parity, HTuple stopBits, HTuple totalTimeOut, HTuple interCharTimeOut )def set_serial_param( serial_handle: HHandle, baud_rate: Union[int, str], data_bits: Union[int, str], flow_control: str, parity: str, stop_bits: Union[int, str], total_time_out: Union[int, str], inter_char_time_out: Union[int, str] ) -> None

Herror T_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 )

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)

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_paramSetSerialParam can be used to set the parameters of a serial device. The parameter BaudRatebaudRatebaud_rate 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 DataBitsdataBitsdata_bits. The parameter FlowControlflowControlflow_control determines if and what kind of data flow control should be used. Software control ('xon_xoff'"xon_xoff") and hardware control ('cts_rts'"cts_rts" and '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"). If and what kind of parity check of the transmitted data should be performed can be determined by Parityparityparity. The number of stop bits sent is set with StopBitsstopBitsstop_bits. Finally, two timeout for reading from the serial device can be set. The parameter TotalTimeOuttotalTimeOuttotal_time_out determines the maximum time, which may pass in read_serialReadSerial until the first character arrives, independent of the actual number of characters requested. The parameter InterCharTimeOutinterCharTimeOutinter_char_time_out determines the time which may pass between the reading of individual characters, if multiple characters are requested with read_serialReadSerial. If one of the timeouts is set to -1-1, the system waits an arbitrary amount of time for the arrival of characters. If both timeouts are set to 00 the system doesn’t wait and returns the available or none characters. Thus, on Windows systems, a total timeout of \(\textrm{TotalTimeOut} + n \textrm{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 100100. For each parameter, the current values can be left in effect by passing 'unchanged'"unchanged".

Execution informationπŸ”—

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:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

ParametersπŸ”—

SerialHandleserialHandleserial_handle (input_control, state is modified) serial β†’ (handle)HTuple (HHandle)HSerial, HTuple (IntPtr)HHandleHtuple (handle)

Serial interface handle.

BaudRatebaudRatebaud_rate (input_control) integer β†’ (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)Union[int, str]Htuple (Hlong / char*)

Speed of the serial interface.

Default: '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'50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 153600, 230400, 307200, 460800, "unchanged"

DataBitsdataBitsdata_bits (input_control) integer β†’ (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)Union[int, str]Htuple (Hlong / char*)

Number of data bits of the serial interface.

Default: 'unchanged'"unchanged"
List of values: 5, 6, 7, 8, 'unchanged'5, 6, 7, 8, "unchanged"

FlowControlflowControlflow_control (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Type of flow control of the serial interface.

Default: 'unchanged'"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'"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"

Parityparityparity (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Parity of the serial interface.

Default: 'unchanged'"unchanged"
List of values: 'even', 'none', 'odd', 'unchanged'"even", "none", "odd", "unchanged"

StopBitsstopBitsstop_bits (input_control) integer β†’ (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)Union[int, str]Htuple (Hlong / char*)

Number of stop bits of the serial interface.

Default: 'unchanged'"unchanged"
List of values: 1, 2, 'unchanged'1, 2, "unchanged"

TotalTimeOuttotalTimeOuttotal_time_out (input_control) integer β†’ (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)Union[int, str]Htuple (Hlong / char*)

Total timeout of the serial interface in ms.

Default: 'unchanged'"unchanged"
Suggested values: -1, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 'unchanged'-1, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, "unchanged"

InterCharTimeOutinterCharTimeOutinter_char_time_out (input_control) integer β†’ (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)Union[int, str]Htuple (Hlong / char*)

Inter-character timeout of the serial interface in ms.

Default: 'unchanged'"unchanged"
Suggested values: -1, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 'unchanged'-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_paramSetSerialParam returns the value 2 (H_MSG_TRUE). Otherwise an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

open_serialOpenSerial, get_serial_paramGetSerialParam

Possible successors

read_serialReadSerial, write_serialWriteSerial

See also

get_serial_paramGetSerialParam

ModuleπŸ”—

Foundation