From 1c78f2450514d4c9f21d13c8590f1f8d32ed7587 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Sun, 9 Nov 2025 11:09:15 +0100 Subject: [PATCH] Added address claim code --- device.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/device.py b/device.py index 3557d39..443e7d3 100644 --- a/device.py +++ b/device.py @@ -3,6 +3,9 @@ NMEA2000-Gerät - auf dem Bus erkannte Geräte - für das eigene Gerät steht initUid() zur Verfügung +TODO +- logging + """ import time @@ -74,6 +77,62 @@ class Device(): self.NAME = struct.unpack_from(' 0.25: + # recv ist blocking. if timeout reached msg should be None + msg = bus.recv(0.25) + if msg: + baseid = (msg.arbitration_id & 0x3ffff00) >> 8 + pgn = baseid & 0xffff00 + if not pgn == 60928: + continue + dest = baseid & 0x0000ff + if dest == 0xff: + print("Claim detected for 0xff (broadcast)") + if self.NAME > struct.unpack_from(' 0.25): + print("claim seems ok after 250ms") + return claim_ok + def __str__(self): out = f"Device: {self.address} : '{self.product}'\n" out += " NAME: {} ({})\n".format(self.getNAME(), self.NAME)