third byte in MIDI message (sometimes) not correct

Bug #879090 reported by Milan M. on 2011-10-20
This bug affects 1 person
Affects Status Importance Assigned to Milestone
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

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)
Milan M. (accxunt) wrote :

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.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers