Using gps usb with raspberry pi 3

Hello! I have a VK-162 G-Mouse RoHS IPX6 USB GPS receiver that I’m trying to use with my Raspberry Pi 3. I’m having some trouble getting it to work. These are the commands I found to set it up in Linux:

cd /dev/
sudo apt-get install gpsd gpsd-clients python-gps
sudo systemctl stop gpsd.socket
sudo systemctl disable gpsd.socket
vim /lib/systemd/system/gpsd.socket
sudo kilall gpsd
sudo gpsd /dev/ttyACM0 -F /var/run/gpsd.sock

However that’s failing in my Dockerfile, presumably because they don’t run on BalenaOS. How could I fix this?

Hey there!

Can you include the full logs of the build, so we can see at which step its failing, and how?

Hi! This is the output when it fails:

sudo: systemctl: command not found

What application container are you deploying? Looks like the container you are using doesn’t have systemd installed (maybe it uses another mechanism to manage services, which depends on the distro). You can either use another base image, or find the right way to start gpsd on the system that you currently have

I’m using balenalib/raspberrypi3-debian:stretch which I need in order for some other things to work. I’ll try to look for the right way to start it on Debian.

Right so I added

apt update && \
apt-get install systemd systemd-sysv && \

at the beginning of those commands and that got rid of the command not found error. However, now there’s this:

> Failed to connect to bus: No such file or directory

I don’t know much about how Debian handles systemd, but would it be that you installed systemd on it, but didn’t start the whole system in Debian?

I don’t know about that, but I tried to work around using systems and running this instead:

stty -F /dev/ttyACM0 ispeed 4800 && cat </dev/ttyACM0

I got:

> stty: /dev/ttyACM0: No such file or directory

Which is weird because the GPS is plugged in and I can see ttyACM0 when I run ls /dev/

So I tried just running cgps and got this output:

> cgps: no gpsd running or network error: -6, can't connect to host/port pair

Hello,

Please try the following to run gpsd without systemd:

FROM balenalib/raspberrypi3-debian:stretch

ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
ENV UDEV=true

RUN apt-get update && apt-get install gpsd gpsd-clients python-gps

CMD gpsd /dev/ttyACM0 -F /var/run/gpsd.sock

Hi Alexis! Thanks for your reply.

I added those lines to my Dockerfile. In the end when I try to run my application, I get the following output:

There seems to be something that keeps from establishing the connection with the GPS even though it is already connected. I’m using the gps3 Python library to try to get the GPS readings.

gpsd /dev/ttyACM0 -F /var/run/gpsd.sock didn’t output anything. However if I run cat /dev/ttyACM0 I do get the NMEA strings so I know the RPi is receiving data from the GPS.