This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Hang using serialport package under nRF Connect

I modified the BLE Low Enery app under nRF Connect (Windows), and fork a custom .js file to connect to a comm port.  The custom file requires 2 packages, fs and serialport.  Running the .js file using node.js works fine, but running via nRF Connect require('fs') works, but then require('serialport') hangs the .js.  The .js doesn't have console access so I write to a log file for debug and status.  Upon require('serialport') I get nothing, but otherwise nRF Connect continues to run. 

Any reason for this, or ideas on how to fix?

  • This is not my expertise, but I have asked somebody with more knowledge about this to look into it.

    Best regards,

    Simon

  • Do you have a production built nRFConnect Desktop (which version) or locally built from sources?

    Can I ask what do you mean by .js doesn't have console access?

    Can you open the dev-console (by Ctrl+Shift+I) and type require('serialport') there? Do you get error/undefined/function output, or does it hang?

    Do you have your sources available?

    BR, Bence

  • Yes, using production install of v2.5.0.

    No console because starting in Windows from icon, console.log() doesn't have a window to print in, and logger.info() from my called .js doesn't seem to go to the log window.

    Didn't know about Ctl+Shift+I.  Nice.  I get this, plus a big grey screen of "function SerialPort(.....blah, blah)" if I hover over the right spot, but it doesn't hang.

    require('serialport')
    ƒ SerialPort(path, options, openCallback) {
      if (!(this instanceof SerialPort)) {
        return new SerialPort(path, options, openCallback);
      }

      if (options instanceof Function) {
        openCallback = o…

    I have sources if you would like.  I only changed 2 files of the BLE Low Energy app, and added a .js and a config.json file.

    -Marty

  • Marty, since you can require serialport (otherwise require would have returned with undefined) that is not the issue.

    Is there a reason you need to use 2.5.0? Can you update to latest 2.6.1?

    logger.*() entries should end up in the app's LogViewer, console.*() should log to dev-console and in case of dev build of nRFConnect also to terminal/command window.

    Also if you develop an app, I would highly recommend to use a locally built development version of nRFConnect, though it's not necessary, it has many many advantages. One is that you'll get access to app actions and states. Also you can install react extension to the dev-console could prove to be useful.

    If you can't trace down the issue, please share the changes, e.g. you can push your source to a GitHub repo.

    Bence

  • I built 2.6.1 and got the same results.  I didn't get any output from console.log(), at least not in the window in which I ran the app.  Note I run my .js file using fork().  But I didn't get any console output from either an app file (adapterActions.js) or my forked file.

    If I push code to GitHub should I push the whole Bluetooth Low Energy app (200 files, GitHub complained) or just the couple files I changed/added?

    I'm not familiar with the actions/states features, or with the react extension.  Any good references you'd suggest?

    -Marty

Related