COMポートからデータを読み取ろうとしているときに問題に直面しています。何が問題なのかわかりません..これは、COMポートを介してデータを送受信するために使用しているコードです.COMポートはに接続されています表示するデータを com ポートに送信する STM32 ボード。表示する文字列の末尾に「\n」を追加しています。ここにコードがあります
import serial
ser.port = "COM4"
ser.baudrate = 9600
ser.bytesize = serial.EIGHTBITS #number of bits per bytes
ser.parity = serial.PARITY_NONE #set parity check: no parity
ser.stopbits = serial.STOPBITS_ONE #number of stop bits
ser.isOpen()
print 'Enter your commands below.\r\nInsert "exit" to leave the application.'
while 1:
input = raw_input()
if input == 'exit':
ser.close()
exit()
else:
ser.write(input.encode('ascii')+'\r')
out = ''
while ser.inWaiting() > 0:
out += ser.readline()
print out
これは予想される出力です
Different commands offered are as follows:
''dis'' Displays contact list
''crt name number'' To create contact list
''del name'' To delete contact details
''edt existingName newName number'' To edit contact details
''clog'' To display calllog details
''cin'' Displays only incoming call details
''cout'' Displays only outgoing call details
''cmis'' Displays only missed call details
''rvc number'' To receive a call
''mkc number'' To make a call
''mkc name'' To call from contact list
''clogc number'' To call from calllog list
''cdel'' To delete callLog details
しかし、私はこれを取得しています http://s15.postimg.org/sg9pvr20r/Untitled.jpg 申し訳ありませんが、出力の合計を貼り付けることができないため、出力のスクリーンショットを含めました..