Hi, I'm having trouble getting this ported to maple. Has anyone done this before me and can help me out?
Thanks!
tinygps port
(16 posts) (8 voices)-
Posted 4 years ago #
-
supermac,
Not sure what needs to be ported. What seems to be the trouble?
I looked over the TinyGPS source code and it doesn't seem to use any AVR- or Arduino-specific features, and the following basic sanity check at least compiles (though I didn't read enough about the library to do more) in MapleIDE:
#include <TinyGPS.h> TinyGPS gps; void setup() { gps.encode('a'); } void loop() { }
Edit: I'm using TinyGPS10, available here: http://arduiniana.org/libraries/tinygps/
Posted 4 years ago # -
Thanks for the help! I'm getting errors trying to make it compile. I'm using their examples that use the newsoftserial library and have tried to port it to use the hardware maple ports. I'm a newbie so it is probably something simple.
the error I get is:
Going to build using 'armcompiler' (ARM)
Compiling core...
Compiling libraries: tinygpsmaple
Compiling the sketch...In function 'void setup()':
error: statement cannot resolve address of overloaded functionMy code:
//#include <NewSoftSerial.h>
#include <TinyGPS.h>/* This sample code demonstrates the normal use of a TinyGPS object.
It requires the use of NewSoftSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 2(rx) and 3(tx).
*/TinyGPS gps;
//NewSoftSerial nss(2, 3);void gpsdump(TinyGPS &gps);
bool feedgps();
void printFloat(double f, int digits = 2);void setup()
{
SerialUSB.begin; //(115200);
Serial2.begin(19200);
SerialUSB.print("Testing TinyGPS library v. "); SerialUSB.println(TinyGPS::library_version());
SerialUSB.println("by Mikal Hart");
SerialUSB.println();
SerialUSB.print("Sizeof(gpsobject) = "); SerialUSB.println(sizeof(TinyGPS));
SerialUSB.println();
}
...... and so on.Posted 4 years ago # -
From briefly looking at the TinyGPS library, it doesn't do any of the communication; it just handles the NMEA data encoding/decoding used by GPS units, so like mbolivar said: no "porting" should be required.
SerialUSB.begin; //(115200);
is invalid as begin is a method. You need to call it at least by:
SerialUSB.begin();
however, SerialUSB is already on by default and the only time you need to call
begin
is after callingend
.You also need to figure out which serial port the GPS unit will be connected to. The TinyGPS example link posted by mbolivar uses the NewSoftSerial library simply because the Arduino has only one serial port that's used for debugging -- generally speaking. Because the Maple has multiple serial ports, using NSS is pointless and decreases your overall performance.
If you're using Serial2 then connect the GPS unit to digital 0 and 1. D0 and D1 are RX and TX respectively so connect the GPS unit's TX to D0 and RX to D1. Beyond that, your communications will now use Serial2 instead of a nss.
Make sure the TinyGPS library is in the correct location and you shouldn't have any issue compiling and running.
-robodude666
Posted 4 years ago # -
robodude:
you stated: "Make sure the TinyGPS library is in the correct location and you shouldn't have any issue compiling and running."
Where should the library be located?
I'm getting the error:
<BUILD>\test_with_maple_gps_device_b.cpp:2: fatal error: TinyGPS.h: No such file or directory
compilation terminated.Posted 4 years ago # -
I got TinyGPS running on the Discovery with libmaple, so I know it can be done...
When I switched to 0.11, I started using the IDE instead of the command line.
On my machine the TinyGPS folder would be placed in: C:/Maple011/libraries
I also had to add the line:
LIBMAPLE_MODULES += $(SRCROOT)/libraries/TinyGPS10to the makefile, in my old 0.0.9 command line environment, but I can't find where or if that line needs to be added in the IDE environment.
Posted 4 years ago # -
All that's necessary is to make a folder called "libraries" in your sketchbook folder, and drop the TinyGPS folder in there. After that, restart MapleIDE; TinyGPS should appear in the libraries drop-down menu.
Posted 4 years ago # -
I've been fiddling with this for about a week now, and I can't seem to get anything from the GPRMC string except zeros for the lat/lon. I'm just dumping the data from the gps to the console. It updates once a second as the gps outputs. Can't seem to figure it out. I can take the same code, put it in the arduino, and I get full GPRMC output within 25 seconds of powering it back up. I do change the serial ports accordingly on each board, but nothing else. Any thoughts?
#include <nmea.h>
#include <SoftwareSerial.h>
NMEA gps(ALL); // GPS data connection to all sentence types
SoftwareSerial SerialG(4, 5);
void setup() {
Serial.begin(19200);
SerialG.begin(9600);
}void loop() {
if (SerialG.available() > 0 ) {
// read incoming character from GPS and feed it to NMEA type object
if (gps.decode(SerialG.read())) {
// full sentence received
Serial.print ("Sentence = ");
Serial.println (gps.sentence());
Serial.print ("Datatype = ");
Serial.println (gps.term(0));
Serial.print ("Number of terms = ");
Serial.println (gps.terms());
Serial.print ("Status = ");
Serial.println (gps.gprmc_status());
}
}
}Posted 3 years ago # -
Have you tried simplifying the program?
e.g.
void loop() { unsigned int ch = SerialG.read(); // I am assuming this is the GPS SerialUSB.print("ch="); SerialUSB.println(ch, HEX); }
To see that something is coming in from the GPS.
(WARNING: I have not compiled or tested that code.)
Posted 3 years ago # -
Yes, I am getting data from the gps. The problem comes in when I use the library to process the data from the gps. I don't get anything from gpgmrc, it's zeros. The library depends on this string being valid to continue processing data. I've used various forms of it and they all do the same thing. I'm wondering if there is something in the maple libraries that is handling this badly.
Posted 3 years ago # -
I've even tried this code I've found. It still won't get anything from GPRMC. Any ideas? I would start suspecting my gps, but it works fine on the arduino with the same code.
#include <string.h> int byteGPS=-1; char linea[300] = ""; char comandoGPR[7] = "$GPRMC"; int cont=0; int bien=0; int conta=0; int indices[13]; void setup() { Serial2.begin(9600); for (int i=0;i<300;i++){ // Initialize a buffer for received data linea[i]=' '; } } void loop() { if (Serial2.available() > 0) { byteGPS=Serial2.read(); // Read a byte of the serial port if (byteGPS == -1) { // See if the port is empty yet delay(100); } else { linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer conta++; SerialUSB.print(byteGPS, BYTE); if (byteGPS==13){ // If the received byte is = to 13, end of transmission //digitalWrite(ledPin, LOW); cont=0; bien=0; for (int i=1;i<7;i++){ // Verifies if the received command starts with $GPR if (linea[i]==comandoGPR[i-1]){ bien++; } } if(bien==6){ // If yes, continue and process the data for (int i=0;i<300;i++){ if (linea[i]==','){ // check for the position of the "," separator indices[cont]=i; cont++; } if (linea[i]=='*'){ // ... and the "*" indices[12]=i; cont++; } } SerialUSB.println(""); // ... and write to the serial port SerialUSB.println(""); SerialUSB.println("---------------"); for (int i=0;i<12;i++){ switch(i){ case 0 :SerialUSB.print("Time in UTC (HhMmSs): ");break; case 1 :SerialUSB.print("Status (A=OK,V=KO): ");break; case 2 :SerialUSB.print("Latitude: ");break; case 3 :SerialUSB.print("Direction (N/S): ");break; case 4 :SerialUSB.print("Longitude: ");break; case 5 :SerialUSB.print("Direction (E/W): ");break; case 6 :SerialUSB.print("Velocity in knots: ");break; case 7 :SerialUSB.print("Heading in degrees: ");break; case 8 :SerialUSB.print("Date UTC (DdMmAa): ");break; case 9 :SerialUSB.print("Magnetic degrees: ");break; case 10 :SerialUSB.print("(E/W): ");break; case 11 :SerialUSB.print("Mode: ");break; case 12 :SerialUSB.print("Checksum: ");break; } for (int j=indices[i];j<(indices[i+1]-1);j++){ SerialUSB.print(linea[j+1]); } SerialUSB.println(""); } SerialUSB.println("---------------"); } conta=0; // Reset the buffer for (int i=0;i<300;i++){ // linea[i]=' '; } } } } }
Posted 3 years ago # -
What do you mean by "It still won't get anything from GPRMC"?
Is it all zero's still?What is your conclusion from that program?
I am a little bit worried about:
if (Serial2.available() > 0) { byteGPS=Serial2.read(); // Read a byte of the serial port if (byteGPS == -1) { // See if the port is empty yet delay(100); } else {
If
serial2.available() > 0
then there is a byte, or there is a bug in that part of the Maple library. Let's assume the library is working.
delay(100)
is the time it takes for 100 characters (at 9600 baud) to arrive, so characters could be lost.
FurtherSerial2.read()
will block until a character arrives, so there is no need to delay, or check available.If a 'line' of data is terminated by character 13, maybe try something simpler:
int i; for (i=0; i<sizeof(linea)-1 && (byteGPS=Serial2.read()) != 13; ++i) { linea[i] = byteGPS; } linea[i+1] = 0; // terminate the string in case the decode function is picky
will read characters upto, but not including the 13. Should that 13 be in the string?
Then the program can manipulate the string.
for (int i=1;i<7;i++){ // Verifies if the received command starts with $GPR if (linea[i]==comandoGPR[i-1]){ bien++; }
Is the comment accurate? The code compares the *second* received character onwards with the string? What happens to the first one, is it ignored? Might that upset the gps class?
The function strncmp() compares n characters of two strings, so
if (strncmp(&linea[1], comandoGPR, strlen(comandoGPR)) == 0)
will do exactly the same comparison as the for loop above..If I've understood, the GPS is returning data. Yes?
All the problems are within gps.decode. Yes?Does the data read in on the Maple look similar to the data on the Arduino?
How about just initializing a few char arrays with the characters that come out of the Arduino? e.g.
unsigned char a[] = { 0xab, 0xcd, 0xef, ..., 0 };
plug that into the simplest possible Maple program, and call the decode functions?I assume something is happening inside the code of the gps class. A possible causes is a difference between an Arduino function, and a Maple function of the same name, maybe the difference in data size, an Arduino int is not the same size as a Maple int
The next approach is to take pieces of the gps decode class, and test them with fixed strings, that you know work, and put print statements into the source, to identify where the problem is introduced.
NB: I have not compiled or tested any of the code.
This horrific forum software swallows the NUL character, so I have used 0 instead.(full disclosure: I am not a member of LeafLabs staff.)
Posted 3 years ago # -
I didn't think about running static outputs into it to see if it processes it correctly. I'll give it a run and reply back. I appreciate the response, I'm still new to this stuff and everyone has been very helpful and forgiving. I'll get back with what I find.
Posted 3 years ago # -
shadethegrey - I'm impressed by your tenacity. I hope we can help you.
Posted 3 years ago # -
Wow. Long break. Catching up on C++. I switched out of the IDE and onto the command-line toolchain. TinyGPS is now working and it is now outputting lat/lon data to the USB serial port.
ridgebackred: Your info was very helpful getting TinyGPS working, I did have to edit TinuGPS.cpp and include stdlib to get it to function without an error. Thank you for your valuable input, thanks everyone for helping me get this working at all. I have not been able to get it to work in the IDE, so that's why I abandoned it. Not as hard as it seemed to switch.Posted 3 years ago #
Reply »
You must log in to post.