I'm making a Serial to MIDI interface in Java, with the serial data coming from an Arduino and being processed through the RXTX library.
Unfortunately, using the suggested code from Arduino website link, I'm unable to retrieve the serial data.
The example code uses Serial.println
on the Arduino side and BufferedReader.readLine()
on the Java side. In my codeI'm not writing a line through Serial.println, but a MIDI message.
Arduino:
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{
status = MESSAGE + midichannel;
Serial.write(status);
Serial.write(PITCH);
Serial.write(VELOCITY);
}
I tried reading the serial data on a char buffer:
Java
char buf[] = new char[3];
reader.read(buf);
int channel = (int)buf[0] ;
int key = (int)buf[1] ;
int vel = (int)buf[2] ;
but I'm getting weird data...