Serial Ports (USB) and NodeJS support
I discovered a thread talking about NodeJS support on the Omega2/1. While I have basic Node working - one of the main things to access is the hardware ports such as Serial (over the USB). Interfacing to devices using the USB port - I would like to interface using a "SerialPort" module. Unfortunately the MIPS ports for most modules are lacking. Here is the deal - hardware specific modules require on-platform compilation. So SerialPort (which has versions for x86 and ARM), does NOT currently compile and install. What is the plan to get this ported?
Steven de Salas
:thumbsup: :thumbsup: I too would love a precompiled version of the
serialportnpm package delivered via
opkgas I dont think npm node-gyp compilation is ever going to work.
This is the way the Arduino Yun supports serial via nodejs (it also uses same chipset and similar openwrt distro).
node-usbpackage one but it doesnt seem to do anything. Cant find it on the file system, neither as npm global package or under
/usr/bindirectory, I also cant seem to use it via
You need serial support, not USB support - even if you are using a USB-serial adapter, the kernel presents it to application programs as a serial device, not a USB one.
Steven de Salas
I will try get a more easily consumable version (maybe another npm package?) but for now feel free to download a working version of firstname.lastname@example.org on the following link:
You just need to untar and move the
node_modulesin your project or global npm folder.
Here is a fork containing the cross-compiled binaries:
Since its in github you can install via npm:
$ npm install github:sdesalas/node-serialport-omega2
@Steven-de-Salas Many thanks. I attempted to use it but unlike the Python code that can read & dump the GPS module - while I do get the serial port to open - I cannot get it to receive and print any data to the console. It seems slow as well to open the port. I will probably debug it more tomorrow.
This post is deleted!
Might be useful to post the output of
stty -F /dev/ttyS[port number]for whatever serial device you are using, while your program is running.
One thing I've noticed is that the serial setting defaults can be different than what you'd typically find on a PC linux installation, for example I had a lazy (self written) program that didn't explicitly set
cread, and that was by default coming up off (
-cread) meaning serial receive was disabled.
Ignore my comment, I was using the wrong baud rate.
Its working fine.
This post is deleted!
@Steven-de-Salas How could I get that to work with Node Red please?
Cross compiled node-red-node-serialport and it all works:
root@Omega-1521:~# node --max-old-space-size=80 /node-red/red.js The host is: undefined Welcome to Node-RED =================== 28 Mar 00:13:43 - [info] Node-RED version: v0.15.2 28 Mar 00:13:43 - [info] Node.js version: v4.3.1 28 Mar 00:13:43 - [info] Linux 4.4.46 mipsel LE 28 Mar 00:13:51 - [info] Loading palette nodes 28 Mar 00:14:18 - [warn] ------------------------------------------------------ 28 Mar 00:14:18 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node 28 Mar 00:14:18 - [warn] ------------------------------------------------------ 28 Mar 00:14:18 - [info] Settings file : /root/.node-red/settings.js 28 Mar 00:14:18 - [info] User directory : /root/.node-red 28 Mar 00:14:18 - [info] Flows file : /root/.node-red/flows_Omega-1521.json 28 Mar 00:14:18 - [info] Server now running at http://192.168.3.1:1880/ 28 Mar 00:14:18 - [info] Starting flows 28 Mar 00:14:18 - [info] Started flows 28 Mar 00:14:18 - [info] serial port /dev/ttyACM0 opened at 57600 baud 8N1