Python 从ArduPilot读取数据';使用电缆的s遥测端口
你好 我需要从ArduPilotMega的遥测端口读取遥测数据 使用串行USB转换器和USB电缆 我该怎么做呢 我尝试使用python:Python 从ArduPilot读取数据';使用电缆的s遥测端口,python,serial-port,arduino,telemetry,Python,Serial Port,Arduino,Telemetry,你好 我需要从ArduPilotMega的遥测端口读取遥测数据 使用串行USB转换器和USB电缆 我该怎么做呢 我尝试使用python: import serial ser = serial.Serial(port='/dev/ttyUSB0', baudrate=57600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=0) print("c
import serial
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=57600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=0)
print("connected to: " + ser.portstr)
line = []
while True:
for c in ser.read():
line.append(c)
if c == '\n':
print line
line = []
结果如下所示:
已连接到:/dev/ttyUSB0
['\x1c'、'\x01'、'\x1e'、'V'、'\x00',
“\x8c”、“=”、“\xe2”、“\xbc”、“v”、“\xc0”、“\xf6”、“8”、“、”、“\xba”,
‘E’、‘8’、‘百分比’、‘\x14’、‘\x01’、‘J’、‘\x00’、‘\x00’、‘\x00’、‘\x00’、‘\x00’,
“Q'、”\xc0'、“>”、“\x00'、“\x00'、“\xc2'、“\x1a'、“\x01'、“\x1b”,
“\x12”、“”、“\x00”、“\x00”、“\xff”、“\xff”、“\xfc”、“\x00”、“\x00”,
“\x00”、“\x00”、“\x00”、“\x00”、“\xa1”、“\x0e”、“\x01”、“\x1d”、“V”,
“\x00”、“\xdb”、“D”、“f”、“>”、“\r”、“\xec”、“\x1f”、“\x01”、“\x01”,
“\xfc”、“\x00”、“\xfc”、“\x00”、“\xfc”、“\x00”、“\x01”、“\x00”,
“\xff”、“\x00”、“\x00”、“\x00”、“\x00”、“\x00”、“\x00”、“\x00”、“\x”,
“\xfe”、“\xa4”、“\x01”、“\xf6”、“.”、
我怎样才能破译它
这是正确的方法吗
谢谢!看起来您正在读取十六进制字符,然后将它们串联起来。请尝试以下操作:
import serial
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=57600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=0)
print("connected to: " + ser.portstr)
while True:
print ser.readline()
我的解决方案:使用一个usb端口安装一个远程通信端口