how to identify a com port in python?
chz
Posts: 8
i'm using python to communicate with the basic stamp and am successful with it, but I am trying to detect which com port the stamp is located at. how would you identify this?
what i've got currently is that it will run through a loop of different device ports, and then when it establishes a connection, it will complete the function call. the only problem is that it will complete on any com port that is established on the system whether its the bs2 or some other device.
even if you dont know python, some other language or example will help. i thank you all in advance. here is what i have for the python code.
what i've got currently is that it will run through a loop of different device ports, and then when it establishes a connection, it will complete the function call. the only problem is that it will complete on any com port that is established on the system whether its the bs2 or some other device.
even if you dont know python, some other language or example will help. i thank you all in advance. here is what i have for the python code.
def connect(self): device = [noparse][[/noparse]'/dev/tty.usbserial-1B1','COM1','COM2', #mac, win, win 'COM3','COM4','/dev/tty.usbserial-3B1'] #win,win,mac i = 0 for dev in device: try: self.activeSerial = dev i=i+1 print str(i) + " " + dev self.serConn = self.openSerial(dev) if(self.serConn): print "self.serConn", self.serConn break except serial.serialutil.SerialException: self.activeSerial = None self.serConn = None print "activeSerial", self.activeSerial
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
thanks for the advice.