python - Pyserial failed to read full line after sending data -
i'm developping script pyserial send data microcontroller, microcontroller read data, process them, , send debug information python script.
my python script working without issue when reading data microcontroller. need send data microcontroller , start reading after that, data i'm reading not complete.
i should receive [tag1],10,11,12,[tag1],13,14,15\n don't received beginning of data end 1,12,[tag1],13,14,15\n
i'm doing:
serial.write(dataout) datain = serial.read(sizeofthedatatoreceive) the issue not come microcontroller i'm sure of that, if i'm using putty send/receive data see full data.
i tried add delay in microcontroller code send data 10s after receiving data python, still it's not working everytime.
do have idea can cause ? com port opened when python script start , closed @ end of script.
you need clear read , write buffers:
serial.flushinput() serial.flushoutput() then read data byte-wise:
serial.write(dataout) time.sleep(0.3) s='' while serial.inwaiting()>0: b=serial.read(1) # time.sleep(0.1) s += b
Comments
Post a Comment