So your music controller wants RS232 levels?
Put your USB to serial adapter on a PC with RealTerm and see if the output from Teensy is correct.
Here's how I start a serial port, in setup()
Code:
Serial1.begin(9600); // start Serial1
while((!Serial1) && (millis()<10000)); // wait until serial1 port is open or timeout
Serial.print("Serial1 ready at "); // send debug message out usb serial port
Serial.println(millis());
I don't have any of the specs for your music controller, but in loop if you have something like
Code:
char inChar1;
char inputString1[32];
uint8_t index1 = 0;
// I have not tried to compile or run this since I don't have the music hardware
// This waits for '>', asks to play 001, wait 5 sec, repeat forever
// repeats response from music player
void loop(void)
{
while (Serial1.available())
{
inChar1 = Serial1.read();
if ('>' == inChar1) // prompt char
{
inputString1[index1++] = inChar1; // save in a string for later use, maybe no need for this
Serial.println("got >");
}
else if (0x0D == inChar1) // CR
{
Serial.println("got carriage return 0x0D")
// discard it
}
else if (0x0A == inChar1) // LF
{
Serial.println("got line feed (newline) 0x0A")
// discard it
inputString1[index1] = 0x0; // null terminate string after ending CR-LF removed
}
else
{
// got some other chars than ><cr><lf> from music
if (inChar1 > 0x1F) // is it printable? if so add it to string
{
[index1++] = inChar1;
}
else
{
// non printable, show hex value, don't add to string
Serial.print("got 0x");
Serial.println(inChar1, HEX); // print hex value, works even if unprintable char
}
}
}
// print the string to debug usb
Serial.println(inputString1);
Serial.println("asking to play 001");
Serial1.println("play(001)");
delay(5000); // 5 seconds to start playing and respond to serial
} // end loop
I like to output LOTs of debug info so if something unexpected happens I have a clue about it