Skip to content
Builds
No builds

Maven project MSSerialConnection

MSSerialConnection

Provides serial connection API for the MethodScript programming language.

Functions

SerialConnectionFunctions

Provides serial connection API that can be used to communicate with serial devices through COMPORT/USB.

void serial_connect(string portName, int baudRate, int numDataBits, int numStopBits, string parity, boolean setRTS, boolean setDTR):

Opens a serial connection to the given serial port using the given parameters. parity has to be one of: PARITY_NONE, PARITY_ODD, PARITY_EVEN, PARITY_MARK and PARITY_SPACE. Many common microprocessors work with settings: numDataBits = 8, numStopBits = 1, parity = PARITY_NONE, setRTS = true and setDTR = true. Look up the specifications of your serial device if this does not work. Throws IllegalArgumentException when parity is not one of: PARITY_NONE, PARITY_ODD, PARITY_EVEN, PARITY_MARK and PARITY_SPACE. Throws IllegalStateException when the given serial port has already been opened by MSSerialConnection. Throws SerialPortException when connecting failed.

void serial_disconnect(string portName):

Disconnects from the given serial port. Throws an IllegalStateException when the given serial port was not open.

array serial_get_ports():

Returns an array containing all serial ports in the system.

boolean serial_is_connected(string portName):

Returns true if this port was opened by serial_connect(), and not yet closed by serial_disconnect(). Note that connection failures are not automatically detected, and therefore not considered by this function.

void serial_send(string serialPort, byte_array data):

Sends the given data to the given serial connection. Throws IllegalStateException when the given serial port was not open. Throws SerialPortException when sending the data to the serial port fails.

Events

SerialConnectionEvents

Contains events related to serial connections.

serial_data_received

Fired when data is received through a serial connection.

Prefilters

Event Data

string serialport: The serial port name
byte_array data: The raw received data

Mutable Fields

Last Successful Artifacts
MSSerialConnection-1.0.2-SNAPSHOT.jar548.43 KiB view
original-MSSerialConnection-1.0.2-SNAPSHOT.jar30.29 KiB view