Big fix for automated connection

This commit is contained in:
Morten Kals
2019-04-21 18:25:37 -07:00
parent 90ebb13ea7
commit e2444761bd

View File

@@ -79,16 +79,25 @@ def find_port(baud, timeout):
version = get_version(sr)
if version != libraryVersion:
if version[0] == 'V' or version == "version":
print("You need to update the version of the Arduino-Python3 ",
"library running on your Arduino. ",
"Flash the prototype sketch again.")
try:
ver = version[0]
except Exception:
ver = ''
if ver == 'V' or version == "version":
print("You need to update the version of the Arduino-Python3",
"library running on your Arduino.")
print("The Arduino sketch is", version)
print("The Python installation is", libraryVersion)
print("Flash the prototype sketch again.")
return sr
else:
log.debug('Bad version {0}. This is not a Shrimp/Arduino!'.format(
version))
sr.close()
continue
# established to be the wrong board
log.debug('Bad version {0}. This is not a Shrimp/Arduino!'.format(
version))
sr.close()
continue
log.info('Using port {0}.'.format(p))
if sr:
return sr
@@ -121,11 +130,21 @@ class Arduino(object):
sr = serial.Serial(port, baud, timeout=timeout)
sr.readline() # wait til board has rebooted and is connected
# check version
if get_version(sr) != libraryVersion:
print("You need to update the version of the Arduino-Python3 ",
"library running on your Arduino. ",
"Flash the prototype sketch again.")
version = get_version(sr)
if version != libraryVersion:
# check version
try:
ver = version[0]
except Exception:
ver = ''
if ver == 'V' or version == "version":
print("You need to update the version of the Arduino-Python3",
"library running on your Arduino.")
print("The Arduino sketch is", version)
print("The Python installation is", libraryVersion)
print("Flash the prototype sketch again.")
sr.flush()
self.sr = sr