[PythonCE] Accessing serial port with PythonCE 2.5
rushaliwatane at gmail.com
Tue Dec 15 04:19:30 EST 2015
Steve (Gadget) Barnes <gadgetsteve <at> hotmail.com> writes:
> On 15/12/2015 06:41, Rushali Watane wrote:
> > David Goncalves <pythonce-ml <at> lestat.st> writes:
> >> Hi,
> >> Stefan Johansson wrote:
> >>> You can find a link to ceserial in the archives:
> >>> http://mail.python.org/pipermail/pythonce/2006-
> >>> I have used it successfully on my Dell Axim.
> >> Thanks a lot for that link.
> >> I downloaded CeSerial and started to listen to my serial port
> >> only with 3 lines of code ;)
> >> Regards.
> > Hi,
> > I have also downloaded ceSerial and successfully communicate with
> > ports. I have successfully write the data to the port but I am not
> > to read the data from the ports. It is getting connected to the port
> > it is not able to read the values. Below is my code snippet for
> > the data from the port.
> > Can you help me to solve this issue.
> > from time import sleep
> > import ceserial
> > ser =
> > STOPBITS_ONE,parity=ceserial.PARITY_EVEN)
> > print("connected to: " + ser.portstr)
> > #data = ''
> > while True:
> > data = ser.read(9999)
> > if len(data) > 0:
> > print 'Got:', data
> > sleep(0.5)
> > #print 'not blocked'
> > ser.close()
> > Regards
> > Rushali
> > _______________________________________________
> > PythonCE mailing list
> > PythonCE <at> python.org
> > https://mail.python.org/mailman/listinfo/pythonce
> You seem to be missing the essential steps of ser.open() before trying
> to read and ser.close() at the end.
I have open the port as ser.open() before trying to read but it is
giving me output as connected to COM1:
But not going to read the data. I am sending you my updated code. Please
have a look on it.
from time import sleep
print("connected to: " + ser.portstr)
#data = ''
n = ser.inWaiting()
size = n
data = ser.readline(size)
if len(data) > 0:
print 'Got:', data
#print 'not blocked'
More information about the PythonCE