Leveraging GPS in MC7700

Bjørn Mork bjorn at mork.no
Mon Feb 6 16:06:03 UTC 2017


Adam Sherman <adam at sherman.ca> writes:
> On 2017-02-06 09:20 AM, Adam Sherman wrote:
>> Output of mmcli shows ports: 'ttyUSB0 (qcdm), ttyUSB2 (at), cdc-wdm0
>> (qmi), wwp0s20u4i8 (net)'.
>
> After adding the udev rules, mmcli shows ports: 'ttyUSB0 (unknown),
> ttyUSB1 (unknown), ttyUSB2 (unknown), cdc-wdm0 (qmi), wwp0s20u4i8
> (net)'. Notable is the addition of ttyUSB1.
>
>> Then I should issue the AT commands to ttyUSB2. Going to test this right
>> away.
>
> I didn't even need to issue any AT commands:
>
> # echo \$GPS_START > /dev/ttyUSB1
> # gpscat /dev/ttyUSB1
>
> Produces NMEA strings. So I'm off to wire up gpsd, next.

I'm using a hackish hook like this to let gpsd autmatically do the
$GPS_START and $GPS_STOP as required. I.e. only start the GPS when there
are gpsd clients connected:


bjorn at miraculix:~$ cat /etc/gpsd/device-hook
#!/bin/sh
# $Id: device-hook,v 1.2 2016/07/09 19:26:07 bjorn Exp $
#
# gpsd will not poll a device before it is opened, at which time this script is called
# This means that we can unconditionally add the GPS without wasting any power,  It
# will be activated when the first client connects to gpsd, and this script is called
#
# gpsd will also deactivate the port after some inactivity period

# figure out the parent usb device
USBDEV=`ls -l "$1" |sed -ne 's!^c......... [0-9]* [^ ]* [^ ]* \([0-9]*\), \([0-9]*\) .*!/sys/dev/char/\1:\2/device/../..!p'`

# silently ignore any non-USB ports
if [ ! -r "$USBDEV/idVendor" ] || [ ! -r "$USBDEV/idProduct" ]; then
  exit 0
fi 

VID=`cat "$USBDEV/idVendor"`
PID=`cat "$USBDEV/idProduct"`

case "$2" in
  ACTIVATE)
    CMD=START
    ;;
  *)
    CMD=STOP
    ;;
esac

case "$VID:$PID" in
  "1199:9071" |\
  "1199:9079" )
    echo \$GPS_$CMD >"$1"
    ;;
  *)
    ;;
esac

exit 0

... along with these matching udev rules:

SUBSYSTEM=="tty",ACTION=="add",ENV{ID_VENDOR_ID}=="1199",ATTRS{bInterfaceNumber}=="02",SYMLINK="gps%n",ENV{ID_MM_PORT_IGNORE}="1",RUN+="/usr/sbin/gpsdctl add $devnode"
SUBSYSTEM=="tty",ACTION=="remove",ENV{ID_VENDOR_ID}=="1199",ATTRS{bInterfaceNumber}=="02",RUN+="/usr/sbin/gpsdctl remove $devnode"


Been meaning to clean that up for a while, but nothing has
happend... like most of my projects ;) Might as well share what I have.
The status is "works for me".  You'll need to modify the list of device
IDs of course, if you are going to use the hook with an MC7700.  The
udev rules should work out of the box.



Bjørn


More information about the ModemManager-devel mailing list