[PythonCE] Accessing serial port with PythonCE 2.5
Rushali Watane
rushaliwatane at gmail.com
Tue Dec 15 07:01:33 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-
September/001589.html
> >>> 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
serial
> > ports. I have successfully write the data to the port but I am not
able
> > to read the data from the ports. It is getting connected to the port
but
> > it is not able to read the values. Below is my code snippet for
reading
> > the data from the port.
> >
> > Can you help me to solve this issue.
> >
> > from time import sleep
> > import ceserial
> >
> > ser =
> >
ceserial.Serial(port="COM1:",baudrate=9600,bytesize=8,stopbits=ceserial.
> > 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
> >
>
> Hi,
>
> You seem to be missing the essential steps of ser.open() before trying
> to read and ser.close() at the end.
Hi
I have open the port before trying to read the data but it shows only
output as-
connected to:COM1
Got:
It is get connected to the serial port but not able to read the values
from the port. I am sending you the my updated code snippet. please tell
me the solution for it.
from time import sleep
import ceserial
ser =
ceserial.Serial(port="COM5:",baudrate=9600,bytesize=8,stopbits=ceserial.
STOPBITS_ONE,parity=ceserial.PARITY_EVEN)
print("connected to: " + ser.portstr)
ser.open()
#data = ''
while True:
n = ser.inWaiting()
size = n
data = ser.readline(size)
if len(data) > 0:
print 'Got:', data
sleep(0.5)
#print 'not blocked'
ser.close()
Regards
Rushali
More information about the PythonCE
mailing list