This seems to be poorly documented on the PySerial website, this works for me:
ser = serial.Serial(DEVICE,BAUD,timeout=1) if(ser.isOpen() == False): ser.open()
A little far-fetched example, but you get the idea. I know this question was asked a long time ago, but today I had the same question, and I felt that someone else would find this page, it would be useful to find the answer.
StampyCode May 27 '13 at 9:17 a.m. 2013-05-27 09:17
source share