Port:open([state])method
Open the Port for serial communication with another connected device.
Parameters
[state]
An optional table to configure the serial communication, using the following optional fields :
["rts"]: astringthat indicates the RTS mode, defaulting to"off"(see Port-rts.html for other possible values)["dtr"]: astringthat indicates the DTR control signal, defaulting to"disabled"(see Port-dtr.html for other possible values)["baudrate"]: anumberthat indicates the transmission speed, defaulting to9600(see Port-baudrate.html for other possible values)["bytesize"]: anumberthat indicates the byte size, defaulting to8(see Port-bytesize.html for other possible values)["parity"]: astringthat indicates the parity mode, defaulting to"none"(see Port-parity.html for other possible values)["stopbits"]: astringthat indicates the stop bits mode, defaulting to"one"(see Port-stopbits.html for other possible values)
Return value
Returns true if serial Port has been successfully opened.In case of error, returns false. Error message can be obtained with the sys.error property.
Example
--! luart-extensions
import serial
local COM1 = serial.Port("COM1")
if COM1:open() then
print("COM1 serial port is now open")
else
print("Failed to open COM1 serial port")
end