EDIT : found the problem: I tried to reference the variable, but mixed up its name, so instead I declared a new variable. It turns out that pySerial is not limited to one open sequential point at a time.
I try to open two serial ports at once using the following code
ser0 = serial.Serial( port = port_list[0], baudrate = 115200, timeout = 0.1 ) ser1 = serial.Serial( port = port_list[1], baudrate = 115200, timeout = 0.1 )
But it seems that I am opening the second, the first is closing. Is there a limit to one serial port opened at the same time using pySerial?
Thanks TG
EDIT: I had to post this to start with
while not (comm_port0_open and comm_port1_open): print 'COM ports available:' port_list = [] i = 0 for port in __EnumSerialPortsWin32(): port_list.append(port[0]) print '%i:' % i, port[0] i+=1 print 'Connect to which port? (0, 1, 2, ...)' comm_port_str = sys.stdin.readline() try: if len(comm_port_str)>0: if comm_port0_open: ser1 = serial.Serial( port = port_list[int(comm_port_str)], baudrate = 115200, timeout = 0.1 ) comm1_port_open = True print '%s opened' % port_list[int(comm_port_str)] else: ser0 = serial.Serial( port = port_list[int(comm_port_str)], baudrate = 115200, timeout = 0.1 ) comm0_port_open = True print '%s opened' % port_list[int(comm_port_str)] else: print 'Empty input' except: print 'Failed to open comm port, try again'
source share