GPS on Beaglebone from 4G modem

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

I am a pfSense fan and have Sierra MC7700 and Atheros Mifi embedded builds in a couple of headless vehicle Intel PC's. So I am familiar with embedded gear and I am learning with FreeBSD on the Beaglebone Black.
So due to a single USB port I used a USB hub with MC7700 on a USB to MiniPCIe adapter and a USB Wifi stick, the RaLink 5592 as a software access point, But I wanted to achieve one last thing:

GPS: The Sierra MC7700 provides NMEA0183 on an cuaU interface.

Here is the what it takes:

Install astro/gpsd package
Prep modem from terminal program:
cu -l /dev/cuaU0.3
at
atz
AT!ENTERCND="A710"
AT!CUSTOM="GPSENABLE",4

Now Exit from cu with shift + ~ then dot key

Reboot and run these commands

stty -f /dev/cuaU0.2 raw; echo \$GPS_START >/dev/cuaU0.2

gpsd -n /dev/cuaU0.2

Tested as working with cgps and xgps-- astro/gpsd provided GPS clients
 
Last edited:
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

How can I add "echo \$GPS_START >dev/cuaU0.2" to my system startup?

This would also work with the MC7710 in DirectIP mode aka PID=68a3
The MC7700 family does not show up in u3g but is covered by the MC8700 entry in in case you go looking.
While usbdevs has the VID&PID for MC7700 and MC7710 in DirectIP mode.
 
Last edited:
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

After further review it appears that the stty -f /dev/cuaU0.2 raw command is only needed once. It survives reboot.

This portion needs running each bootup:
echo \$GPS_START >/dev/cuaU0.2
So this command would appear as it is sending $GPS_START to the modems GPS port?

I need it to launch before astro/gpsd in the rc.conf.
 

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

You might be able to do the magic echo later, while gpsd(8) is already running. Least fuss that way. Works that way here with a Qualcomm 3G&GPS.

tty(1) mode does not survive reboot, but the defaults suffice.

Juha
 

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

gpsd(8) has a mechanism for oddball devices, it seems.
Code:
hopo # gpsd -nF /var/run/gpsd.sock
hopo # gpsdctl add /dev/cuaU0.3
hopo # echo '!/dev/cuaU0.3=$GPS_START' | nc -UN /var/run/gpsd.sock
First command starts the daemon without any devices, 2nd adds a device (note my endpoint is different) and the last one does the magic. U is for Unix Domain socket, N is for the OK/ERROR response to come back and the connection to end properly.

Juha

EDIT: improper nc(1) option -w5 changed.
 
Last edited:
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

I am having trouble with the commands on the third line. It is kicking out an error:
Code:
/dev/cuaU0.2=: Event not found
I tried a couple of variations on your approach and have posted my console output.

***attachment deleted by author***
 
Last edited:

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

Looks like echo '&/dev/cuaU0.2=244750535f5354415254[B]0d0a[/B]' is a better way, you get full control on the linefeed.

I hope your chip is not as flaky as this Gobi 2000 one. I'm finally trying to set things up so that "the blue antenna button" would bring things up automatically via devd(8) as needed. GPS goes completely mute, if accessed too soon after PPP.

Juha
 
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

Thanks Again. It seems that did the trick for echo, now I am getting ERROR(no description given). After troubleshooting the problem is on the nc side of the pipe.
I am reading on it now. Could it be permissions on the gpsd.sock file???

I see more instructions from you and will try them now.

Tonight I finally got net/mpd5 running with the MC7700 and that is a watershed moment for me. Took a while to get DNS worked out with resolvconf(8). Getting mpd.conf right was a challenge. I even have it launching on startup correctly.

Once again Thanks for your Patience
 
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

So with an "Blue Antenna Button" am I to assume you are using an USB Gobi2000 Stick? You said earlier Qualcomm? What is your device?
Thanks
 
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

After consulting the nc(1) manual this example stands out to me:
nc -lU /var/tmp/dsocket

Maybe I need to scan for listening daemons:
nc -zU /var/run/gpsd.sock??

This would listen for incoming connections?
nc -lU /var/run/gpsd.sock
 

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

nc is working fine, the ERROR comes from gpsd. It probably cannot open the /dev/cuaU0.2, because it is being paranoid and gave up root privileges. gpsd is a mess :) You'll see more info in /var/log/messages (if syslogd is running). It can be fixed by chgrp wheel /dev/cuaU0.2 before you launch gpsd.

