1

良い一日。

SERIAL-USB コンバーターと USB ケーブルを使用して、ArduPilotMega のテレメトリー ポートからテレメトリーを読み取る必要があります。

どうすればできますか?

ここに画像の説明を入力

私は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("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'、'Q'、'\xc0'、'c'、'>'、'\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'、'\xed'、'\xfe'、'\xa4'、'\x01'、'\xf6'、'.'、....\xed'、'\xfe'、'\xa4'、'\x01'、'\xf6'、'.'、....\xed'、'\xfe'、'\xa4'、'\x01'、'\xf6'、'.'、....

どうすればデコードできますか?

正しい方法ですか?

ありがとうございました!

4

1 に答える 1

2

16 進文字を読み取ってから連結しているようです。代わりにこれを試してください:

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()
于 2014-06-16T01:26:29.067 に答える