Skip to content Skip to sidebar Skip to footer

No Output From Pyserial

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 l

Solution 1:

Please try this instead:

import serial
import sys
from time import sleep

try:
  ser = serial.Serial("/dev/ttyUSB0", 115200,timeout=0, parity=serial.PARITY_NONE, 
                        stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS)
except:
  sys.exit("Error connecting device")

whileTrue:
  queue = ser.inWaiting()
  if queue > 0:
    data = ser.read(1000)
    print data
  sleep(0.2)

The problem may be related to not configuring all the UART settings as expected for the Zolertia Z1 mote.

Update: Please make sure that the connection to port is not used by another process. Because if it is printing elsewhere then it won't be able to read the data by the python script.

Post a Comment for "No Output From Pyserial"