@PiWolf said in Arduino serial data read/write.:
Clarification: Johnny-Five builds on Firmata, which is a general pupose Protocol (and Arduino Sketch) for programmatic interaction with Arduino and Arduino compatible development boards. See also https://github.com/firmata/arduino#usage. According to the usage outline, for JohnnyFive you would normally use the general purpose Sketch, e.g. StandardFirmata, and tell JohnnyFive how to interact with the board, e.g. which Pins to read/write, or which devices to interact with as there are numerous abstractions for analog and digitals sensors and actuators available.
If you cannot adapt to this model and you have a specific Arduino sketch to deal with, perhaps the approach outlined by @leader21 will be suitable for you. Another approach would be to write your own serialport driver based on node-serialport. This is also used for various pimatic plugins. For example, you can have a look at pimatic-homeduino where the serialport driver is implemented in an subordinate project: https://github.com/pimatic/homeduinojs. See board.coffee and serialport.coffee in the src folder.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law