More sensible sorting of baudrates for auto detect
115200 is the most likely baudrate candidate for printers, followed by 250000. Any additional baudrates that were configured are even more likely.
This commit is contained in:
parent
78724163b1
commit
dffb33727d
2 changed files with 15 additions and 12 deletions
|
|
@ -78,8 +78,8 @@ def _get_options():
|
|||
default_profile = printerProfileManager.get_default()
|
||||
|
||||
options = dict(
|
||||
ports=connection_options["ports"],
|
||||
baudrates=connection_options["baudrates"],
|
||||
ports=sorted(connection_options["ports"]),
|
||||
baudrates=sorted(connection_options["baudrates"], reverse=True),
|
||||
printerProfiles=[dict(id=printer_profile["id"], name=printer_profile["name"] if "name" in printer_profile else printer_profile["id"]) for printer_profile in profile_options.values() if "id" in printer_profile],
|
||||
portPreference=connection_options["portPreference"],
|
||||
baudratePreference=connection_options["baudratePreference"],
|
||||
|
|
|
|||
|
|
@ -165,21 +165,24 @@ def serialList():
|
|||
return baselist
|
||||
|
||||
def baudrateList():
|
||||
ret = [250000, 230400, 115200, 57600, 38400, 19200, 9600]
|
||||
# sorted by likelihood
|
||||
candidates = [115200, 250000, 230400, 57600, 38400, 19200, 9600]
|
||||
|
||||
# additional baudrates prepended, sorted descending
|
||||
additionalBaudrates = settings().get(["serial", "additionalBaudrates"])
|
||||
for additional in additionalBaudrates:
|
||||
for additional in sorted(additionalBaudrates, reverse=True):
|
||||
try:
|
||||
ret.append(int(additional))
|
||||
candidates.insert(0, int(additional))
|
||||
except:
|
||||
_logger.warn("{} is not a valid additional baudrate, ignoring it".format(additional))
|
||||
|
||||
ret.sort(reverse=True)
|
||||
|
||||
# last used baudrate = first to try, move to start
|
||||
prev = settings().getInt(["serial", "baudrate"])
|
||||
if prev in ret:
|
||||
ret.remove(prev)
|
||||
ret.insert(0, prev)
|
||||
return ret
|
||||
if prev in candidates:
|
||||
candidates.remove(prev)
|
||||
candidates.insert(0, prev)
|
||||
|
||||
return candidates
|
||||
|
||||
gcodeToEvent = {
|
||||
# pause for user input
|
||||
|
|
@ -2033,7 +2036,7 @@ class MachineCom(object):
|
|||
results = self._process_command_phase("queuing", cmd, cmd_type, gcode=gcode)
|
||||
|
||||
if not results:
|
||||
# commnd is no more, return
|
||||
# command is no more, return
|
||||
return False
|
||||
else:
|
||||
results = [(cmd, cmd_type, gcode)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue