It is avoidable via no. 1 for now, but here is a crash log with my branch in the PR (The crash only happens occasionally when example_cd_access.py runs, so apparently it is a race condition) just for reference--This log event could be considered artificial since the NodeID was entered manually (but demonstrates the issue since the same undefined behavior could occur at the same point in the code after any removal or clearing of the alias maps).
C:\Users\first\git\python-openlcb\openlcb\canbus\canphysicallayer.py:66: UserWarning: [registerFrameReceivedListener] You don't really need to listen to packets. Use pollFrame instead, which will collect and decode packets into frames (this layer communicates to upper layers using physicalLayer.onFrameReceived set by LinkLayer/subclass constructor).
warnings.warn(
QUEUE frames : link up...
[CanLink handleFrameReceived] control_frame=ControlFrame.LinkUp
[CanLink] done calling defineAndReserveAlias.
QUEUED frames : link up...waiting...
[linkStateChange] Link_Layer_Up
SENT frames : link up
This example will exit on failure or complete data.
Requesting memory read. Please wait...
Did not know destination = 09.00.99.03.00.0F on datagram send self.nodeIdToAlias={09.00.99.01.03.FF: 998, 06.01.00.00.C8.FC: 232, 06.01.00.00.C8.44: 123, 06.01.00.00.C3.58: 14, 06.01.00.00.00.03: 3783, 06.01.00.00.D1.FD: 3674}. Ensure recv loop (such as OpenLCBNetwork's _listen thread) is running before and during alias reservation sequence delay. Check previous log messages for an exception that may have ended the recv loop.
nodeIdToAlias updated: {09.00.99.01.03.FF: 998, 06.01.00.00.C8.FC: 232, 06.01.00.00.C8.44: 123, 06.01.00.00.C3.58: 14, 06.01.00.00.00.03: 3783, 06.01.00.00.D1.FD: 3674}
nodeIdToAlias updated: {09.00.99.01.03.FF: 998, 06.01.00.00.C8.FC: 232, 06.01.00.00.C8.44: 123, 06.01.00.00.C3.58: 14, 06.01.00.00.00.03: 3783, 06.01.00.00.D1.FD: 3674, 06.01.00.00.C9.D5: 3565, 09.00.99.03.00.0F: 3456}
Exception in thread Thread-1 (memoryRead):
Traceback (most recent call last):
File "C:\Python312-Win7\Lib\threading.py", line 1075, in _bootstrap_inner
self.run()
File "C:\Python312-Win7\Lib\threading.py", line 1012, in run
self._target(*self._args, **self._kwargs)
File "c:\Users\first\git\python-openlcb\examples\example_cdi_access.py", line 308, in memoryRead
memoryService.requestMemoryRead(memMemo)
File "C:\Users\first\git\python-openlcb\openlcb\memoryservice.py", line 188, in requestMemoryRead
self.requestMemoryReadNext(memo)
File "C:\Users\first\git\python-openlcb\openlcb\memoryservice.py", line 217, in requestMemoryReadNext
self.service.sendDatagram(dgWriteMemo)
File "C:\Users\first\git\python-openlcb\openlcb\datagramservice.py", line 167, in sendDatagram
self.sendDatagramMessage(memo)
File "C:\Users\first\git\python-openlcb\openlcb\datagramservice.py", line 173, in sendDatagramMessage
self.linkLayer.sendMessage(message)
File "C:\Users\first\git\python-openlcb\openlcb\canbus\canlink.py", line 892, in sendMessage
dddAlias = self.nodeIdToAlias[msg.destination]
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 09.00.99.03.00.0F
The issue could be solved via one of:
It is avoidable via no. 1 for now, but here is a crash log with my branch in the PR (The crash only happens occasionally when example_cd_access.py runs, so apparently it is a race condition) just for reference--This log event could be considered artificial since the NodeID was entered manually (but demonstrates the issue since the same undefined behavior could occur at the same point in the code after any removal or clearing of the alias maps).