admin管理员组文章数量:1336346
Hi i am working with python serial project i want to change the serial port parity value at runtime it is not working properly especially in odd parity mode it is not sending correct data
import serial
import time
ser = serial.Serial(
port='COM3',
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=0
)
time.sleep(2)
while True:
ser.parity = serial.PARITY_ODD
ser.write(serial.to_bytes([0x01]))
ser.write(serial.to_bytes([0x02]))
ser.write(serial.to_bytes([0x03]))
ser.write(serial.to_bytes([0x01]))
ser.write(serial.to_bytes([0x02]))
ser.write(serial.to_bytes([0x03]))
time.sleep(2)
In above code i am sending three bytes of data with Odd and Even parity while sending i am able receive the Even parity data with correct value but in odd parity mode it is not transmitting correct values
for even parity at the receiver end i am getting 01 02 03
for odd parity at receiver end i am getting some time 01 12 03 some time 01 08 03 some time 81 02 03
guide me to change the parity of the serial port at run time
本文标签: Changing Serial Port Parity at Run time Python SerialStack Overflow
版权声明:本文标题:Changing Serial Port Parity at Run time Python Serial - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742354902a2459213.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论