We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

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?



  • šŸ‘ šŸ‘ I too would love a precompiled version of the serialport npm package delivered via opkg as 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).

    I noticed opkg has a node-usb package one but it doesnt seem to do anything. Cant find it on the file system, neither as npm global package or under /usr/bin directory, I also cant seem to use it via require('usb').



  • 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.



  • Hey @Ashu-Joshi @chris-stratton, there is a solution for this.

    See comment in this link.
    @Steven-de-Salas said in Serial port communication using Node.js:

    Hi guys, I just thought you'd like to know that I got serialport npm module cross compiled for the Omega2 following instructions here and here.

    I will try get a more easily consumable version (maybe another npm package?) but for now feel free to download a working version of serialport@3.0.0 on the following link:

    https://github.com/sdesalas/robotics/raw/master/omega2/node-serialport-v3.0.0.tar.gz

    You just need to untar and move the node_modules/serialport and node_modules/.bin folders to node_modules in your project or global npm folder.


    Even better:

    Here is a fork containing the cross-compiled binaries:

    https://github.com/sdesalas/node-serialport-omega2

    Since its in github you can install via npm:

    $ npm install github:sdesalas/node-serialport-omega2
    

    Cherio.
    S



  • @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
    


  • This is a Cross compiled node-red-node-serialport 0.8.1 for Onion omega 2/2+/2 Pro
    https://github.com/t2t-sonbui/Node-Red-Omega-2



Looks like your connection to Community was lost, please wait while we try to reconnect.