I am trying to write a code wit pyserial (v2.6) that should wait indefinitely for any input from the port specified using inWaiting()
and then read it using read()
but there's no luck and no output at all. What am I doing wrong? The program just doesn't print anything at all!
Edit: both the program and the port are running on a virtual machine of Contiki OS
Edit2: z1 mote is the device connected to the port. I found out that pyserial is used to write to it (I can't upgrade pyserial to the latest version because it won't workout with the z1 motes)
The full code:
import pyserial
baudrate = 115200
port = '/dev/ttyUSB0'
ser = serial.Serial(port,baudrate)
while 1:
time.sleep(1)
coming_data = ser.inWaiting()
if coming_data != 0:
data = ser.read(coming_data)
print data
# the output from the port is (which should be the output of this program)
# abcd::abcd:0:0:c9 2293 6 -3 243 -23 108
# abcd::abcd:0:0:c9 2337 8 -4 242 -27 108