Difference between revisions of "Serial Module"

From SolarStrike wiki
Jump to: navigation, search
(Created page with "See also: Serial Port Class == open == '''serialPort serial.open(string portName)''' '''serialPort serial.open(string portName, number baudRate)''' Opens a serial port b...")
 
m
 
Line 8: Line 8:
  
 
If this function succeeds, a new serial port object will be returned. If this function fails, it returns false plus an error message.
 
If this function succeeds, a new serial port object will be returned. If this function fails, it returns false plus an error message.
 +
 +
See the documentation for the [[Serial Port Class]] to learn how to use this object.
  
  

Latest revision as of 20:43, 26 February 2018

See also: Serial Port Class

open

serialPort serial.open(string portName) serialPort serial.open(string portName, number baudRate)

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 false plus an error message.

See the documentation for the Serial Port Class to learn how to use this object.


Example:

local port = serial.open("COM7"); -- Open COM7 with a default baud rate of 9600
local port2 = serial.open("COM8", 115200); -- Open COM8 with baud rate of 115200