Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sv443/ez-serial-read
Makes reading the serial data of an Arduino and other serial devices really easy
https://github.com/sv443/ez-serial-read
arduino arduino-serial javascript js node-js nodejs npm npm-package serial serial-communication serial-port
Last synced: about 1 month ago
JSON representation
Makes reading the serial data of an Arduino and other serial devices really easy
- Host: GitHub
- URL: https://github.com/sv443/ez-serial-read
- Owner: Sv443
- License: mit
- Archived: true
- Created: 2019-02-03T01:12:07.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-28T09:43:40.000Z (almost 3 years ago)
- Last Synced: 2024-09-27T00:42:13.242Z (about 1 month ago)
- Topics: arduino, arduino-serial, javascript, js, node-js, nodejs, npm, npm-package, serial, serial-communication, serial-port
- Language: JavaScript
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ez-serial-read
## A package that makes the usage of [the serialport package](https://github.com/node-serialport/node-serialport) easier.
### This package was made to make reading an Arduino serial comm easier as normally you have to write many lines of code and end up getting a buffer instead of a string.
# Install:
```
> npm i --save ez-serial-read
```
# Usage:
(Arguments prefixed with `?` are optional and will have a default value)
```js
var success = ezSerial(comPort, ?baudRate, callback); // basic initialization
// typeof success = booleanezSerial.listAll(result => { // list all open serial ports
// typeof result = object array
});
```# Example:
```js
const ezSerial = require("ez-serial-read");var success = ezSerial("COM4", 9600, data => { // serial port, baud rate, data callback - if you don't know your serial port, run the listAll method like demonstrated below this snippet
// this function gets called every time a line is being received and the "data" variable contains that line
console.log(data);
});if(success) { // the ezSerial() function returns a boolean value that is true, if the connection could be established and false, if not
console.log("Successfully connected to the serial port!");
}
else {
console.log("Couldn't connect!");
}
```## If you don't know your COM ports, use this:
```js
const ezSerial = require("ez-serial-read");ezSerial.listAll(console.log);
```
This lists all serial ports to the console. It will look something like this:```js
[ { comName: 'COM3',
manufacturer: 'FTDI',
serialNumber: 'A702H5DS',
pnpId: 'FTDIBUS\\VID_0403+PID_6001+A702H5DSA\\0000',
locationId: undefined,
vendorId: '0403',
productId: '6001' },
{ comName: 'COM1',
manufacturer: '(Standard port types)',
serialNumber: undefined,
pnpId: 'ACPI\\PNP0501\\0',
locationId: undefined,
vendorId: undefined,
productId: undefined },
{ comName: 'COM4', // <- <- <- <- this is the actual port of our arduino we want to talk to, so we need to enter "COM4" in the initialization function
manufacturer: 'Arduino LLC (www.arduino.cc)',
serialNumber: '85633323530351905232',
pnpId: 'USB\\VID_2341&PID_0043\\85633323530351905232',
locationId: 'Port_#0003.Hub_#0003',
vendorId: '2341',
productId: '0043' } ]
```