Giter VIP home page Giter VIP logo

p5.serialserver's Introduction

p5.serialserver

About

p5.serialserver is a p5.js library that enables communication between your p5.js sketch and a serial enabled device, for example, an Arduino microcontroller.

This repository is part of the p5-serial project, for more info please visit https://github.com/p5-serial/p5.serial.github.io/.

Installation

In order to follow these steps:

  1. Connect an Arduino microcontroller or any other serial device to your computer.
  2. Clone or download this repository.
  3. Follow the steps to use either the Node.js version, or the Processing version.

Node.js version

  1. Open the terminal and navigate to this repository.
  2. Install the dependencies with the command npm install.
  3. Start the server with the command node startserver.js.

Processing version

  1. Install the latest Processing app, available at https://processing.org/.
  2. Navigate to the p5_serialserver/ folder on this repository and open the file p5_serialserver.pde with the Processing app.
  3. Run this app and follow the instructions on it.

Use

After running the server with Node.js or Processing, you can connect a client to the server.

For this you need to use the companion library p5.serialport available at https://github.com/p5-serial/p5.serialport, and follow the instructions over there.

Contributions

Info about contributing is available at the main repository of this organization: https://github.com/p5-serial/p5.serial.github.io/.

p5.serialserver's People

Contributors

davejm avatar dependabot[bot] avatar js6450 avatar kaganjd avatar montoyamoraga avatar ppeol avatar tigoe avatar tstefanich avatar vanevery avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

p5.serialserver's Issues

Using a different baud rate

Everything works fine at 9600 baud, but if I change the baud rate to some higher value in both my js script and on the micrcontroller, the communication does not work. The problem appears to be that the server automatically is configured to use 9600 baud. How can I change this on the server?

Error: Cannot find module 'ws'

When I try to sart the server with : $ node startserver.js
I get :
module.js:440
throw err;
^

Error: Cannot find module 'ws'
at Function.Module._resolveFilename (module.js:438:15)
at Function.Module._load (module.js:386:25)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.start (C:\p5.serialport-master\p5.serialserver.js:23:24)
at Object. (C:\p5.serialport-master\startserver.js:4:14)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)

What's wrong ?

Change default websocket address

In order to make the client more dynamic, change the default websocket address from localhost to the IP address obtained from document.location.hostname.

For example:

serial = new p5.SerialPort(document.location.hostname);

voila! Works from any client device's browser.

NullPointerException when selecting port after running PDE in Linux

Hello,

When I run the p5.serialserver PDE and select the Arduino port from the drop down menu the app crashes. Please see the screenshot and error log below.

I'm running Processing 4 on Manjaro

Any suggestions on a bug fix would be greatly appreciated, thank you

screen

SEVERE: An error occured while forwarding a Controller event, please check your code at selectPort
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at controlP5.ControlBroadcaster.invokeMethod(Unknown Source)
at controlP5.ControlBroadcaster.callTarget(Unknown Source)
at controlP5.ControlBroadcaster.broadcast(Unknown Source)
at controlP5.Controller.broadcast(Unknown Source)
at controlP5.Controller.setValue(Unknown Source)
at controlP5.ScrollableList.updateIndex(Unknown Source)
at controlP5.ScrollableList.onRelease(Unknown Source)
at controlP5.Controller.setMousePressed(Unknown Source)
at controlP5.ControllerGroup.setMousePressed(Unknown Source)
at controlP5.ControlWindow.mouseReleasedEvent(Unknown Source)
at controlP5.ControlWindow.mouseEvent(Unknown Source)
at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1309)
at processing.core.PApplet.handleMethods(PApplet.java:1456)
at processing.core.PApplet.handleMouseEvent(PApplet.java:2368)
at processing.core.PApplet.dequeueEvents(PApplet.java:2261)
at processing.core.PApplet.handleDraw(PApplet.java:2104)
at processing.awt.PSurfaceAWT$9.callDraw(PSurfaceAWT.java:1386)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:356)
Caused by: java.lang.RuntimeException: Error opening serial port /dev/ttyACM0: Permission denied
at processing.serial.Serial.(Unknown Source)
at processing.serial.Serial.(Unknown Source)
at p5_serialserver.selectPort(p5_serialserver.java:245)
... 25 more
NullPointerException

Naming is off

project called p5.serialport here
project called p5.serialserver on npm

Tom makes point that it should be called p5.serialsocket to accurately describe functionality

project does not build with Node 10

I'm having trouble copying the whole list of errors right now but they take the form:

> [email protected] install /Users/adi/dev/github/open-source/p5.serialport/node_modules/serialport
> node-pre-gyp install --fallback-to-build

node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ '/usr/local/Cellar/node/10.11.0/bin/node',
node-pre-gyp verb cli   '/Users/adi/dev/github/open-source/p5.serialport/node_modules/serialport/node_modules/.bin/node-pre-gyp',
node-pre-gyp verb cli   'install',
node-pre-gyp verb cli   '--fallback-to-build' ]
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | darwin | x64
node-pre-gyp verb command install []
node-pre-gyp info check checked for "/Users/adi/dev/github/open-source/p5.serialport/node_modules/serialport/build/Release/serialport.node" (not found)
node-pre-gyp http GET https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v64-darwin-x64.tar.gz
node-pre-gyp http 404 https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Tried to download(404): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v64-darwin-x64.tar.gz
node-pre-gyp verb command build [ 'rebuild' ]
node-pre-gyp ERR! Tried to download(undefined): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI) (falling back to source compile with node-gyp)
node-pre-gyp http Connection closed while downloading tarball file
node-pre-gyp verb command build [ 'rebuild' ]
  CXX(target) Release/obj.target/serialport/src/serialport.o
  CXX(target) Release/obj.target/serialport/src/serialport.o
../src/serialport.cpp:90:44: error: no matching member function for call to 'ToInt32'
  return getValueFromObject(options, key)->ToInt32()->Int32Value();
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
../src/serialport.cpp:90:44: error: /Users/adi/.node-gyp/10.11.0/include/node/v8.hno: 2433matching: 43member:  note: candidate function not viable: requires single argument 'context', but no
      arguments were provided
  V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
                                          ^
function/Users/adi/.node-gyp/10.11.0/include/node/v8.h:2446:34: note: candidate function not viable: requires single  argument for'isolate',  callbut  tono
'ToInt32'      arguments
 were provided
  return getValueFromObject(options, key)->ToInt32()->Int32Value();
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/Users/adi/.node-gyp/10.11.0/include/node/v8.h:2433:43: note: candidate function not viable: requires single argument 'context', but no
      arguments were provided
  V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
                                          ^
/Users/adi/.node-gyp/10.11.0/include/node/v8.h:2446:34: note: candidate function not viable: requires single argument 'isolate', but no
      arguments were provided
                    Local<Int32> ToInt32(Isolate* isolate) const);
                                 ^
                    Local<Int32> ToInt32(Isolate* isolate) const);
                                 ^
../src/serialport.cpp:102:44: error: no matching member function for call to 'ToNumber'
  return getValueFromObject(options, key)->ToNumber()->NumberValue();
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/Users/adi/.node-gyp/10.11.0/include/node/v8.h:2421:44: note: candidate function not viable: requires single ../src/serialport.cppargument: 102'context',: 44but:  no
      errorarguments:  were noprovided matching
 member function for call to 'ToNumber'
  V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(

Problem with ReadStringUntil

There's a reliably repeatable problem with readStringUntil:

  1. Send the following string from the remote device: 500, 230, 1\r\n (replace values with any numeric string)
  2. Read string with the following code:
function serialEvent() {
  // read a string from the serial port:
 var inString = serial.readStringUntil('\r\n');
  //check to see that there's actually a string there:
 if (inString.length > 0 ) {
  //put it in a global variable:
  inData = inString;
  }
}

result: one serialEvent is triggered, then nothing.

Now replace serialEvent with the following:

void serialEvent() {
   var inByte = char(serial.read());
   if (inByte === '\n') {
     inData = '';
   } else {
     inData += inByte;
   }
}

result: inData reliably gets the original string.

@vanevery I tested this after we parted, and it was indeed the right file after all.

Library does not work with https

I just updated the p5.js web editor to use https, which broke @tigoe's p5.serial example. I had to change the file p5.serialport.js, on line 78, to

this.socket = new WebSocket("wss://" + this.hostname + ":" + this.serverport);

to get it to work.

Sample code generated does not work

Here's the process for testing:

  1. open p5.serialcontrol
  2. scan for ports
  3. open a port
  4. Copy serial code as generated
  5. paste into a new sketch at https://editor.p5js.org
  6. add CDN link after line 6 of index.html: <script language="javascript" type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.serialport.js">
  7. Save
  8. Close serial port in serialcontrol app.
  9. Click Run

Result: sketch does not run.

ports.forEach(function(port) Error

According to the instruction, run ' node startserver.js', then use the demo example 'echo', but got the issue: how to solve this out
/p5.serialserver.js:142
ports.forEach(function(port) {
^
TypeError: Cannot read property 'forEach' of undefined

interest in serial over audio using webjack?

Hello, I am one of the developers of WebJack (https://github.com/publiclab/webjack) and love your library. I was curious if you'd be interested in an audio connection implementation of this lib, which would wrap WebJack and allow for connecting using the browser's WebRTC microphone API. It's not as solid as your implementation but is nice because it requires no app, and works on phones.

I think making a WebJack wrapper offer exactly the same methods as p5.serialport would be pretty easy, but wanted to ask if you're interested in this first. Otherwise I think I could refactor the simple example i have to at least match p5.serialport: https://p5js.org/examples/interaction-arduino-sensor-data-via-webjack.html

Thanks!

Not installing on Linux

Getting the following error when trying to install on linux (Ubuntu) with nodejs v.4.2.6
Same issue when trying to install locally.

$ sudo npm install -g p5.serialserver
/usr/local/bin/p5serial -> /usr/local/lib/node_modules/p5.serialserver/startserver.js

[email protected] install /usr/local/lib/node_modules/p5.serialserver/node_modules/serialport
node-pre-gyp install --fallback-to-build

/usr/bin/env: ‘node’: No such file or directory
/usr/local/lib
└── (empty)

npm ERR! Linux 4.8.0-52-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "p5.serialserver"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs serialport
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/////npm-debug.log
npm ERR! code 1

Could not locate the bindings files

Hi,

After cloning the package and using npm install I end up with this error when calling startserver.js:

`/Users/u0122145/Documents/p5.serialport/node_modules/bindings/bindings.js:91
throw err
^

Error: Could not locate the bindings file. Tried:
→ /Users/u0122145/Documents/p5.serialport/node_modules/serialport/build/serialport.node
→ /Users/u0122145/Documents/p5.serialport/node_modules/serialport/build/Debug/serialport.node
→ /Users/u0122145/Documents/p5.serialport/node_modules/serialport/build/Release/serialport.node
→ /Users/u0122145/Documents/p5.serialport/node_modules/serialport/out/Debug/serialport.node
→ /Users/u0122145/Documents/p5.serialport/node_modules/serialport/Debug/serialport.node
→ /Users/u0122145/Documents/p5.serialport/node_modules/serialport/out/Release/serialport.node
→ /Users/u0122145/Documents/p5.serialport/node_modules/serialport/Release/serialport.node
→ /Users/u0122145/Documents/p5.serialport/node_modules/serialport/build/default/serialport.node
→ /Users/u0122145/Documents/p5.serialport/node_modules/serialport/compiled/11.12.0/darwin/x64/serialport.node
at bindings (/Users/u0122145/Documents/p5.serialport/node_modules/bindings/bindings.js:88:9)
at Object. (/Users/u0122145/Documents/p5.serialport/node_modules/serialport/lib/bindings.js:3:35)
at Module._compile (internal/modules/cjs/loader.js:799:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
at Module.load (internal/modules/cjs/loader.js:666:32)
at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
at Function.Module._load (internal/modules/cjs/loader.js:598:3)
at Module.require (internal/modules/cjs/loader.js:705:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object. (/Users/u0122145/Documents/p5.serialport/node_modules/serialport/lib/serialport.js:12:25)`

p5.serialserver

When I tried to install p5.serialserver in my Mac I got the next errors:

> [email protected] install /Users/bsys/node_modules/p5.serialserver/node_modules/serialport
> node-pre-gyp install --fallback-to-build

node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ '/usr/local/bin/node',
node-pre-gyp verb cli   '/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/node_modules/.bin/node-pre-gyp',
node-pre-gyp verb cli   'install',
node-pre-gyp verb cli   '--fallback-to-build' ]
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | darwin | x64
node-pre-gyp verb command install []
node-pre-gyp info check checked for "/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/build/Release/serialport.node" (not found)
node-pre-gyp http GET https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v57-darwin-x64.tar.gz
node-pre-gyp ERR! Tried to download(undefined): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v57-darwin-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI) (falling back to source compile with node-gyp) 
node-pre-gyp http EACCES: permission denied, mkdir '/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/build' 
node-pre-gyp verb command build [ 'rebuild' ]
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/build'
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/build/Release/serialport.node" "--module_name=serialport" "--module_path=/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/build/Release"
gyp ERR! cwd /Users/bsys/node_modules/p5.serialserver/node_modules/serialport
gyp ERR! node -v v8.11.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/build/Release' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Darwin 17.5.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/bsys/node_modules/p5.serialserver/node_modules/serialport
node-pre-gyp ERR! node -v v8.11.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/Users/bsys/node_modules/p5.serialserver/node_modules/serialport/build/Release' (1)
npm WARN enoent ENOENT: no such file or directory, open '/Users/bsys/package.json'
npm WARN bsys No description
npm WARN bsys No repository field.
npm WARN bsys No README data
npm WARN bsys No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/bsys/.npm/_logs/2018-05-04T16_19_25_570Z-debug.log
~~~Go to ```~/node_modules``` create a folder called p5.serialserver paste ```startserver.js```~~~

~~~Run in terminal with node ```~/node_modules/p5.serialserver/startserver.js```~~~

Port List could display product name

from @tigoe

Attached is a kluge for getting port's board name.

A real version could look for the user’s ~/Library/Arduino15/packages, and in each package folder keep looking for boards.txt files, and take any line with .pid in it and pull the pid for comparison.

But this will get the names for now.

ListPorts.js

/*
Lists serial ports.
Copied from https://github.com/voodootikigod/node-serialport readme

refactored to get rid of anonymous functions, to make it clearer for
those new to JavaScript
*/

var pids = [{productName : 'Yún', productId : 0x0041},
{productName : 'Yún', productId : 0x8041},
{productName : 'Yún', productId : 0x0041},
{productName : 'Yún', productId : 0x8041},
{productName : 'Uno', productId : 0x0043},
{productName : 'Uno', productId : 0x0001},
{productName : 'Uno', productId : 0x0043},
{productName : 'Uno', productId : 0x0243},
{productName : 'Mega', productId : 0x0010},
{productName : 'Mega', productId : 0x0042},
{productName : 'Mega', productId : 0x0010},
{productName : 'Mega', productId : 0x0042},
{productName : 'Mega', productId : 0x0210},
{productName : 'Mega', productId : 0x0242},
{productName : 'Mega ADK', productId : 0x003f},
{productName : 'Mega ADK', productId : 0x0044},
{productName : 'Mega ADK', productId : 0x003f},
{productName : 'Mega ADK', productId : 0x0044},
{productName : 'Leonardo', productId : 0x0036},
{productName : 'Leonardo', productId : 0x8036},
{productName : 'Leonardo', productId : 0x0036},
{productName : 'Leonardo', productId : 0x8036},
{productName : 'Micro', productId : 0x0037},
{productName : 'Micro', productId : 0x8037},
{productName : 'Micro', productId : 0x0037},
{productName : 'Micro', productId : 0x8037},
{productName : 'Micro', productId : 0x0237},
{productName : 'Micro', productId : 0x8237},
{productName : 'Esplora', productId : 0x003C},
{productName : 'Esplora', productId : 0x803C},
{productName : 'Esplora', productId : 0x003C},
{productName : 'Esplora', productId : 0x803C},
{productName : 'LilyPad USB', productId : 0x9207},
{productName : 'LilyPad USB', productId : 0x9208},
{productName : 'Robot Control Board', productId : 0x0038},
{productName : 'Robot Control Board', productId : 0x8038},
{productName : 'Robot Control Board', productId : 0x0038},
{productName : 'Robot Control Board', productId : 0x8038},
{productName : 'Robot Motor Board', productId : 0x0039},
{productName : 'Robot Motor Board', productId : 0x8039},
{productName : 'Robot Motor Board', productId : 0x0039},
{productName : 'Robot Motor Board', productId : 0x8039},
{productName : 'Gemma', productId : 0x0c9f},
{productName : 'Arduino Zero (Programming Port)', productId : 0x2157},
{productName : 'Arduino Zero native', productId : 0x804d},
{productName : 'Arduino Zero native', productId : 0x004d},
{productName : 'Arduino Zero native', productId : 0x824d},
{productName : 'Arduino Zero native', productId : 0x024d},
{productName : 'MKR1000', productId : 0x804e},
{productName : 'MKR1000', productId : 0x004e},
{productName : 'MKR1000', productId : 0x824e},
{productName : 'MKR1000', productId : 0x024e},
{productName : 'Arduino 101', productId : 0x0AB6},
{productName : 'Flora8', productId : 0x8004},
{productName : 'Bluefruit Micro', productId : 0x800A},
{productName : 'Feather 32u4', productId : 0x800C},
{productName : 'Adafruit 32u4', productId : 0x8001},
{productName : 'Circuit Playground 32u4 cat', productId : 0x8011},
{productName : 'Adafruit feather M0', productId : 0x800B},
{productName : 'Adafruit feather M0', productId : 0x000B},
{productName : '#Adafruit radio M0', productId : 0x8014},
{productName : '#Adafruit radio M0', productId : 0x0014},
{productName : '#Adafruit metro M0', productId : 0x8013},
{productName : '#Adafruit metro M0', productId : 0x0013},
{productName : 'Blend', productId : 0x0036},
{productName : 'Blend', productId : 0x8036},
{productName : 'Blend Micro 8', productId : 0x2404},
{productName : 'Blend Micro 16', productId : 0x2404}];

var serialport = require("serialport");
var myName = "unknown";
// list serial ports:
serialport.list(listPorts);

function listPorts(error, ports) {
ports.forEach(printPort);

function printPort(port) {
    for (p in pids) {
        if (pids[p].productId == port.productId) {
            myName = pids[p].productName;
        }
    }
    console.log(port.comName + "\t" + port.manufacturer + "\t" + port.productId  + "\t" + myName );
}

}

Feature request: Callbacks should be able to access the port name

I was thinking about how to implement two-port sketches today. In Processing, the port generating the event is returned to serialEvent as a parameter like so:

void serialEvent(port) {

}

With this, you can take different actions depending on which port is sending data. It might be useful to have this option in P5 too. I tried to see if I could access the port using "this" in the callback functions, but it didn't work.

Is it working on windows ?

Hi , I installed node 0.12.7 and after i did npm -g install p5.serialserver
i run node startserver.js it starts but in P5.js as soon as i uncomment the line "serial = new p5.SerialPort(); " it gives an error : "Uncaught TypeError: undefined is not a function"

When i run the html file it doenst work either

Thx for the help !

Can ArrayBuffer data be sent?

Hello,
First of all, I'm loving the library it's amazing!

I'm not sure if this is a question or a feature request. I want to be able to send an ArrayBuffer of pixel data over serial to an LED matrix connected vai an Arduino.

I've created this sketch and Arduino code but just can't get the ArrayBuffer data to be received and/or processed correctly.
P5 sketch: https://editor.p5js.org/owenmcateer/sketches/mY4FOIUZ
I've left some comments in the sketch to explain whats going on.
Arduino code: https://gist.github.com/owenmcateer/1151febe57b7bd971255cfef2f0a2e06
(I have tested and confirmed this Arduino code to be working using glediator(a led display animation program that is sent over serial connection, glediator uses an end line market of \1))

Any help to point me in the right direction would be great. Thank you.

Errors when trying to install p5.serialserver

I have tried everything I can think of to try and download p5.serialserver on a mac. I used all three methods suggested in the documentation. It keeps giving me errors that 3 arguments are required, but 2 were provided like below:
npm ERR! /path/path/path/node-gyp/17.4.0/include/node/v8-object.h:247:37: note: candidate function not viable: requires 3 arguments, but 2 were provided
npm ERR! V8_WARN_UNUSED_RESULT Maybe Set(Local context, uint32_t index,

Then the following:
npm ERR! ^
npm ERR! 4 errors generated.
npm ERR! make: *** [Release/obj.target/bindings/src/serialport.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: make failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/path/path/path/.nvm/versions/node/v17.4.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:520:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.1.0
npm ERR! gyp ERR! command "/path/path/path/.nvm/versions/node/v17.4.0/bin/node" "/path/path/path/.nvm/versions/node/v17.4.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /path/path/path/.nvm/versions/node/v17.4.0/lib/node_modules/p5.serialserver/node_modules/@serialport/bindings
npm ERR! gyp ERR! node -v v17.4.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

I assume this is because there are updated required and some of the packages required have changed, but I'm not sure which packages or how to resolve this. Any ideas would be helpful.

Websocket Connection Failure

When trying to connect to serial in the usual way:

var serial = new p5.SerialPort();

I am graced with the ERR:
WebSocket connection to 'ws://localhost:8081/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

I've tried:

  • changing the port
  • changing the network
  • opening the port (not sure if I did that right tho)
  • changing browsers (firefox, chrome, safari)

Omitted callback functions cause port not to close

@tigoe reports that if client doesn't register callback for "close" and/or "error" when those happen the, port doesn't close.

It could either be a client side issue with the missing callback creating a condition where the close property isn't updated or a server side issue resulting from an error generated on the client side.

This should be tested/verified and corrected.

Serial.list() should return a list

Serial.list() should return a list. That way all the examples that do serial.list()[x] will be easier to translate from Processing. - Tom

port error in windows os

I am facing problem in getting the serial port from my port(COM3) which is defined in my sketch.js code.
Opening /dev/cu.usbmodem14131: Unknown error code 3
I am getting this error although my sketch.js is:

var serial; // variable to hold an instance of the serialport library
var portName = 'COM3'; // fill in your serial port name here
var inData; // for incoming serial data

function setup() {
  createCanvas(400, 300);
  serial = new p5.SerialPort(); // make a new instance of the serialport library
  serial.on('data', serialEvent); // callback for when new data arrives
  serial.on('error', serialError); // callback for errors

  serial.open(portName); // open a serial port
  serial.clear();
}

function draw() {
  // black background, white text:
  background(0);
  fill(255);
  // display the incoming serial data as a string:
  text("incoming value: " + inData, 30, 30);
}

function keyTyped() {
    var outByte = key;
    console.log("Sending " + outByte);
    //serial.write(Number(outByte)); // Send as byte value
    serial.write(outByte); // Send as a string/char/ascii value
}

function serialEvent() {
  // read a byte from the serial port:
  var inByte = serial.read();
  println("inByte: " + inByte);
  inData = inByte;
}

function serialError(err) {
  println('Something went wrong with the serial port. ' + err);
}

Does not install on kali linux

└─$ uname -a
Linux kali 5.16.0-kali7-amd64 #1 SMP PREEMPT Debian 5.16.18-1kali1 (2022-04-01) x86_64 GNU/Linux

┌──(jung㉿kali)-[~/Desktop/p5.serialport]
└─$ node --version
v16.15.0

┌──(jung㉿kali)-[~/Desktop/p5.serialport]
└─$ npm --version
8.8.0

┌──(jung㉿kali)-[~/Desktop/p5.serialport]
└─$ yarn --version
1.22.18

log details

yarn install v1.22.18
warning package.json: License should be a valid SPDX license expression
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
warning [email protected]: License should be a valid SPDX license expression
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Rebuilding all packages...
error /home/jung/Desktop/p5.serialport/node_modules/@serialport/bindings: Command failed.
Exit code: 1
Command: prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
Arguments:
Directory: /home/jung/Desktop/p5.serialport/node_modules/@serialport/bindings
Output:
prebuild-install WARN install No prebuilt binaries found (target=16.15.0 runtime=node arch=x64 libc= platform=linux)
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 3.9.12 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/home/jung/.nvm/versions/node/v16.15.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/jung/Desktop/p5.serialport/node_modules/@serialport/bindings/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/jung/.nvm/versions/node/v16.15.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/jung/.cache/node-gyp/16.15.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/jung/.cache/node-gyp/16.15.0',
gyp info spawn args '-Dnode_gyp_dir=/home/jung/.nvm/versions/node/v16.15.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/jung/.cache/node-gyp/16.15.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/jung/Desktop/p5.serialport/node_modules/@serialport/bindings',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/jung/Desktop/p5.serialport/node_modules/@serialport/bindings/build'
CXX(target) Release/obj.target/bindings/src/serialport.o
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Open(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:78:51: warning: cast between incompatible function types from ‘void ()(uv_work_t)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
78 | uv_queue_work(uv_default_loop(), req, EIO_Open, (uv_after_work_cb)EIO_AfterOpen);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Update(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:135:53: warning: cast between incompatible function types from ‘void ()(uv_work_t)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
135 | uv_queue_work(uv_default_loop(), req, EIO_Update, (uv_after_work_cb)EIO_AfterUpdate);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Close(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:175:52: warning: cast between incompatible function types from ‘void ()(uv_work_t)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
175 | uv_queue_work(uv_default_loop(), req, EIO_Close, (uv_after_work_cb)EIO_AfterClose);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Flush(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:215:52: warning: cast between incompatible function types from ‘void ()(uv_work_t)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
215 | uv_queue_work(uv_default_loop(), req, EIO_Flush, (uv_after_work_cb)EIO_AfterFlush);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Set(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:270:50: warning: cast between incompatible function types from ‘void ()(uv_work_t)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
270 | uv_queue_work(uv_default_loop(), req, EIO_Set, (uv_after_work_cb)EIO_AfterSet);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Get(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:314:50: warning: cast between incompatible function types from ‘void ()(uv_work_t)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
314 | uv_queue_work(uv_default_loop(), req, EIO_Get, (uv_after_work_cb)EIO_AfterGet);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘void EIO_AfterGet(uv_work_t*)’:
../src/serialport.cpp:329:17: error: no matching function for call to ‘v8::Object::Set(v8::Localv8::String, Nan::imp::FactoryBasev8::Boolean::return_t)’
329 | results->Set(Nan::Newv8::String("cts").ToLocalChecked(), Nan::Newv8::Boolean(data->cts));
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/jung/.cache/node-gyp/16.15.0/include/node/node.h:63,
from ../../../nan/nan.h:58,
from ../src/./serialport.h:6,
from ../src/serialport.cpp:1:
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3961:37: note: candidate: ‘v8::Maybe v8::Object::Set(v8::Localv8::Context, v8::Localv8::Value, v8::Localv8::Value)’
3961 | V8_WARN_UNUSED_RESULT Maybe Set(Local context,
| ^~~
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3961:37: note: candidate expects 3 arguments, 2 provided
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3964:37: note: candidate: ‘v8::Maybe v8::Object::Set(v8::Localv8::Context, uint32_t, v8::Localv8::Value)’
3964 | V8_WARN_UNUSED_RESULT Maybe Set(Local context, uint32_t index,
| ^~~
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3964:37: note: candidate expects 3 arguments, 2 provided
../src/serialport.cpp:330:17: error: no matching function for call to ‘v8::Object::Set(v8::Localv8::String, Nan::imp::FactoryBasev8::Boolean::return_t)’
330 | results->Set(Nan::Newv8::String("dsr").ToLocalChecked(), Nan::Newv8::Boolean(data->dsr));
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/jung/.cache/node-gyp/16.15.0/include/node/node.h:63,
from ../../../nan/nan.h:58,
from ../src/./serialport.h:6,
from ../src/serialport.cpp:1:
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3961:37: note: candidate: ‘v8::Maybe v8::Object::Set(v8::Localv8::Context, v8::Localv8::Value, v8::Localv8::Value)’
3961 | V8_WARN_UNUSED_RESULT Maybe Set(Local context,
| ^~~
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3961:37: note: candidate expects 3 arguments, 2 provided
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3964:37: note: candidate: ‘v8::Maybe v8::Object::Set(v8::Localv8::Context, uint32_t, v8::Localv8::Value)’
3964 | V8_WARN_UNUSED_RESULT Maybe Set(Local context, uint32_t index,
| ^~~
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3964:37: note: candidate expects 3 arguments, 2 provided
../src/serialport.cpp:331:17: error: no matching function for call to ‘v8::Object::Set(v8::Localv8::String, Nan::imp::FactoryBasev8::Boolean::return_t)’
331 | results->Set(Nan::Newv8::String("dcd").ToLocalChecked(), Nan::Newv8::Boolean(data->dcd));
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/jung/.cache/node-gyp/16.15.0/include/node/node.h:63,
from ../../../nan/nan.h:58,
from ../src/./serialport.h:6,
from ../src/serialport.cpp:1:
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3961:37: note: candidate: ‘v8::Maybe v8::Object::Set(v8::Localv8::Context, v8::Localv8::Value, v8::Localv8::Value)’
3961 | V8_WARN_UNUSED_RESULT Maybe Set(Local context,
| ^~~
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3961:37: note: candidate expects 3 arguments, 2 provided
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3964:37: note: candidate: ‘v8::Maybe v8::Object::Set(v8::Localv8::Context, uint32_t, v8::Localv8::Value)’
3964 | V8_WARN_UNUSED_RESULT Maybe Set(Local context, uint32_t index,
| ^~~
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3964:37: note: candidate expects 3 arguments, 2 provided
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE GetBaudRate(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:363:58: warning: cast between incompatible function types from ‘void ()(uv_work_t)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
363 | uv_queue_work(uv_default_loop(), req, EIO_GetBaudRate, (uv_after_work_cb)EIO_AfterGetBaudRate);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘void EIO_AfterGetBaudRate(uv_work_t*)’:
../src/serialport.cpp:378:17: error: no matching function for call to ‘v8::Object::Set(v8::Localv8::String, Nan::imp::IntegerFactoryv8::Integer::return_t)’
378 | results->Set(Nan::Newv8::String("baudRate").ToLocalChecked(), Nan::Newv8::Integer(data->baudRate));
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/jung/.cache/node-gyp/16.15.0/include/node/node.h:63,
from ../../../nan/nan.h:58,
from ../src/./serialport.h:6,
from ../src/serialport.cpp:1:
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3961:37: note: candidate: ‘v8::Maybe v8::Object::Set(v8::Localv8::Context, v8::Localv8::Value, v8::Localv8::Value)’
3961 | V8_WARN_UNUSED_RESULT Maybe Set(Local context,
| ^~~
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3961:37: note: candidate expects 3 arguments, 2 provided
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3964:37: note: candidate: ‘v8::Maybe v8::Object::Set(v8::Localv8::Context, uint32_t, v8::Localv8::Value)’
3964 | V8_WARN_UNUSED_RESULT Maybe Set(Local context, uint32_t index,
| ^~~
/home/jung/.cache/node-gyp/16.15.0/include/node/v8.h:3964:37: note: candidate expects 3 arguments, 2 provided
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Drain(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:409:52: warning: cast between incompatible function types from ‘void ()(uv_work_t)’ {aka ‘void ()(uv_work_s)’} to ‘uv_after_work_cb’ {aka ‘void ()(uv_work_s, int)’} [-Wcast-function-type]
409 | uv_queue_work(uv_default_loop(), req, EIO_Drain, (uv_after_work_cb)EIO_AfterDrain);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: At global scope:
../src/serialport.cpp:430:28: warning: unnecessary parentheses in declaration of ‘ToParityEnum’ [-Wparentheses]
430 | SerialPortParity NAN_INLINE(ToParityEnum(const v8::Localv8::String& v8str)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp:430:28: note: remove parentheses
430 | SerialPortParity NAN_INLINE(ToParityEnum(const v8::Localv8::String& v8str)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| - -
../src/serialport.cpp:449:30: warning: unnecessary parentheses in declaration of ‘ToStopBitEnum’ [-Wparentheses]
449 | SerialPortStopBits NAN_INLINE(ToStopBitEnum(double stopBits)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp:449:30: note: remove parentheses
449 | SerialPortStopBits NAN_INLINE(ToStopBitEnum(double stopBits)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| - -
In file included from ../../../nan/nan.h:58,
from ../src/./serialport.h:6,
from ../src/serialport.cpp:1:
/home/jung/.cache/node-gyp/16.15.0/include/node/node.h:847:7: warning: cast between incompatible function types from ‘void ()(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void ()(v8::Localv8::Object)’} to ‘node::addon_register_func’ {aka ‘void ()(v8::Localv8::Object, v8::Localv8::Value, void)’} [-Wcast-function-type]
847 | (node::addon_register_func) (regfunc),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jung/.cache/node-gyp/16.15.0/include/node/node.h:881:3: note: in expansion of macro ‘NODE_MODULE_X’
881 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
| ^~~~~~~~~~~~~
../src/serialport.cpp:483:1: note: in expansion of macro ‘NODE_MODULE’
483 | NODE_MODULE(serialport, init);
| ^~~~~~~~~~~
make: *** [bindings.target.mk:116: Release/obj.target/bindings/src/serialport.o] Error 1
make: Leaving directory '/home/jung/Desktop/p5.serialport/node_modules/@serialport/bindings/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/jung/.nvm/versions/node/v16.15.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (node:events:527:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Linux 5.16.0-kali7-amd64
gyp ERR! command "/home/jung/.nvm/versions/node/v16.15.0/bin/node" "/home/jung/.nvm/versions/node/v16.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/jung/Desktop/p5.serialport/node_modules/@serialport/bindings
gyp ERR! node -v v16.15.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

WHY DOES THIS NOT WORK? WHAT IS MISSING? DOES THIS NOT WORK ON LINUX?

Transmiting data through serial from a python script

Hello !

I'm trying to get data from a python script into a p5.js app.

In your example, I have only find communication with arduino but not with other program.
I'm using this python librairy but didn't succeed to make it work. I'm not an expert on serial neither.

Is it possible to make such a workflow work ?

I'll be happy to contribute to your doc/example if I manage to make it work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.