Dragonboard 410c development board application: parsing GPS message location information using Python script

The dragonboard 410c is a very powerful development board that comes with GPS, wifi and high-performance graphics processing unit, which can easily realize various functional requirements in the Internet of Things. GPS is a commonly used function in IoT devices. Conveniently positioning the device is the basis of many IoT applications. This blog will give you a brief introduction to how to use Python scripts to parse GPS message data on the dragonboard 410c.

Dragonboard 410c development board application: parsing GPS message location information using Python script

First of all, we need to understand the GPS message format. Here we introduce and use the commonly used GPS message format recommended by the industry, as follows:

d. Recommended location information (RMC)

$GPRMC, <1>, <2>, <3>, <4>, <5>, <6>, <7>, <8>, <9>, <10>, <11>, <12> *hh

<1> UTC time, hhmmss (hours, minutes and seconds) format

<2> Positioning status, A=effective positioning, V=invalid positioning

<3> Latitude ddmm.mmmm (degrees) format (the previous 0 will also be transmitted)

<4> Latitude hemisphere N (Northern Hemisphere) or S (Southern Hemisphere)

<5> Longitude dddmm.mmmm (degrees) format (the previous 0 will also be transmitted)

<6> Longitude hemisphere E (East) or W (Western)

<7> Ground rate (000.0~999.9, the previous 0 will also be transmitted)

<8> Ground heading (000.0~359.9 degrees, with the true north as the reference, the front 0 will also be transmitted)

<9> UTC date, ddmmyy (day, month, year) format

<10> Magnetic declination (000.0~180.0 degrees, the front 0 will also be transmitted)

<11> Magnetic declination direction, E (east) or W (west)

<12> Mode indication (only NMEA0183 3.00 version output, A= autonomous positioning, D=differential, E=estimate, N=invalid data)

e. Ground speed information (VTG)

$GPVTG, <1>, T, <2>, M, <3>, N, <4>, K, <5> *hh

<1> Ground heading with true north as reference (000~359 degrees, the front 0 will also be transmitted)

<2> Ground heading with reference to magnetic north (000~359 degrees, the front 0 will also be transmitted)

<3> Ground speed (000.0~999.9, the previous 0 will also be transmitted)

<4> Ground speed (0000.0~1851.8 km/h, the previous 0 will also be transmitted)

<5> Mode indication (only NMEA0183 3.00 version output, A= autonomous positioning, D=differential, E=estimate, N=invalid data)

After seeing the above format, combined with the parsing of the XML files and the operation of the python script messages in the previous blogs, this is very simple. If we need to read the location information and time information in the GPS message, we can Design the following function to complete:

Class gpsDataProcessing:
Def __init__(self, gpsFrame):
self.gpsData=gpsFrame

#get laTItude and longitude date from gpsFrame
# East Longitude and North laTItude is abs posiTIve number +
# West longtude and south laTItude is negative -
# return (longitude and latitude)
Def getPosition(self):
#当 gpsFrame is GPRMC
Longitude=0.0
Latitude=0.0
dataList=self.gpsData.split(',')
utcTime=dataList[1]
If dataList[0]=='$GPRMC'or dataList[0]=='$gprmc' :
If dataList[6]=='E' or dataList[6]=='e':
Longitude=float(dataList[5])
Elif dataList[6]=='W' or dataList[6]=='w':
Longitude=0-float(dataList[5])
Else:
Return -1
If dataList[4]=='N'or dataList[4]=='n':
Latitude=float(dataList[3])
Elif dataList[4]=='S'or dataList[4]=='s':
Latitude=0-float(dataList[3])
Else:
Return -1
Elif dataList[0]=='$GPGGA'or dataList[0]=='$gpgga' :
If dataList[5]=='E' or dataList[5]=='e':
Longitude=float(dataList[4])
Elif dataList[5]=='W' or dataList[5]=='w':
Longitude=0-float(dataList[4])
Else:
Return -1
If dataList[3]=='N'or dataList[3]=='n':
Latitude=float(dataList[2])
Elif dataList[3]=='S'or dataList[3]=='s':
Latitude=0-float(dataList[2])
Else:
Return -1

Return(utcTime,longitude,latitude)

In the above python code, we built a GPS parsing class, but only gave the analytic function interface of the relevant message in the recommended message format. If you need to further parse the GPS data of other message formats, you can inherit Or rewriting the class, the class is instantiated in the need to obtain GPS data and parsing the GPS data, and the GPS data can be conveniently parsed to obtain the positioning time and the latitude and longitude position information.

For Oppo Glass

For Oppo Glass,Oppo Find X3 Front Glass,Oppo Phone Screen Glass,Oppo Reno 5 Pro Glass

Dongguan Jili Electronic Technology Co., Ltd. , https://www.jlglassoca.com