read_serialT_read_serialReadSerialReadSerialread_serial (算子)

名称

read_serialT_read_serialReadSerialReadSerialread_serial — 从串行设备读取。

签名

read_serial( : : SerialHandle, NumCharacters : Data)

Herror T_read_serial(const Htuple SerialHandle, const Htuple NumCharacters, Htuple* Data)

void ReadSerial(const HTuple& SerialHandle, const HTuple& NumCharacters, HTuple* Data)

HTuple HSerial::ReadSerial(Hlong NumCharacters) const

static void HOperatorSet.ReadSerial(HTuple serialHandle, HTuple numCharacters, out HTuple data)

HTuple HSerial.ReadSerial(int numCharacters)

def read_serial(serial_handle: HHandle, num_characters: int) -> Sequence[int]

def read_serial_s(serial_handle: HHandle, num_characters: int) -> int

描述

read_serialread_serialReadSerialReadSerialReadSerialread_serial tries to read NumCharactersNumCharactersNumCharactersNumCharactersnumCharactersnum_characters from the serial device given in SerialHandleSerialHandleSerialHandleSerialHandleserialHandleserial_handle. The read characters are returned in DataDataDataDatadatadata 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_paramset_serial_paramSetSerialParamSetSerialParamSetSerialParamset_serial_param, read_serialread_serialReadSerialReadSerialReadSerialread_serial 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 DataDataDataDatadatadata

执行信息

参数

SerialHandleSerialHandleSerialHandleSerialHandleserialHandleserial_handle (输入控制)  serial HSerial, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Serial interface handle.

NumCharactersNumCharactersNumCharactersNumCharactersnumCharactersnum_characters (输入控制)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Number of characters to read.

默认值: 1

建议值: 1, 2, 3, 4, 5, 10, 20, 40, 100

DataDataDataDatadatadata (输出控制)  integer(-array) HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Read characters (as tuple of integers).

结果

If the parameters are correct and the read from the device was successful, the operator read_serialread_serialReadSerialReadSerialReadSerialread_serial 返回值 2 ( H_MSG_TRUE )。否则将抛出异常。

可能的前趋

open_serialopen_serialOpenSerialOpenSerialOpenSerialopen_serial

另见

write_serialwrite_serialWriteSerialWriteSerialWriteSerialwrite_serial

模块

基础