On Mar 9, 8:01 pm, kishore <kishorei...@gmail.com> wrote: > On Mar 9, 2:19 pm, News123 <news...@free.fr> wrote: > > > > > Hi, > > > kishore wrote: > > > hello there > > > > Iam using python 2.5.4 > > > pyserial 2.4 > > > pywin32-214 > > > > on windows 7 > > > > i hav a small test script written to query a serial device (arduino) > > > and get back reply appropriately > > > > ////file: test.py > > > > import serial > > > print 'hi' > > > ser=serial.Serial(port='\\.\COM2', baudrate=9600) > > > ser.close() > > > ser.open() > > > ser.write('1') > > > ser.readline() > > > ser.readline() > > > ser.close() > > > > the device waits for '1' through its serial interface and print two > > > lines if it gets '1' > > > > "Some Data found" and "Header received" > > > > the script works on IDLE well when given one line at a time > > > > but when given in command line as python test.py it prints hi and wait > > > forever > > > Unfortunately I don't remember exacty, but try following: > > > close IDLE and try then to start the script from the command line. > > I remember having had a problem with idle, that it did not always close > > the UART port > > (especially, when an error (e.g. syntax) occured before the close statement) > > > bye > > > N > > Thanks for your response > i tried closing idle and the following code prints > port opened > Write failed > > code: > > import serial > import time > ser=serial.Serial(port='\\.\COM2', baudrate=9600) > if ser: > print 'port opened' > ser.open() > if ser.write('1'): > print 'Write success' > else: > print 'write failed' > > time.sleep(1) > > a=ser.readline() > time.sleep(1) > b=ser.readline() > print b > ser.close() > > I believe this might be a serial port access error. > how to solve this? > Any suggestions?
have found one more person with same problem but no solution http://mail.python.org/pipermail/python-win32/2009-January/008613.html -- http://mail.python.org/mailman/listinfo/python-list