Never thought this was going to be so hard.
1. So, I've got a USB<>RS232 converter connected to pins 7 & 8 on the Teensy (plus pwr and gnd); the converter uses the SiLabs CP2102 chip set. Tested the setup using the UART example code from PJRC website: UART_USB_Dual_Serial. Works as expected.
2. I've got a decent, integrated 1Hz GPS with a USB connector on it. If I plug it into my PC and open a com port, GPS data just comes over--once-per-second--onto the screen of my ascii terminal session.
...all seems good, so far.
3. Plug the USB connector from the GPS into the USB connector of the USB<>RS232 converter with a F/F USB adapter in the middle, and loaded the following code on the Teensy (basically adapted from Mikal Hart's example):
...but there is no output. I suspect is has something to do with no USB host--but then, I think all that stuff is just magic, anyway. Any ideas?
1. So, I've got a USB<>RS232 converter connected to pins 7 & 8 on the Teensy (plus pwr and gnd); the converter uses the SiLabs CP2102 chip set. Tested the setup using the UART example code from PJRC website: UART_USB_Dual_Serial. Works as expected.
Code:
// This line defines a "Uart" object to access the serial port
// usage notes: http://pjrc.com/teensy/td_uart.html
HardwareSerial Uart = HardwareSerial();
void setup() {
Serial.begin( 4800 );
Uart.begin( 115200 );
pinMode(PIN_D6, OUTPUT);
}
void loop() {
int incomingByte;
if (Serial.available() > 0) {
incomingByte = Serial.read();
Serial.print("USB received: ");
Serial.println(incomingByte, HEX);
Uart.print("USB received:");
Uart.println(incomingByte, HEX);
//Uart.write( incomingByte );
}
if (Uart.available() > 0) {
incomingByte = Uart.read();
Serial.print("UART received: ");
Serial.println(incomingByte, HEX);
Uart.print("UART received:");
Uart.println(incomingByte, HEX);
}
}
2. I've got a decent, integrated 1Hz GPS with a USB connector on it. If I plug it into my PC and open a com port, GPS data just comes over--once-per-second--onto the screen of my ascii terminal session.
...all seems good, so far.
3. Plug the USB connector from the GPS into the USB connector of the USB<>RS232 converter with a F/F USB adapter in the middle, and loaded the following code on the Teensy (basically adapted from Mikal Hart's example):
Code:
// Documentation: https://www.pjrc.com/teensy/td_libs_TinyGPS.html
/* On Teensy, the UART (real serial port) is always best to use. */
/* Unlike Arduino, there's no need to use NewSoftSerial because */
/* the "Serial" object uses the USB port, leaving the UART free. */
HardwareSerial Uart = HardwareSerial();
void setup() {
Serial.begin(115200);
Uart.begin(4800);
delay(1000);
Serial.print("Testing TinyGPS library v. ");
Serial.println("by Mikal Hart");
Serial.println();
}
void loop() {
unsigned long start = millis();
// Every 5 seconds we print an update
while (millis() - start < 5000) {
if (Uart.available()) {
char c = Uart.read();
Serial.print(c); // uncomment to see raw GPS data
}
}
}
...but there is no output. I suspect is has something to do with no USB host--but then, I think all that stuff is just magic, anyway. Any ideas?