rams4pi
Posts: 5
Joined: Fri May 16, 2014 3:53 pm

Serial Communication Pyserial

Mon Jun 02, 2014 4:47 am

hi friends,
i am facing some problems with serial communcation, my requirement is i need to write i value, Instead of Giving string in ser.write ()

import serial
i = 10
ser = serial.Serial(port, 9600, timeout=1)
ser.open() # i am opening a serial port .
i need to write i value. can any one tell me the syntax .
ser.write(i) # is this correct ... can i write i value using i ...


Please Reply me ASAP

Thanks,
Rams4pi.

riklaunim
Posts: 265
Joined: Tue Apr 22, 2014 7:34 pm

Re: Serial Communication Pyserial

Mon Jun 02, 2014 6:10 am

Maybe chr(i) would work for you? Serial communication may depend a lot on the target device and its API. If that doesn't help post some info about your device connected via serial.


rams4pi
Posts: 5
Joined: Fri May 16, 2014 3:53 pm

Re: Serial Communication Pyserial

Mon Jun 02, 2014 7:00 am

i am coonecting Xbee to Piusing usb and using Pyserial to communicate Serially ..

atomic3
Posts: 99
Joined: Thu Jan 17, 2013 4:31 pm

Re: Serial Communication Pyserial

Mon Jun 02, 2014 5:17 pm

On the receiving end just convert to int?

rams4pi
Posts: 5
Joined: Fri May 16, 2014 3:53 pm

Re: Serial Communication Pyserial

Wed Jun 04, 2014 5:39 am

Thanks i got the Output ...

Return to “Beginners”