0
私はディスプレースメント測定をしています。私はそのPythonに値を与えてもらいたいですが、わかりません。どのようにデータを受け取りますか?このコードを使用して、私の次のエラー - TypeError:バイトをstrに連結できません。RS232からのデータをPythonで読み取る
`import serial
port = "COM3"
baud = 115200
ser = serial.Serial(port, baud, timeout=1)
# open the serial port
if ser.isOpen():
print(ser.name + ' is open...')
while True:
cmd = input("Enter command or 'exit':")
# for Python 2
# cmd = input("Enter command or 'exit':")
# for Python 3
if cmd == 'exit':
ser.close()
exit()
else:
ser.write(cmd.encode('ascii','strict')+'\r\n')
out = ser.read()
print('Receiving...'+out)
`