diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index 24d6f0aa0..7ad7326a4 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -78,15 +78,25 @@ def findSerialPorts(isIotMotes=False): tester = SerialTester(probe.portname) tester.setNumTestPkt(1) tester.setTimeout(2) - tester.test(blocking=True) - if tester.getStats()['numOk'] >= 1: - mote_ports.append((port[0],BAUDRATE_LOCAL_BOARD)); + # stop the test as soon as a packet is ok + test=0 + while True: + tester.test(blocking=True) + + if tester.getStats()['numOk'] >= 1: + mote_ports.append((port[0],BAUDRATE_LOCAL_BOARD)); + break + #at most 3 retries + if (test>5): + break; + test = test + 1 + probe.close() probe.join() # log log.info("discovered following COM port: {0}".format(['{0}@{1}'.format(s[0],s[1]) for s in mote_ports])) - + return mote_ports #============================ class ===========================================