2014年11月12日水曜日

QZQSMをデコードするプログラムをPythonで作ってみた。

QZQSMをデコードするプログラムをPythonで作ってみた。


#GPS QZSS robot car using QZPOD for QZSS scramble 
import serial
import time

def main():
 
    con=serial.Serial('/dev/ttyACM1', 19200, timeout=10)
    print con.portstr

    a='QSM'

    while 1:
        str=con.readline()
        if a in str:
              b=str.split(',')
              c=b[2]
              d=c.split('07DE')
              e=d[1]
              teamNo=e[0:2]
              X_div=e[2:4]
              Xwidth=e[4:6]
              Y_div=e[6:8]
              Ywidth=e[8:10]
              NumberTarget=e[10:12]
              Stx=e[12:14]
              Sty=e[14:16]
              T1x=e[16:18]
              T1y=e[18:20]
              T2x=e[20:22]
              T2y=e[22:24]
              T3x=e[24:26]
              T3y=e[26:28]

              print(e)
              print('->', teamNo, X_div ,Y_div ,Xwidth ,Ywidth,NumberTarget,'-',Stx,Sty,'-', T1x,T1y, '-',T2x,T2y,'-',T3x,T3y)

#       con.write(str)

if __name__ == '__main__':
    main()

0 件のコメント:

コメントを投稿