Skip to main content
Version: Next

Debugging

Debugging Output​

We use the debug package and log under the serialport namespace. Each package has it's own scope

  • serialport/stream for all stream released logging
  • serialport/binding* for all binding related logging
  • serialport* for everything

You can enable logging through environment variables. Check the debug docs for info.

Linux and OSX​

DEBUG=serialport/stream node myapp.js
DEBUG=serialport* node myapp.js
DEBUG=* node myapp.js

Windows Command Prompts​

CMD​

On Windows the environment variable is set using the set command.

set DEBUG=serialport*

Example:

set DEBUG=serialport* & node myapp.js

PowerShell (VS Code default)​

PowerShell uses different syntax to set environment variables.

$env:DEBUG = "serialport*"

Example:

$env:DEBUG='serialport*'; node app.js

Core dumps​

You can enable core dumps on osx with;

ulimit -c unlimited for core dumps

You can "console.log" from c++ with;

fprintf(stdout, "Hellow World num=%d str=%s\n", 4, "hi");

Repl​

You can make use of the serialport-repl command with;

DEBUG=serialport* serialport-repl # to auto detect an arduino
DEBUG=serialport* serialport-repl /path/name # to connect to a specific port

and it will load a serialport object with debugging turned on.

Multiple Ports Slowdown​

When working with multiple Serial Ports you might see slowdowns in reading and writing. This is caused by thread pool exhaustion in NodeJS. You can set the UV_THREADPOOL_SIZE environment variable to be set to 1 + the number of ports you wish to open at a time. Defaults to 4 which supports 3 open ports. This might increase your performance.