third byte in MIDI message (sometimes) not correct

Bug #879090 reported by Milan M.
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ttyMIDI
Fix Released
High
Jari Suominen

Bug Description

I encountered a problem when playing around with a simple arduino sketch that just turns notes on and off. Sometimes the third byte of the message was not read correctly and the value of the last message was used or ttymidi just read zeros (seems to depend on baud rate).
Then I saw that when using the -p option (nothing else changed), suddenly the output was correct.
So I looked into the read_midi_from_serial_port function: When I change the "read(serial, buf+1, 2);" in line 418 to two consecutive reads like this: "read(serial, buf+1, 1); read(serial, buf+2, 1);" the error doesn't come up anymore (with -p the read function is used in the same way).
My naive conclusion would be that the Computer just can't read two bytes at once because it's to fast for the arduino, but I just started today with microcontrollers :) Is this a real bug or did I just mess it up?

If it is of any interest, I'm using:
Linux 2.6.39-1-amd64 on Debian testing
AMD Phenom II X4 920 Processor
DFRobot Arduino Clone Mega 2560
Arduino 0022 from unstable

Revision history for this message
Jari Suominen (jari-tasankokaiku) wrote :

Hello, I bumped to this bug four days ago and figured out same solution. Although I think your reasoning is probably not a correct one, read-function will just probably check if there is something to be read, but doesn't check if there is more than 1 in cases where you want to read more bytes.

Anyways we are releasing new version of ttymidi next week which has more changes than this, and we are still testing it out. But if you are brave, just fetch new version from the repo. But remember to update your ardumidi-library as well as the data between Arduino and ttymidi is now 'real MIDI'.

Changed in ttymidi:
importance: Undecided → High
status: New → Fix Committed
assignee: nobody → Jari Suominen (jari-tasankokaiku)
Revision history for this message
Milan M. (accxunt) wrote :

Hello,
I think I meant somethin like this with "too fast", but what you say clarifies it.
anyway, just wanted to say thanks for your fast reply - and for writing ttymidi in the first place :) It's a great tool for learning to program your own midi stuff. The "real MIDI" support will be a great addition.

Changed in ttymidi:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.