Opens a serial port by it's name. The 'portName' should not contain the "\\.\" prefix as this is provided for you. You may optionally provide a baud rate, otherwise it will default to 9600.
If this function succeeds, a new serial port object will be returned. If this function fails, it returns
See the documentation for the Serial Port Class to learn how to use this object.
local port,errMsg = serial.open("COM7"); -- Open COM7 with a default baud rate of 9600
local port2,errMsg2 = serial.open("COM8", 115200); -- Open COM8 with baud rate of 115200
if( not port ) then
printf("Failed to open COM7: %s\n", errMsg);
end
if( not port2 ) then
printf("Failed to open COM8: %s\n", errMsg2);
end
Page last updated at 2018-09-25 20:48:24
Copyright 2024