1
USBシリアルポートからの空のB「」を出力し、それは、USBシリアル制御デバイスのためです:Pyserialが、私は問題を抱えているように見える
import serial
import time
ser1 = serial.Serial('/dev/tty.usbserial', 115200, timeout=0.1)
def setupMode():
ser1.write(b'$PF,200\r\n')
ser1.write(b'$PO,20\r\n')
setupMode()
def startMeasurments():
ser1.write(b'$GO\r\n')
startMeasurments()
def checkUnit():
ser1.write(b'$US\r\n')
checkUnit()
while True:
data = ser1.read(9999)
print ('Got:', data)
time.sleep(0.1)
ser1.close()
私はこれらの結果を得る:
python maintest.py
Got: b''
Got: b''
Got: b''
Got: b''
Got: b''
Got: b''
Got: b''
Got: b''
Got: b''
Got: b''
印刷データの周波数が正しいようで、コマンドをテストしたとき:
ser1.write(xxxxx)
それのトンデバイスを起動し、必要なデータをメーカーが提供するソフトウェアに出力するので、うまくいきます。ちょうどpythonの出力がうまくいかないようです。 どうすればこの問題に取り組むことができますか?
をあなたのタイムアウトが低いように思われます。 – stovfl