On Apr 26, 8:21 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-04-25, terry <[EMAIL PROTECTED]> wrote: > > > I am trying to send a character to '/dev/ttyS0' and expect the > > same character and upon receipt I want to send another > > character. I tired withPyserialbut in vain. > > Pyserialworks. I've been using it almost daily for many > years. Either your program is broken, your serial port is > broken, or the device connected to the serial port is broken. > > > Test Set up: > > > 1. Send '%' to serial port and make sure it reached the serial port. > > 2. Once confirmed, send another character. > > > I tried with write and read methods inPyserialbut no luck. > > > Can you help? > > Ah yes, the problem is in line 89 of your program. > > We've no way to help if you don't provide details. If you > really want help, write as small a program as possible that > exhibits the problem. I'd like to emphasize _small_. The > larger the program the less likely people are to look at it, > and the less likely they are to find the problem if they do > look at it. > > Much of the time the exercise of writing a small demo program > will lead you to the answer. If not, then post it, along with > the output from the program that shows the problem. > > Then we can tell you what you did wrong. > > -- > Grant Edwards grante Yow! I'm also against > at BODY-SURFING!! > visi.com
Here is the code. """Open serial connection""" def openSerialConnection(self,serpt): try: s1 = serial.Serial(serpt,timeout=10) except: self.print_u("Failed to open serial port %s. " %serpt) def enterThroughSerialPort(self,serpt): s1 = serial.Serial(serpt,timeout=10) self.print_u('Sending !!!!..') while True: s1.write('*') c = s1.read(1) if c: self.print_u('Found "*" ') break print c s1.write('enter\r') s1.read('login') if __name__ == '__main__': serpt = '/dev/ttyS0' x.openSerialConnection(serpt) # funtion to reboot the device goes here ---# x.enterThroughSerialPort(serpt) After opening the serial connection, the device is rebooted followed by sending '*' to serial port and reading back the same. I seem to have problem while trying to read '*' back from serial port. First of all I am not sure if serial port received the '*'. Thanks! -- http://mail.python.org/mailman/listinfo/python-list