Port:read(len)method

Reads data from the serial communication Port.

Parameters

len

A number indicating the number of bytes to read.

Return value

Returns a Task object to perform the read operation asynchronously.
Once the Task has terminated, it will return a Buffer that contains the data, or false in case of error.

Example

--! luart-extensions import serial local COM1 = serial.Port("COM1") if COM1:open() then print("COM1 serial port is now open") if await COM1:read(5) then print("5 bytes successfully received") else print("Read error") end else print("Failed to open COM1 serial port") end