kingforger
Active member
I got this breakout to work with the Teensy3.0 via hardware serial: http://www.adafruit.com/products/746
I'm not sure what forum to post it under, so it's here. I'm just excited that it works and wanted to share!
First of all, I started out with the "parsing" example code that comes with that GPS. I commented out anything having to do with the interrupt because some things using the interrupt just weren't worknig. If you want to use that, I'm sorry but I have nothing for you. You don't need it though. Next, I removed any references to newsoftwareserial or softwareserial or anything that uses those files from both Adafruit_GPS.h and Adafruit_GPS.cpp and, of course, parsing.ino (the example file). This means that I was only using hardware serial. The Teensy 3.0 has 3 hardware serial ports, so who needs the softwareserial anyway?
I modified a particular line in the parsing example program to get rid of that UDR0 thing that wasn't working. The new line by itself is "if (c) Serial.print(c);". To show you some context, I have some code that surrounds it below:
char c = GPS.read();
// if you want to debug, this is a good time to do it!
if (GPSECHO)
if (c) Serial.print(c);
// writing direct to UDR0 is much much faster than Serial.print
// but only one character can be written at a time.
I also had to define the function itoa() with code that I found at www.jb.man.ac.uk/~slowe/cpp/itoa.html. Specifically, I used the char* version 0.4 code found at the bottom of that page, which is as follows:
/**
* C++ version 0.4 char* style "itoa":
* Written by Lukás Chmela
* Released under GPLv3.
*/
char* itoa(int value, char* result, int base) {
// check that the base if valid
if (base < 2 || base > 36) { *result = '\0'; return result; }
char* ptr = result, *ptr1 = result, tmp_char;
int tmp_value;
do {
tmp_value = value;
value /= base;
*ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz" [35 + (tmp_value - value * base)];
} while ( value );
// Apply negative sign
if (tmp_value < 0) *ptr++ = '-';
*ptr-- = '\0';
while(ptr1 < ptr) {
tmp_char = *ptr;
*ptr--= *ptr1;
*ptr1++ = tmp_char;
}
return result;
}
I just stuck that code right at the top of WString.cpp (which is found in arduino-1.0.1/hardware/teensy/cores/teensy3).
After that, it worked! My location is perfectly accurate, and everything else seems to be too. There was a lot of stuff I played around with and discovered before this stuff that I just told you about, but ultimately none of it is relevant if you just want to get the GPS working. So I think that's everything that I needed to do to make this particular GPS work.
If you have any questions, let me know. I'm just an analog/antenna/power electronics engineer, not really a software guy. So my knowledge of this software is limited. I can really just edit it, but could never write this stuff on my own from scratch.
edit: OH! I also had to edit two calls to isdigit and isalpha. I forget which file they were in. But I got an error saying that isAlpha and isDigit were not called in scope. There was a problem with case. I changed isDigit and isAlpha to isdigit and isalpha, and then there was no problem. I included #include <ctype.h> too in the parsing example main file. I'm not sure if you need this or not.
I'm not sure what forum to post it under, so it's here. I'm just excited that it works and wanted to share!
First of all, I started out with the "parsing" example code that comes with that GPS. I commented out anything having to do with the interrupt because some things using the interrupt just weren't worknig. If you want to use that, I'm sorry but I have nothing for you. You don't need it though. Next, I removed any references to newsoftwareserial or softwareserial or anything that uses those files from both Adafruit_GPS.h and Adafruit_GPS.cpp and, of course, parsing.ino (the example file). This means that I was only using hardware serial. The Teensy 3.0 has 3 hardware serial ports, so who needs the softwareserial anyway?
I modified a particular line in the parsing example program to get rid of that UDR0 thing that wasn't working. The new line by itself is "if (c) Serial.print(c);". To show you some context, I have some code that surrounds it below:
char c = GPS.read();
// if you want to debug, this is a good time to do it!
if (GPSECHO)
if (c) Serial.print(c);
// writing direct to UDR0 is much much faster than Serial.print
// but only one character can be written at a time.
I also had to define the function itoa() with code that I found at www.jb.man.ac.uk/~slowe/cpp/itoa.html. Specifically, I used the char* version 0.4 code found at the bottom of that page, which is as follows:
/**
* C++ version 0.4 char* style "itoa":
* Written by Lukás Chmela
* Released under GPLv3.
*/
char* itoa(int value, char* result, int base) {
// check that the base if valid
if (base < 2 || base > 36) { *result = '\0'; return result; }
char* ptr = result, *ptr1 = result, tmp_char;
int tmp_value;
do {
tmp_value = value;
value /= base;
*ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz" [35 + (tmp_value - value * base)];
} while ( value );
// Apply negative sign
if (tmp_value < 0) *ptr++ = '-';
*ptr-- = '\0';
while(ptr1 < ptr) {
tmp_char = *ptr;
*ptr--= *ptr1;
*ptr1++ = tmp_char;
}
return result;
}
I just stuck that code right at the top of WString.cpp (which is found in arduino-1.0.1/hardware/teensy/cores/teensy3).
After that, it worked! My location is perfectly accurate, and everything else seems to be too. There was a lot of stuff I played around with and discovered before this stuff that I just told you about, but ultimately none of it is relevant if you just want to get the GPS working. So I think that's everything that I needed to do to make this particular GPS work.
If you have any questions, let me know. I'm just an analog/antenna/power electronics engineer, not really a software guy. So my knowledge of this software is limited. I can really just edit it, but could never write this stuff on my own from scratch.
edit: OH! I also had to edit two calls to isdigit and isalpha. I forget which file they were in. But I got an error saying that isAlpha and isDigit were not called in scope. There was a problem with case. I changed isDigit and isAlpha to isdigit and isalpha, and then there was no problem. I included #include <ctype.h> too in the parsing example main file. I'm not sure if you need this or not.
Last edited: