Regular API function

simSerialRead

Description Reads from a previously opened serial port (RS-232). The C version of the function cannot be blocking. See also simSerialCheck and simSerialSend.
C synopsis simInt simSerialRead(simInt portHandle,simChar* buffer,simInt dataLengthToRead)
C parameters
portHandle: the handle returned by the simSerialOpen function
buffer: a buffer that will be filled with read data
dataLengthToRead: the maximum data length that should be read
C return value
-1 if operation was not successful, otherwise the effective data length that was read
Lua synopsis string data=simSerialRead(number portHandle,number dataLengthToRead,Boolean blockingOperation,string closingString='',number timeout=0)
Lua parameters
portHandle: the handle returned by the simSerialOpen function
dataLengthToRead: the maximum data length that should be read
blockingOperation: if true and the calling script is running in a thread, then the function only returns when the desired data length was read (or if the closingString was met, or if there was a timeout (see next arguments)
closingString: a string (containing any byte value) can be specified, that will break from the blocking operation if a match was found in the incoming data. Useful when you know that a data packet is always ended with a given signature. Can be an empty string for default operation.
timeout: duration after which the blocking operation will be aborted, or 0 if the timeout is infinite.
Lua return values
data: a string containing read data (excluding the closingString if it was specified and found)

All regular API functions on one page