资料详细资料: $GPRMC,1,2,3,4,5,6,7,8,9,10,12 * hh1utc时间,hhmmss (时分秒)格式2的定位状态,A=有效定位、 V=无效定位3纬度ddmm.mmmm (度数)格式(4纬度半球n ) (也传输前面的0 )或s )南半球) 5经度ddmm.mmmm (度数)格式(也传输前面的0 ) 6经度半球e )东经ddmmyy )日月年)格式10磁偏角) 000.0~180.0度,前0也传输) 11磁偏角方向,e (东)或w )西) 12模式显示)仅输出NMEA01833.00版,NMEA01833.00版
' ' ' $GNRMC,092846.400,a,3029.7317,n,10404.1784,e,000.0,183.8,070417,A*73
$GNRMC,
092846.400,//UTC时间,hhmmss.sss (时分秒.毫秒)格式
a、//定位状态,A=有效定位,V=无效定位
3029.7317,n,//纬度
10404.1784,e,//经度
000.0,//地面速度
183.8,//地面航向
070417,//UTC日期
、//磁俯角
、//磁方位
A*73 //模式指示" " "
#coding:utf-8#! /usr/cmdxl/python3
importsys,osimportreimportloggingimportdatetime # addpathforimportmodule
filePath=os.getcwd (
sys.path.append (文件路径) )。 from com _ utilities.flexconfigimportresourcesconfigasflexconfigfromcom _ utilities.uartimportcserialasuartfromcom _ utities lities resourcehandlerasresource _ _ all _=[ ' GPS _ fake ' ] ' ' gpsdatapacketformat 3360 '
数据详细信息: $GPRMC,1,2,3,4,5,6,7,8,9,10,11,12 * hh
1 UTC时间,hhmmss (时分秒)格式
2定位状态,A=有效定位,V=无效定位
3纬度ddmm.mmmm (度)格式(也传输前面的0 ) )。
4纬度半球n (北半球)或s (南半球)
经度dddmm.mmmm (分钟)格式(也传输上一个0 ) )。
经度半球e (东经)或w (西经)
7地面速度(000.0~999.9节,还传输前面的0 ) )。
8地面航向(000.0~359.9度,以正北为基准,也传输前面的0 ) )。
9 UTC日期,ddmmyy (日月年)格式
10磁偏角(000.0~180.0度,上一个0也被传输) ) )。
11磁偏角方向,e (东)或w (西) )。
12模式指示(仅NMEA01833.00版本输出,A=自主定位,D=差分,E=估计,N=数据无效) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
' $GPRMC,' 060949.000 ',a,3150.7815,n,11711.9239,e,2.87,314.13,' 050314 ',D*69 '
时间格式:080650.00008336006336050.00000
date format :3112192019/12/31 " "
' ' ' $GNRMC,092846.400,a,3029.7317,n,10404.1784,e,000.0,183.8,070417,A*73
$GNRMC,
092846.400,//UTC时间,hhmmss.sss (时分秒.毫秒)格式
a、//定位状态,A=有效定位,V=无效定位
3029.7317,n,//纬度
10404.1784,e,//经度
000.0,//地面速度
183.8,//地面航向
070417,//UTC日期
、//磁俯角
、//磁方位
A*73 //模式指示" " "
classGPS_fake(UART ) : def _ init _ (self,userName,userID ) :
self.resource=Resource (; #serial port message: [0]-port,[1]-baud
serial port msg=self.resource.get _ serial _ or _ IP (username,userID )
URT.__init_(self,serialportMsg[0],int ) serialportMsg[0],10 ) )
self.Serial_Create () def__GPS_checksum_ ) self,string ) :
checksum=0
val=bytes(string ) forindexinrange (len ) val ) ) :
checksum ^=val [ index ] return checksum # time format 3360080650.00008336006360050.0000
defGPS_currentformattime(self ) :
now_time=datetime.datetime.now (
strtime=now _ time.strftime (% h % m % s.% f ) ) ) )。
str=strTime.split ('.' )
micSecond=str[1][0:3]
nowtime=str [0] '.' micsecondreturnnowtime # time format 33602604192019/04/26
defGPS_currentformatdate(self ) :
now_time=datetime.datetime.now (
covyear=now _ time.year-2000 nowdate=' DD ' % (now _ time.day,now_time.month,cov year ) returnowdatededefgggge
gpsMessage='GPRMC,' time ',a,3150.7815,n,12123.5344,e,2.87,314.13,' date ',d ' checksum=self
message=' $ ' gpsmessage ' * ' str (checksum,encoding='utf8 ' ) (r(n'self.serial_writestring ) message )
gpsMessage='GPRMC,' time ',a,' latitude ',n,' longitude ',e,2.87,314.13,' date ',d ' checksum=sell
message=' $ ' gpsmessage ' * ' str (checksum,encoding='utf8 ' ) (r(n'self.serial_writestring ) message )
gpsMessage='GNRMC,' time ',a,3150.7815,n,12123.5344,e,2.87,314.13,' date ',a ' checksum=self .
message=' $ ' gpsmessage ' * ' str (checksum,encoding='utf8 ' ) (r(n'self.serial_writestring ) message )
gpsMessage='GNRMC,' time ',a,' latitude ',n,' longitude ',e,2.87,314.13,' date ',a ' checksum=sell
message=' $ ' gpsmessage ' * ' str (checksum,encoding='utf8 ' ) (r(n'self.serial_writestring ) message )
self.Serial_Close () #test example
if __name__=='__main__':
gps_test=GPS_Fake (
gps_test.Serial_Create (