python3使用serial以及pyserial包读取串口数据并解析字节数组,涉及数据移位以及Python无符号整数转为有符号整数操作
1. 代码如下
import serial
import serial.tools.list_ports
import json
import chardet
gps_data = {'lat':[], 'lon':[], 'height':[], 'eulers':[], 'speed':[]}
def getLatLon(data, index):
lat = 0
lon = 0
for i in range(8):
d = int(data[index+i], 16)
left =
原创
2021-04-07 11:54:35 ·
1901 阅读 ·
0 评论