Why there is no gpsfake in OpenWrt?

Hello,
I am writing as I need a way to simulate the presence of a GNSS device on some boards running OpenWrt 21.02.1, starting from some NMEA traces. When working on Ubuntu, I typically use gpsfake, as a convenient way of faking the presence of an actual GNSS device connected via USB.

However, I noticed that gpsfake is not available in OpenWrt, even if I select all the needed packages (gpsd, gpsd-clients, python).
I currently have Python 3.9 installed on the OpenWrt image I built for my target devices.
I also installed the gps Python package with pip3 install gps.

Do you know why there is no gpsfake? Do you know any valid alternative?

I tried importing it (as, in the end, it is a Python script) from an Ubuntu 20.04 LTS installation, but I am getting an error when I try to launch it on OpenWrt:

gpsfake: can't load Python gps libraries -- check PYTHONPATH.
cannot import name 'packet' from 'gps' (/usr/lib/python3.9/site-packages/gps/__init__.py)

Could this be due to the fact that OpenWrt installs by default, through pip3, gps 3.19, instead of gps 3.20, as in Ubuntu 20.04 LTS?

Thank you very much in advance!

you probably should copy gpsfake sources code from some other machine, as openwrt python not likely have a module unless a package installed it

2 Likes

I already tried importing the whole gps package source from both an Ubuntu 18 LTS machine and from an Ubuntu 20 LTS one. However, this does not seem to work.
In particular, I am getting the following errors:
-- When importing the gps package from Ubuntu 18 LTS (\usr\lib\python3\dist-packages\gps), then copying the Ubuntu 18 gpsfake script into the same folder, and launching it:

gpsfake: can't load Python gps libraries -- check PYTHONPATH.
cannot import name 'packet'

Probably due to the fact that Ubuntu 18 LTS gpsfake is still based on Python 2 and not Python 3.

-- When importing the gps package from Ubuntu 20 LTS (\usr\lib\python3\dist-packages\gps), then copying the Ubuntu 20 gpsfake script into the same folder, and launching it:

gpsfake: can't load Python gps libraries -- check PYTHONPATH.
attempted relative import with no known parent package

Unfortuntaly, even if I copy the whole "gps" package from Ubuntu and I replace all the content inside "/usr/lib/python3.9/site-packages/gps", I still get:

gpsfake: can't load Python gps libraries -- check PYTHONPATH.
cannot import name 'packet' from 'gps' (/usr/lib/python3.9/site-packages/gps/__init__.py)

install pip and bring whole thing from there? (not sure if router have enough space for that though)

I actually tried downloading all the needed packages with pip3 (in my case, I have quite a lot of free space inside the target devices), directly from OpenWrt, but all my attempts were unsuccesful, unfortunately. In particular, I noticed that the gps package may need netifaces to be installed, too.
However, I was unable to install it with pip3 install netifaces, as I was always getting several "exit status 1" errors, resulting, at last, in the following critical error:

ERROR: Could not find a version that satisfies the requirement netifaces (from versions: 0.8, 0.10.0, 0.10.1, 0.10.2, 0.10.3, 0.10.4, 0.10.5, 0.10.6, 0.10.7, 0.10.8, 0.10.9, 0.11.0)
ERROR: No matching distribution found for netifaces

As a workaround, I ended up creating a Docker container, based on Ubuntu 20.04 LTS, running gpsfake and connecting directly to the host network (docker run -dit --net=host --name=gpsfake_container gpsfake_images). Thanks to the Docker integration inside OpenWrt 21.02.1, I was finally able to launch gpsfake directly on the target devices, even if this may definitely not be the best and/or fastest solution.