Has anyone figured out how to get GPS libraries to work with the latest OS 6.11? I tried using them with BufferedSerial class instead of Serial and gps.read(&c,1) instead of gps.getc() with no success. I was able to write a script to prove that the device was capable of reading the GPS data bit by bit using BufferedSerial so I know it is possible. I’m beginning to think that the simplest solution would be to use an older Mbed OS, but I am open to suggestion.
Hello,
please be so kind and share info about what GPS module and libraries did you use.
BR, Jan
Hi Jan,
I am using the Neo-6m TinyGPS++ with the libraries TinyGPSPlus and TinyGPSplus. I’m usng the correct baud rate and was able to get both libraries to work with an older OS.
Can you share a link? I will check it today later.
BR, Jan
https://os.mbed.com/users/Sir_Binky/code/TinyGPSplus/docs/tip/
https://os.mbed.com/users/aoba/code/TinyGPSPlus/docs/tip/
Thank you.
Ok that is only parser what is not depend on any Mbed API.
I imported this one TinyGPSPlus - A port of Mikal Hart’s TinyGPS++ version 1.0.2 to… | Mbed in to the MbedStudio(1.4.1) with MbedOS 6.11 bare metal
// based on original https://os.mbed.com/users/aoba/code/TinyGPSPlus-example/
#include "mbed.h"
DigitalOut led1(LED1);
#include "TinyGPSPlus.h"
TinyGPSPlus gps_parser;
static const int GPS_BAUD_RATE = 9600;
BufferedSerial gps(D1, D0);
char buf[128];
int main()
{
gps.set_baud(GPS_BAUD_RATE);
gps.set_format(8,BufferedSerial::None, 1);
printf("Start\n");
while(1){
char c;
if (uint32_t num = gps.read(&c, sizeof(char))) {
// Toggle the LED.
led1 = !led1;
switch (c) {
case '\n':
if (gps_parser.satellites.isValid() && gps_parser.satellites.value() > 3 && gps_parser.hdop.hdop() > 0) {
snprintf(buf, 128, "{\"lat\":%lf,\"lng\":%lf}", gps_parser.location.lat(), gps_parser.location.lng());
} else {
snprintf(buf, 128, "Satellites: %lu, time: %04d-%02d-%02dT%02d:%02d:%02d.%02d",
gps_parser.satellites.value(), gps_parser.date.year(), gps_parser.date.month(), gps_parser.date.day(),
gps_parser.time.hour(), gps_parser.time.minute(), gps_parser.time.second(), gps_parser.time.centisecond());
}
printf("%s\r\n", buf);
break;
default:
gps_parser.encode(c);
break;
}
}
}
}
It seems to be ok. Tested with my Nucleo-F303K8 and BN-280 GPS.
EDIT: important thing!!!
In mbed_app.json
(if you not have it, then just create it in your project folder)you need to set STD
because default is minimal-printf
and that will not let you print floats. Bare metal is optional.
{
"requires": ["bare-metal"],
"target_overrides": {
"*": {
"target.printf_lib": "std"
}
}
}
BR, Jan
Thank you!