jgautier/firmata — pull request #18 by rwldrn (2013-04-05 19:08:52+00:00)
Title: Support for multi-byte buffers. #17

@jgaultier I decided to help out by attempting to find a solution.

- updates "data" handler to loop over data array, instead of copying data[0]
- push each byte into into currentBuffer
- inspect currentBuffer in each loop iteration for [START_SYSEX, …, END_SYSEX] or MIDI commands
- when [START_SYSEX, …, END_SYSEX] or MIDI are found, invoke command and clear currentBuffer

```
$ npm test

> firmata@0.2.4 test /Users/rick/clonez/firmata
> mocha test/firmata.js

․․․․․․․․․․․․․․․․

16 tests complete (18 ms)
```

```
$ ./repl.js
Enter USB Port and press enter:
/dev/cu.usbmodem411
Successfully Connected to /dev/cu.usbmodem411
firmata>board.pinMode(13, 0x01);
undefined
firmata>board.di
board.digitalRead board.digitalWrite

firmata>board.digitalWrite(13, 1)
undefined
firmata>board.digitalWrite(13, 0)
```

```
$ node examples/blink.js
blink start ...
connected
Firmware: StandardFirmata-2.3
+
-
+
-
+
-
+
-
+
-
+
-
+
-
```

Signed-off-by: Rick Waldron