My device is Qualcomm Gobi 2000, an internal USB device, sticker reads HP un2420 Mobile Broadband Module. The blue/orange button powers it on/off and, as the chip requires the firmware to reloaded, it's a mess too. And the 3G network is a mess as well, so the button must be used a lot.

This works for me, when I wait until devd has finished and PPP is up:
Code:
#!/bin/sh

debug="-ND3" # foreground, verbose
debug=""         # normal

killall -q gpsd && echo old gpsd terminated

set -e  # exit if sysctl or echo fails

GPS="/dev/cua`sysctl -n dev.u3g.0.ttyname`.3"

echo '$GPS_START' > "$GPS" # CRLF via default oflags: opost onlcr

gpsd $debug -nF /var/run/gpsd.sock "$GPS"
gpsdctl and nc are not used. There's a hardcoded u3g.0 there, so it fails with multiple GPSs. A man with two GPSs is never sure :)

Juha
 
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

Thank You, the permissions fix for dev/cuaU0.2 gave me an OK with those 4 lines and now xgps gives me satellites.
What would be the best way for me to autolaunch on boot the settings I now have.
I do not see a chgrp command in your script? Would I add the 4 lines to a new script?
 
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

How about this approach. I put my $GPS_START command into rc.d/serial. Would that run it before rc.conf is evoked?
 

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

In that complete launch/relaunch script, "F /var/run/gpsd.sock" can be omitted, it has no purpose. The device is given on the gpsd command line, and is opened as root immediately (-n flag is required) before gpsd changes into nobody:wheel credentials. chgrp is not needed.

I would stay away from rc.conf and rc.d/ and just put the complete script at the end of /etc/rc.local. All in one, instead of scattered.

Juha
 
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

OK Thank you again. I spent the night trying to change from the modem end. NMEA sentence and other GPS options. No luck. Still needs the echo magic to start. The AT!CUSTOM="GPSENABLE",4 command from above is correct according to the Sierra doc's. It was needed to work on a module I flashed with the newest firmware.

I cut and pasted the script directly from above into a file named rc.local and pasted it into /etc/ folder. Is that correct? I saw no file named rc.local there. So I made one.
I did append line 6.) ttyname`.3" to say ttyname`.2" --I am assuming that is the GPS cuaU port(Or should it be the u3g0 USB bus/address).

I also noticed tonight that the order I launch my two commands does not matter,
astro/gpsd can go first and $GPS_START > launched later.
 

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

Correct, .2 is your cuaU port. Better move the script into, say, /root/bin/gpstart and call that from /etc/rc.local. You might want to run it manually sometimes, and might later need to add completely different boottime commands. And it's the traditional rc.local way
Code:
/root/bin/gpstart && echo -n ' gpsd'
Juha
 
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

So I figured out that we were calling gpsd twice. Once on line 4 of the script and once in the rc.local as well. The one in rc.local was not calling up the interface. So when i deleted line 4 of my gpsstart script gpsd still did not come up correctly. So i deleted that as well from rc.local.
Instead I added these lines to rc.conf.
Code:
GPSD_ENABLE="YES"
GPSD_FLAGS="-n"
GPSD_DEVICE="/dev/cuaU0.2"
That works well. I did have to remove the "relaunch line" in the gpsstart script. I really needed to see it work.
Code:
#killall -q gpsd && echo old gpsd terminated
Now I have both net/mpd5 and astro/gpsd on startup just like I wanted.
Thanks Again
 

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

You must be starting it via rc.conf now. The gpsstart would need the full path /usr/local/sbin/gpsd to work in all cases. But, as long as it works.

Juha
 
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

It does work well. Several reboots. Extended cold boots it works.
Ready for embedded implementation.
Now its time to explore all the different software available for GPS and find a good logging method.

I have to try this. Open Chart Plotter Navigation.
http://opencpn.org/ocpn/

The only thing I am missing for the trifecta is an NTP time server from the GPS. Would be a worthy addition due to Beaglebones lack of a RTC.
 
OP
Phishfry

Phishfry

Son of Beastie

Reaction score: 1,886
Messages: 4,913

I wanted to add to this thread the incredibly useful software:

gpxlogger

This program collects fixes from gpsd and logs them to standard output in GPX, an XML profile for track logging.

This is a component of the astro/gpsd port.
Kudos for gpsd. It is a great collection of software.
 
Top