【问题标题】:i am sending commands through serial port in python but they are sent multiple times instead of one我通过python中的串口发送命令,但它们被发送多次而不是一次
【发布时间】:2023-04-01 05:50:02
【问题描述】:

我正在使用 com 端口串行发送一些具有特定响应的命令..这些命令保存在一个文件中..我通过文件逐行读取每个命令并通过 com 端口串行发送..但是当我我使用魔术终端(软件)从接收器端看到它..我发现每个命令都会执行多次..我只发送一次..我在 pycharm 中编写了一个代码..在控制台中我是看到该命令只执行一次,但从 uart 接收端来看,故事是另一回事..我被这个问题困住了..我保持相同的波特率和一切,但无法诊断问题..
代码的github链接是:https://github.com/AkshatPant06/Akshat-Pant/blob/master/cmd%20list

def recvResponse():
ser.write(serial.to_bytes(intCmd))
time.sleep(1)
data_recv=ser.read(2)
return data_recv

这是我用来接收 2 字节响应的..

【问题讨论】:

    标签:
    python
    python-3.x
    serial-port