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
local serial = require "serial"
local COM1 = serial.Port("COM1")
if COM1:open() then
print("COM1 serial port is now open")
if COM1:read(5):wait() then
print("5 bytes successfully received")
else
print("Read error")
end
else
print("Failed to open COM1 serial port")
end