You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 24, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+57-2Lines changed: 57 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,11 @@
2
2
An NPM module which makes it easy to safely interface with your Arduino over serial.
3
3
It allows you to safely update it too. Great for remote mission critical deployments.
4
4
5
-
Want to make sure that your messages are received correctly? No problem! NMEA checksums are supported natively!
5
+
It has two modes: Binary mode and String mode.
6
+
7
+
Binary mode supports SLIP encoding, checksums, and one-way (computer-to-arduino) message confirmation checking for extremely robust communication.
8
+
9
+
String mode supports NMEA checking to make sure that your messages are received correctly.
6
10
7
11
## Usage
8
12
Get it through NPM by running: `npm install arduino-interface`
@@ -13,7 +17,7 @@ Compatible with node 6.x
13
17
### Troubleshooting
14
18
If your Arduino isn't being detected, you may need to add the productId to the boards.js file in [arduino-scanner](https://github.com/UBCSailbot/arduino-scanner). If this happens, please make a pull request to that repo have the boards.js updated so we can improve the module!
`writeAndWaitForAcknowledgment` will add the message to a queue of messages to send. This ensures that the messages
67
+
are sent in a proper order. Only if a message succeeds to send and gets an acknowledgement, or fails
68
+
to send after the amount of times specified in the "attempts" will it be dequeued.
69
+
70
+
The checksum is calculated by the XOR of each byte of your message, and is the very last byte of the message (before being SLIP encoded).
71
+
72
+
The acknowledgment byte is added automatically by this library if `acknowledgment` is true, and is the sequence number of the message in the queue.
73
+
It is added to the end of the message, before the checksum (and so is included in the checksum). This byte must be sent back from the Arduino
74
+
within the allotted `timeout` field in the `options` object or else the acknowledgment will have been considered a fail and the message will be resent.
75
+
Note that the acknowledgment byte sent back must also be SLIP encoded and have a checksum if `nmea` is enabled.
76
+
77
+
We recommend using the excellent [Packet Serial](https://github.com/bakercp/PacketSerial) library for Arduino
78
+
SLIP support, and adding your own checksum checker and acknowledgment sender on top of that
79
+
(we may release our own implementation at a later date).
80
+
81
+
We recommend [Google's Protobuf](https://github.com/google/protobuf) tool to serialize your data, but any serial encoding/decoding should work.
82
+
83
+
When Binary Mode is enabled, all incoming messages will be run through a SLIP decoding before being surfaced by `arduino.on('data', () => {})`,
84
+
so make sure that your Arduino encodes the data with SLIP before sending it back (can use the above Packet Serial for that as well).
85
+
41
86
## Reference Guide
42
87
### Constructor
43
88
Search for an Arduino and connect once it's found.
@@ -104,6 +149,16 @@ Writes to Arduino and waits for it to finish transmitting before calling the cb.
104
149
If the NMEA option was set to true then this message will be sent in accordance
0 commit comments