Closed henripalmroth closed 4 months ago
That is strange, it kindof looks like it does not get coverage but that does not make sense if it comes back with addon restart.
Could you try to connect your dongle with a USB extension cord? Just to see if it could be interference from the Pi causing the issue? Something like this:
If you know how, you could also connect to the container and run a dmesg after it stops updating just to see if there are any hardware failure messages in the log.
Hi and thanks for a reply. I currently have 20 cm long extension cable and this gps dongle is having small led which is blinking when it is having a fix to satellites. Of course there can be some problems sometimes. Is it so that gpsd cannot recover from those?
Here is my log from dmesg. I didn't notice anything suspicious. Do you have any thoughts how could I narrow this problem down?
Nah this looks ok, but we are most interested in dmesg events just when it fails. Seems you reseated the USB stick at this time? Did you see anything further up in the dmesg log?
Another thing to try, when it is working, run a gpsmon from the shell, it should look something like this:
This image is when it is working. The NMEA logs at the bottom is the GPS NMEA data it receives from the GPS dongle. It would be interesting to see how this looks both when it works, and when it is failed.
Again this needs to be run from the addons docker containter interactively like before.
Its getting warmer. Gpsmon looks fine when everything is working but after while it looks like this. I can replicate this quite quickly after I put update frequency to 1 sec.
Thank you. Looks like it lost the device here. I find it strange that you can provoke this error with changing the update frequency, since that only affects the rate at which the addon updates MQTT, not how often GPSD updates internally.
Have you tried to manually set the port speed? From the manual it seems to want it to be set to 4800. Could you try that if you have not?
Probably that 1 sec setting was my own misinterpretation. And yes, I'm using that 4800 baud setting. Otherwise it won't work.
But since this gpsmon is connecting directly to gpsd it probably got nothing to do with your implementation. However still all help is welcome. Do you have any thoughts how I could debug more of gpsd? Dmesg didn't reveal anything suspicious.
Had to have a think about this. Dmesg does not output a HW error at any time?
Could it be the cable? Would it be possible to swap the USB cable for another one? Or just temporarily connect the dongle directly to the Pi?
Another thing to try is to try to get serial data directly from the serial device. First stop the addon. Then open a terminal and run the following commands:
/bin/stty -F /dev/ttyUSB0 raw 4800 cs8 clocal -cstopb
cat -v /dev/ttyUSB0
Replace device with your device if it is wrong. See if the same error occurs outside the addon. This would just type the serial NMEA sentences directly to terminal. You could also try to pipe them to a file. Though if it is a hardware error it should happen with or without the cat command, its just easier to see.
How long in general does it take before the device "stops working".
Looks like in terminal it runs "forever". Strange. Not sure how to narrow down what happens inside docker container.
I try to also find out how I could use serial integration to get e.g. boat speed and track. That way I can see if it really works for longer period.
I'm starting to believe it is not hardware issue.
According to this article: https://www.jfcarter.net/~jimc/documents/gps-clock-1507.html it seems the device should disable the parity bit. Maybe it is a shot in the dark, but it could be something. I would need to make some changes to let you disable it though.
Could you try a new beta version I set up? You have to add a new repository with this URL: https://github.com/corvy/ha-beta-addons. Install version 2024.7.0_b4 (or newer).
The settings should look like this:
Please output the logs from the startup just to see if it sets the correct settings. Should be something similar to this.
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Setting up serial device with the following: /dev/ttyAMA0 4800 cs8 -cstopb -parenb clocal
Starting GPSD with device "/dev/ttyAMA0"...
/usr/sbin/gpsd: 3.25 (revision 3.25)
Starting MQTT Publisher with integrated credentials ...
2024-07-23 11:08:42,902 - MQTT Publisher - INFO - Connecting to MQTT broker
2024-07-23 11:08:43,906 - MQTT Publisher - INFO - Verifying MQTT Connection ....
2024-07-23 11:08:44,110 - MQTT Publisher - INFO - Connected to MQTT broker
2024-07-23 11:08:44,110 - MQTT Publisher - INFO - Subscribe to MQTT topic homeassistant/status to listen for HA reboots.
2024-07-23 11:08:44,906 - MQTT Publisher - INFO - Verifying MQTT Connection ....
2024-07-23 11:08:44,908 - MQTT Publisher - INFO - Published MQTT discovery message to topic: homeassistant/device_tracker/gpsd2mqtt/a411f609/config
2024-07-23 11:08:44,908 - MQTT Publisher - INFO - Starting location detection and sending GPS updates.
2024-07-23 11:10:43,638 - MQTT Publisher - INFO - Published 11 updates to the device_tracker in last 2.0 minutes. Achieved 3D fix, position with 10 of required 0 GPS satellites.
Up and running and looks good so far:
Actually stopped again. Is there any chance of increasing the debug logging to see what happens there?
I have added config option to add more debugging to GPSD in version _b5.
Add -N to get the logs (foreground) and then try -D1 -D2 or -D3 for more logging information.
Does this tell anything to you? Seems that it is not providing anything to MQTT with -N switch.
I disabled the use of sock in the _b7 version. Could you try that?
To get it to update it might have to run as a daemon, so just remove the -N and -D3 to get it to start updating again.
Sorry to say, but it didn't make any difference. I need to dig deeper to gpsd.
Can you give me more logs from the debugging? Still the same permissions error for the tty device?
Yes. This is with -N and -D2 switches:
I am not sure what causes this. In the last version I tried to disable apparmour, just to see if that will fix the issue. Could you. test?
I have also made a newer version with a modified apparmour, please let me know when you have tested this one and then I will upload the newer version after.
Still getting this with recent version (switches -N and -D2):
ok, so another version then 👍 try _b9
A bit different outcome
Cool, at least something is changing. Setgroups I do not know how to change. But in _b10 at least the setgid and setuid should be fixed.
Could you test? Have you tested to run without the -D and -N settings to see if it will work?
I tested now without fixes and I think we have a success. 🥳
Have been providing value every sec for five minutes now (boat is stationary). Than you very much for your efforts.
Cool! Is this the _b10 version?
Merged the changes into version 2024.7.0. Please see if that works for you now. If yes we will close this isse. :)
I can confirm that it works.
Noticed that 0 on update rate doesn't work but it defaults to 10 seconds. However that is another story.
Thanks and greetings from Sandhamn, Sweden!
Thanks for confirming! I will for sure check the 0 setting. Happy boating!
Hi,
I'm having this usb dongle: https://www.globalsat.com.tw/en/product-199954/GPS-Receiver-ND-105C.html
This works fine for some time but then it stops. Any idea how to debug this further? I'm having HA on Raspberry PI 5 on a boat.
Log with debug setting on looks like this and then it just goes on with pings. Restart resolves the issue. On dongle the led is blinking as expected when there is fix available.