Purposing onboard serial console for GPS module using gpsd

Mods please move this thread if it's better suited elsewhere.

I’m working on a project using a GL-iNET GL-MiFi and Arduino GPS module (XC3712 with NEO6M2 receiver) in order to have GPS data be available for devices behind my MiFi. The MiFi looks to be using a stripped back version of OpenWRT:
OpenWrt 18.06.1, r7258-5eb055306f using BusyBox v1.28.3 () built-in shell (ash)

I want to repurpose the serial console interface of the MiFi to accept NMEA strings from the GPS module.

I’ve attached the GPS module and using dmesg can see it advertised as /dev/ttyATH0.

Using minicom and setting my terminal settings I can see valid NMEA stings coming through (same as using cat /dev/ttyATH0).

Next I installed gpsd and gpsd-clients (for testing). The issue currently looks to be the ttyATH0 port is being consumed by another process which is preventing gpsd from connecting to the port. For instance if I’m running cgps I get no data received and eventually cgps times out, but in another shell I run minicom and some NMEA data gets delivered to gpsd when it first starts but then ceases after 1-2 seconds, then closing minicom there is another trickle of NMEA data to gpsd (verified by full 3D GPS lock in cgps) but then ceases after 1-2 seconds. This suggests to me something is grabbing the port once minicom hangs up its session.

I’ve referenced this link: https://forum.archive.openwrt.org/viewtopic.php?id=47723 and https://oldwiki.archive.openwrt.org/doc/recipes/terminate.console.on.serial which gives details on disabling the console but haven’t had any luck getting gpsd to attach onto the serial console (ttyATH0) without using minicom to initiate and hang up which trickles through a little bit of NMEA data.

Some config outputs to try and disable any process from using the serial console:
cat /etc/inittab

::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
#::askconsole:/bin/ash --login

cat /etc/sysctl.conf
#Defaults are configured in /etc/sysctl.d/* and can be customized in this file
kernel.printk = 0 4 1 7

Tried a couple of options in: /etc/rc.local (last few lines):

/usr/sbin/gpsd -G /dev/ttyATH0
stty -F /dev/ttyATH0 4:0:18b2:0:0:0:0:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0

both now commented out.

gpsd config:

Any thoughts?

1 Like

The "lsof" utility can display open files and the process that has opened them.

Thanks I'll check out that command and see if it gives me the info I need. I'll let you know how I go.