Class: SerialPort

SerialPort(serialport, serialoptions)

Represents a serialport object. Maintains an array of Client objects subscribed to the serial port.

Constructor

new SerialPort(serialport, serialoptions)

creates a SerialPort object

Parameters:
Name Type Description
serialport serialport

serialport object

serialoptions Object

JSON object of options for the serialport object

Properties:
Name Type Description
LOGGING Boolean

sets whether to console.log detailed information

serialPortName String

name of the connected serialport

serialOptions Object

JSON array of options for the serialport

messageListeners Array.<Client>

array of subscribed Client objects

Source:
See:

Methods

addClient(client)

add a web client to messageListeners array

Parameters:
Name Type Description
client Client

Client object subscribing to the SerialPort

Source:

closeSerial()

closes the serialport connection and sends message to the connected clients that the serialport is closed.

Source:

onMessage(msg)

Forwards message emitted by SerialPort events to the susbscribed clients in the messageListeners array

Parameters:
Name Type Description
msg Object

JSON object containing message method and data

Source:

openSerial()

Opens SerialPort of serialPortName with serialOptions. Sets serialport event listeners of method 'data', 'close' and 'error' and sends messages to the client via onMessage function

Source:

removeClient(client)

remove client from messageListeners array to unsubscribe client

Parameters:
Name Type Description
client Client

Client object unsubscribing to the SerialPort

Source: