Open ABHITHLALC opened 4 months ago
I believe I found the root cause. In your quote (and I'm seeing the same problem on my own hardware as well) you logged the following NMEA message:
$GNRMC,052331.000,A,1057.27606,N,07619.38087,E,0.00,190.74,140224,,,A,V*0D
This message has 14 data fields in total. According to all NMEA specs I've checked in the process it should only have 13 fields, and that's what packet_forwarder expects. If the number of fields doesn't match, the basic GPS time sync fails, and if this is not done, no position is accepted either.
The patch (as in: "make it work and don't care") is easy: Just make packet_forwarder accept the message with 14 fields, the last one (which is the superfluous one) doesn't hurt. This preliminary fix is running fine on my system without the earlier problem.
However, a true solution (as in: "why is this field number 14 there in the first place?") I can not provide. The trailing ",V" in your message just shouldn't be there as much as I understand.
Did you solve this? I am running into the same problem.
In the meantime I did some more research and found that the NMEA spec is not as absolute as I assumed it to be. Apparently, there are a number of manufacturers who transmit messages not strictly conforming to the spec, so the parsing needs to accomodate for this (see discussion from the developers of gpsd, they are recommending the gpsd unified communication syntax over NMEA for exactly this reason.)
Therefore the case at hand doesn't appear to be that out of the ordinary, but rather "NMEA business as usual". And since the required payload of the GNRMC message is not affected by the unexpected addition, it may as well just be ignored.
So yes, I believe you can actually call it a "solution" instead of just a "patch".
Got it, thank you. Could you share this code?
Thak you for the response , I will check it out let you know the result.
It's trivial, really:
In libloragw/src/loragw_gps.c, you'll find:
832 if (nb_fields != 13) {
Change that to something like:
832 if ( (nb_fields != 13) && (nb_fields != 14) ) {
This change will accept NMEA G?RMC messages with 13 or 14 fields, not only those with 13 as before. The L76K receiver apparently defaults to sending 14-field-messages.
Thank you for you response. After adding to adapt nb_field 14, now it woking.
Excellent, thanks for the feedback!
PS: Does anyone know how to get the change into the repository? Is there even a maintainer still active? I can see pull requests still pending from 2022, not sure if it's worth creating another one.
I made these changes but still having some issues.
The code was on line 532 thought, not 832?
Its picking out the GPS coords now, but the timing is still off.
# SX1302 counter (INST): 90725791
# SX1302 counter (PPS): 90671076
# BEACON queued: 0
# BEACON sent so far: 0
# BEACON rejected: 0
### [JIT] ###
src/jitqueue.c:431:jit_print_queue(): INFO: [jit] queue is empty
#--------
src/jitqueue.c:431:jit_print_queue(): INFO: [jit] queue is empty
### [GPS] ###
# Valid time reference (age: 1 sec)
# GPS coordinates: latitude 42.34331, longitude -83.07263, altitude 198 m
ERROR: invalid I2C file descriptor
### Concentrator temperature unknown ###
##### END #####
JSON up: {"stat":{"time":"2024-03-24 21:48:33 GMT","lati":42.34331,"long":-83.07263,"alti":198,"rxnb":0,"rxok":0,"rxfw":0,"ackr":0.0,"dwnb":0,"txnb":0,"temp":0.0}}
WARNING: [gps] GPS out of sync, keeping previous time reference
WARNING: [gps] GPS out of sync, keeping previous time reference
Excellent, thanks for the feedback!
PS: Does anyone know how to get the change into the repository? Is there even a maintainer still active? I can see pull requests still pending from 2022, not sure if it's worth creating another one.
I tried a few years ago to get this exact change in. This repo ONLY supports UBLOX gpses, and the Waveshare decided to use a non UBLOX gps.
See https://github.com/Lora-net/sx1302_hal/issues/90#issuecomment-1329169154
Ah man, I was waiting whole night to get it to catch a lock, then checking with gpsd in the morning, packet forwarder just don't understand the GPS... and gpsd had perfect lock with GPS data.... I'm going to try the fix with 14-field-messages. Or maybe give the chirpstack gateway os a try, since it looks like the maintainer abandoned this repo :(
Hello @VladoPortos , this repo is not abandoned, but the support of various GPS receiver is out of the scope of this project. ;) We give an example for Ublox receiver, but fill free to adapt according to your specific hardware.
The main focus of this repo is the libloragw part, which is the driver of the SX1302 chip.
Though, in the next release I'll add a fix for the issue described here.
Hi @mcoracin, ah ok... I'm sorry. I'm just frustrated a bit, since documentation for Lora - anything, is not done well for people who try to learn it. For some reason I kind of expected since this repo is linked from https://www.waveshare.com/wiki/SX1302_LoRaWAN_Gateway_HAT that it should work. However seems like none of the Lora packet forwarders support anything but Ublox,. So why the hell waveshare sticked L76K on to their HAT? This one is working fine for linux with gpsd, but none of the packet forwarders I tried supports it. The packet forwarding works fine, I got that part working, just not sure why to include GPS on the board and not support it, thus I assume this repo is not really related to waveshare at all, right ?
You're right, this repo is not related to Waveshare at all. This repo aims to provide an official driver for Semtech SX1302/SX1303 chips for LoRa Gateways (libloragw). It also provides a simple implementation of a Packet Forwarder (as we always did in Semtech) to easily connect to LoRaWAN Network Servers which support our UDP protocol. But by no mean it aims to support any flavors of Raspberry Pi HATs which exist with a sx1302/1303.
By the way, the GPS is only needed if you want to do LoRaWAN Class-B, or if you are using a sx1303 for fine timestamping. For regular LoRaWAN Class-A, there is no need for a GPS.
I was having the same issue with packet_forwarder and "no valid GPS coordinates available yet".
Changing of the nb_fields variable in loragw_gps.c to support 14 fields gps responses was successful.
But receiving warnings like below:
WARNING: [gps] GPS out of sync, keeping previous time reference
, even if GPS data get picked correctly by TTN v3.
Hello all, just for information, the necessary change to support various possible number of fields in the RMC sentence will be done in next release, which should happen during the summer.
Thanks, appreciate that!
It's trivial, really:
In libloragw/src/loragw_gps.c, you'll find:
832 if (nb_fields != 13) {
Change that to something like:
832 if ( (nb_fields != 13) && (nb_fields != 14) ) {
This change will accept NMEA G?RMC messages with 13 or 14 fields, not only those with 13 as before. The L76K receiver apparently defaults to sending 14-field-messages.
Thank you, this also worked for me.
Greeting, I am encountering difficulties with GPS synchronization in the Lora gateway. My hardware setup is: Raspberry Pi 3B+ and SX1302 LoRaWAN Gateway HAT by waveshare. I've successfully connected to TTN and can forward Lora packets to the network server without any issues. However, I'm having trouble getting GPS coordinates from the Lora gateway. It keeps showing a synchronization warning. Did I miss any additional required configurations to retrieve GPS data?
I have used
sudo cat /dev/ttyS0
command for checking GPS port and getting this valueThe part of the config file is:
And these are the terminal logs after running the packet forwarder
Any guidance or suggestions would be greatly appreciated. Thanks in advance.