Created
December 13, 2018 11:04
-
-
Save RavSS/d1ec3f54d565f3e51db3e6776a4a39f2 to your computer and use it in GitHub Desktop.
A script that allows a user to use the Ericsson F5521gw (HP HS2340) UMTS/GPRS WWAN card with the de facto standard GPS utility on Linux, which is GPSd.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -Author: Ravjot Singh Samra ([email protected])- | |
# This script is intended for using the Ericsson F5521gw (HP HS2340) WWAN card | |
# with GPSd. As of now (d13/m12/2018) it is still unusable with GPSd without | |
# configuring it first; however, GPSd does not send the Hayes AT command | |
# in the first place to start up the GPS. The solution is to send the AT | |
# commands, set the connection used for sending it to "sleep", and then | |
# use the device normally. This should seriously be done by GPSd instead. | |
import sys | |
import serial # sudo pip3 install pyserial | |
def getline(gps, lines): | |
for i in range(lines): | |
print(gps.readline().decode("utf-8")) | |
def main(dev): | |
gps = serial.Serial(dev, timeout=5) | |
print(gps.name) | |
getline(gps, 1) | |
gps.write(b"AT*E2GPSCTL=1,5,1\r\n") # Control GPS settings. NMEA on. | |
getline(gps, 2) | |
gps.write(b"AT*E2GPSNPD\r\n") # Start the GPS. | |
getline(gps, 3) | |
print("'OK' should be returned twice as a\n" | |
"result of sending 2 AT commands.\n") | |
input("Press ENTER once you have launched\n" | |
"GPSd and your monitoring program\n" | |
"with the device specified above,\n" | |
"or preferably you can leave this\n" | |
"script open until you're done...\n") | |
gps.close() | |
if __name__ == "__main__": | |
if len(sys.argv) < 2: | |
print("USAGE: python3 thisScript.py " | |
"<F5521gw NMEA device under /dev/>\n" | |
"The device is usually '/dev/ttyACM2>'") | |
sys.exit() | |
main(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment