Port:write(data)method
Writes data to the serial communication Port.
Parameters
data
A Buffer or a string containing the data to be written. If another type of variable is used, it is internaly converted to a string before sending.
Return value
Returns a Task object to perform the write operation asynchronously.Once the Task has terminated, it will return the number of bytes written, 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:write("First message") then
print("Data successfully written")
else
print("Write error")
end
else
print("Failed to open COM1 serial port")
end