pyserial script doesnt execute properly

News123 news123 at free.fr
Tue Mar 9 04:19:56 EST 2010


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




More information about the Python-list mailing list