Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Steve Lim
    Hi, I am trying to open a serial port with none for flow control. I am following the Github and cannot understand why my port.read is just echoing my port.write

    port.on('open', function(){
    console.log('Port Opened');

    port.on('data', function(data){
    data = data.toString();

    thats all im trying to do
    Steve Lim
    I got it, nothing wrong with the code, it was the device issue
    hello,I can't install serialport on my ubuntu, anyone could help me?
    Sara Mae
    hello all
    Am I missing something trying to use @serialport/stream and mockbindings because I cannot get the realine parser on'data' to fire at all
    I am a new serialport user. I have got it working to send a data stream out. I would like to ask someones help with some example code on how to listen for a response from the other device when I send a string out. Would some kind soul be able to assist me please?
    Frank Lemanschik
    @Vercellotti this code already should be in the repo :)
    const SerialPort = require('serialport')
    const Readline = require('@serialport/parser-readline')
    const port = new SerialPort('/dev/tty-usbserial1')
    const parser = new Readline()
    // Here we wait for data and do console.log
    parser.on('data', console.log)
    // Here we send data and do nothing else
    port.write('ROBOT PLEASE RESPOND\n')
    this example uses the searl port stream interface
    Frank Lemanschik
    you can see we pipe the port stream which is bidirectional read/ẃrite
    into the parser Stream that is write only
    the parser stream processes the data of the port stream
    Many thanks Frank.
    Scott Foster
    Adding on to @Vercellotti 's question (I'm a bit new to streams): I need be able to keep track of which command I write triggered the response I read. Is pairing each port.write(...) with a corresponding port.once('data',...) function a reasonable way to do this, or is there a more sensible / direct way?
    I also considered having my write commands set a "lastCommandSent" flag and having a port.on("data",...) function that checks the flag before processing the response, but that felt like a bad pattern.
    Juan José Bermúdez
    Hi, I have a problem with the write function on a raspberry using UART port: it doesn't report any error but the execution stops.

    ``` const SerialPort = require('serialport')
    const port = new SerialPort('/dev/ttyAMA0', {
    baudRate: 9600,
    autoOpen: false

    port.open(function (err) {
    if (err) {
    return console.log('Error opening port: ', err.message)


    // The open event is always emitted
    port.on('open', function() {
    // open logic
    console.log('opened ')
    var buf = new Buffer([ 0xC1, 0xC1, 0xC1 ]);
    port.write(buf, function(err,n) {
    if (err) {
    return console.log('Error on write: ', err.message)
    console.log('message written')

    }) ```

    @scottosaur_gitlab The way we handle this is to send one command at a time and wait for a response before sending the next command. We send a command and set a timeout that the device must respond within. If we receive a response that makes some kind of sense, then we move on. If the response doesn't make sense or we don't receive a response in a specified amount of time, then we throw an exception. So commands are sent in a serial manner, one at a time and we ensure we get a response. We deal with up to 28 ports simultaneously and keep track of them in an array. We also use sockets to communicate with a browser window, so we can have up to 28 browser windows open simultaneously, talking to 28 ports. We tack the socket ID on to the serial port info so when we get a response, we know which browser window it came from and then gets sent back to. The limitation of 28 ports is not a real limitation but the number of ports we could physically connect to one computer before we ran out of hardware.
    Marko Bregant
    Hello everyone! I have an electron app which connects via johnny-five to arduino and everything works fine in development. When I package my app with electron-packager and open my app I get this error: Uncaught Exception: /path/to/app/release/Rozi-darwin-x64/Rozi.app/Contents/Resources/app/node_modules/johnny-five/node_modules/serialport/lib/serialport.js:1 Error: Cannot find module 'debug'. Anyone has any idea what am I doing wrong?
    Bryan Hughes
    @eMarek that typically happens when you have a native module (a.k.a. something written in C++) that was compiled against the wrong version of Node.js. This is very common with Electron, and you'll want to make use of the electron-rebuild module to fix it: https://github.com/electron/electron-rebuild
    Hi there
    i need some help
    with node serial port
    i asked question on stackoverflow
    please help
    Hi! is somebody try to use node-serial port with cctalk protocol ?
    I have found CCTALK module https://github.com/direktspeed/ds-cctalk, but I don't know how to use it correct
    M Wittig
    @usmanakram-ts See my answer post on Stack Overflow
    Hi. I'm doing a website with node js and I react and I need to access the PC Com port, I'm using the serialport dependency of node js. The program shows ports in localhost, but when I deploy in Heroku or Google Cloud, the program shows nothing.
    How do you want a cloud server to access your local serial port?
    Bryan Hughes
    To clarify @tagyoureit’s comment to you @EdgarEsco cloud services do not have access to your local machine, including your serial ports. You’ll need to write an app that runs locally on your machine that talks to your cloud service using HTTP requests.
    Guido Pontet
    Hi! i wanna update from v6.1.1 to v7.1.5, but on v7.x.x and above, there is no assets to download and i need them for windows, linux and macos. Anyone know where these assets are available to download? Thanks!
    Victor Aprea
    hey guys, has anyone had any problems with some characters not making it from a host to an arduino intact when you write a string
    like I've seen cases today where I write 'get timestamp'
    and the arduino sees 'gep'
    or 'gea'
    which I surmise were: gexxxxxxxxxxp and gexxxxxxxxaxx respectively
    i'm trying to work around this by breaking the string into characters and introducing an intra-character delay of 10ms
    but it would be nice to know if "it's not just me"
    i'm pretty sure i'm not overflowing the 64-byte input buffer on the arduino either
    and there's nothing going on in my arduino code that would be disabling interrupts or what not
    John Melody Me
    Frank Lemanschik
    @vicatcu thats normal for serial communication