Skip to content

read_serialReadSerialReadSerialread_serialT_read_serial🔗

Short description🔗

read_serialReadSerialReadSerialread_serialT_read_serial — Read from a serial device.

Signature🔗

read_serial( serial SerialHandle, integer NumCharacters, out integer Data )void ReadSerial( const HTuple& SerialHandle, const HTuple& NumCharacters, HTuple* Data )static void HOperatorSet.ReadSerial( HTuple serialHandle, HTuple numCharacters, out HTuple data )def read_serial( serial_handle: HHandle, num_characters: int ) -> Sequence[int]

def read_serial_s( serial_handle: HHandle, num_characters: int ) -> intHerror T_read_serial( const Htuple SerialHandle, const Htuple NumCharacters, Htuple* Data )

HTuple HSerial::ReadSerial( Hlong NumCharacters ) const

HTuple HSerial.ReadSerial( int numCharacters )

Description🔗

read_serialReadSerial tries to read NumCharactersnumCharactersnum_characters from the serial device given in SerialHandleserialHandleserial_handle. The read characters are returned in Datadatadata as a tuple of integers. This allows to read NUL characters, which would otherwise be interpreted as the end of a string. If the timeout of the serial device has been set to a value greater than 0 with set_serial_paramSetSerialParam, read_serialReadSerial waits at most as long for the arrival of the first character as indicated by the timeout. Otherwise, the operator returns immediately. In any case, the number of characters available at the time of return are passed back to the caller, i.e., fewer characters than requested can be returned. This can be checked by the length of the tuple Datadatadata.

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.

Parameters🔗

SerialHandleserialHandleserial_handle (input_control) serial → (handle)HTuple (HHandle)HSerial, HTuple (IntPtr)HHandleHtuple (handle)

Serial interface handle.

NumCharactersnumCharactersnum_characters (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Number of characters to read.

Default: 11
Suggested values: 1, 2, 3, 4, 5, 10, 20, 40, 1001, 2, 3, 4, 5, 10, 20, 40, 100

Datadatadata (output_control) integer(-array) → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Read characters (as tuple of integers).

Result🔗

If the parameters are correct and the read from the device was successful, the operator read_serialReadSerial returns the value 2 (H_MSG_TRUE). Otherwise an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

open_serialOpenSerial

See also

write_serialWriteSerial

Module🔗

Foundation