0
我真的希望有人能帮助我解决这个问题,我一直在为它工作3天,现在它让我疯狂。十六进制数据发送出串口问题
我有两个基于Linux的设备通过串行连接,一个是嵌入式设备,另一个是pc型设备。我在PC设备上有一些python代码,它目前可以成功读取嵌入式设备发送的消息(因此串行设置是正确的)。
但是我现在需要将命令发回给嵌入式设备,这就是我所苦苦挣扎的,我在串口线上有一个数据分接头,所以我可以看到数据被发送/接收。
当我从串口发送字符串“\ x2a \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x57 \ x78 \ xD6 \ x81 \ x00 \ x01 \ x00 \ x8D \ x54”数据点击我只看到“EF F7 FF FF”。
请参阅下面的代码:
import serial
serialport = serial.Serial(port=self.device,
baudrate=self.baudrate,
bytesize=self.bytesize,
parity=self.parity,
stopbits=self.stopbits,
timeout=0)
data = "\x2a\x00\x00\x00\x00\x00\x57\x78\xD6\x81\x00\x01\x00\x8D\x54"
serialport.write(data)
serialport.flushOutput()
您的串行数据分接头是否显示嵌入式设备发送的命令上的正确数据? –