Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multi-byte buffers. #17 #18

Merged
merged 2 commits into from Apr 5, 2013
Merged

Conversation

rwaldron
Copy link
Collaborator

@rwaldron rwaldron commented Apr 5, 2013

@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 waldron.rick@gmail.com

- 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

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
@rwaldron
Copy link
Collaborator Author

rwaldron commented Apr 5, 2013

Tests to follow

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
jgautier added a commit that referenced this pull request Apr 5, 2013
LGTM...pretty much exactly what I was planning on doing.  Thanks Rick!  There is actually a bug about the bufferSize that was introduced in streams2 nodejs/node-v0.x-archive#5098 but this is a good change anyways.  I will push this to npm later.
@jgautier jgautier merged commit c7e18cf into firmata:master Apr 5, 2013
@jgautier
Copy link
Member

jgautier commented Apr 5, 2013

Thanks @rwldrn! This is pretty much what I was planning on doing. The bufferSize argument to fs.createReadStream is broken though see: nodejs/node-v0.x-archive#5098 but this is a good change anyways. I will push to npm later.

@rwaldron
Copy link
Collaborator Author

rwaldron commented Apr 5, 2013

Awesome!

@rwaldron
Copy link
Collaborator Author

rwaldron commented Apr 5, 2013

@jgautier can you publish this to npm :D

@jgautier
Copy link
Member

jgautier commented Apr 5, 2013

published as 0.2.5

@rwaldron
Copy link
Collaborator Author

rwaldron commented Apr 5, 2013

Awesome, now I'll be spending the next few days testing all the things :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants