#!/usr/bin/python
# coding=UTF-8
import RPi.GPIO as GPIO
import serial
import time
from threading import Timer
from EC200U import*      
ec200u=EC200U('/dev/ttyS0',115200)
ec200u.ATSignle('ATE0\r\n','OK')# set gps power on
ec200u.ATSignle('AT+QGPS=1\r\n','OK')# set gps power on
time.sleep(0.5)#单位是s
while True:
    ec200u.ATSignle('AT+QGPSGNMEA=\"rmc\"\r\n','OK')# get gps data
    print(ec200u.rxData)
    if ec200u.rxData.find('$GNRMC')!=-1:#
        line = str(ec200u.rxData).split(',')  # 将line以“，”为分隔符
        if line[4]=='N':#dingwei is ok
            weidu = float(line[3][:2]) + float(line[3][2:])/60
            # 读取第5个字符串信息，从0-3为经度，即经度为117，再加上后面的一串除60将分转化为度
            jingdu = float(line[5][:3]) + float(line[5][3:])/60
            # 纬度同理
            print("longitude:",'{:.6f}'.format(jingdu))
            print("latitude:",'{:.6f}'.format(weidu))
    time.sleep(0.5)#单位是s

         
         