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 |
Methods
addClient(client)
add a web client to messageListeners array
Parameters:
Name | Type | Description |
---|---|---|
client |
Client |
|
- 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 |
|
- Source: