mirror of https://github.com/Desuuuu/klipper.git
canbus_ids: Use 4 as the first nodeid to reduce id bitstuffing
Starting with nodeid 4 instead of nodeid 0 can reduce bitstuffing of the id field in common configurations. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
b725d971db
commit
2293e1506f
|
@ -4,6 +4,8 @@
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
NODEID_FIRST = 4
|
||||||
|
|
||||||
class PrinterCANBus:
|
class PrinterCANBus:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
|
@ -11,7 +13,7 @@ class PrinterCANBus:
|
||||||
def add_uuid(self, config, canbus_uuid, canbus_iface):
|
def add_uuid(self, config, canbus_uuid, canbus_iface):
|
||||||
if canbus_uuid in self.ids:
|
if canbus_uuid in self.ids:
|
||||||
raise config.error("Duplicate canbus_uuid")
|
raise config.error("Duplicate canbus_uuid")
|
||||||
new_id = len(self.ids)
|
new_id = len(self.ids) + NODEID_FIRST
|
||||||
self.ids[canbus_uuid] = new_id
|
self.ids[canbus_uuid] = new_id
|
||||||
return new_id
|
return new_id
|
||||||
def get_nodeid(self, canbus_uuid):
|
def get_nodeid(self, canbus_uuid):
|
||||||
|
|
Loading…
Reference in New Issue