diff --git a/openlcb/localnodeprocessor.py b/openlcb/localnodeprocessor.py index 93f84fb..8c2dcd1 100644 --- a/openlcb/localnodeprocessor.py +++ b/openlcb/localnodeprocessor.py @@ -65,7 +65,7 @@ def process(self, message, givenNode=None): MTI.Optional_Interaction_Rejected): self.errorMessageReceived(message, node) else: - self.unrecognizedMTI(message, node) + self._unrecognizedMTI(message, node) return False # private method @@ -123,11 +123,10 @@ def identifyEventsAddressed(self, message, node): ''' return - def unrecognizedMTI(self, message, node): + def _unrecognizedMTI(self, message, node): '''Handle a message with an unrecognized MTI by returning OptionalInteractionRejected ''' - # FIXME: should be private method. Add _ to start of method name. # special case of unknown MTI from lower level unknownAddressed = False diff --git a/openlcb/memoryservice.py b/openlcb/memoryservice.py index 8675355..bd3ed43 100644 --- a/openlcb/memoryservice.py +++ b/openlcb/memoryservice.py @@ -296,9 +296,9 @@ def arrayToUInt64(self, data): 64-bit int Returns: - int: The converted data as a number. + int: The converted data as a number (Python determines + actual in-memory size based on the value). """ - # FIXME: Python resizes ints automatically based on value. result = 0 for index in range(0, len(data)): result = result << 8 diff --git a/openlcb/remotenodeprocessor.py b/openlcb/remotenodeprocessor.py index 3170e59..81c66cf 100644 --- a/openlcb/remotenodeprocessor.py +++ b/openlcb/remotenodeprocessor.py @@ -42,34 +42,33 @@ def process(self, message, node) : node.state = Node.State.Initialized # in case we came late to the party, must be in Initialized state # noqa: E501 # specific message handling - match message.mti : - case MTI.Initialization_Complete | MTI.Initialization_Complete_Simple : # noqa: E501 - self.initializationComplete(message, node) - return True - case MTI.Protocol_Support_Reply : - self.protocolSupportReply(message, node) - return True - case MTI.Link_Layer_Up : - self.linkUpMessage(message, node) - case MTI.Link_Layer_Down : - self.linkDownMessage(message, node) - case MTI.Simple_Node_Ident_Info_Request : - self.simpleNodeIdentInfoRequest(message, node) - case MTI.Simple_Node_Ident_Info_Reply : - self.simpleNodeIdentInfoReply(message, node) - return True - case MTI.Producer_Identified_Active | MTI.Producer_Identified_Inactive | MTI.Producer_Identified_Unknown | MTI.Producer_Consumer_Event_Report : # noqa: E501 - self.producedEventIndicated(message, node) - return True - case MTI.Consumer_Identified_Active | MTI.Consumer_Identified_Inactive | MTI.Consumer_Identified_Unknown : # noqa: E501 - self.consumedEventIndicated(message, node) - return True - case MTI.New_Node_Seen : - self.newNodeSeen(message, node) - return True - case _ : - # we ignore others - return False + if message.mti in (MTI.Initialization_Complete, MTI.Initialization_Complete_Simple) : # noqa: E501 + self.initializationComplete(message, node) + return True + elif message.mti == MTI.Protocol_Support_Reply : + self.protocolSupportReply(message, node) + return True + elif message.mti == MTI.Link_Layer_Up : + self.linkUpMessage(message, node) + elif message.mti == MTI.Link_Layer_Down : + self.linkDownMessage(message, node) + elif message.mti == MTI.Simple_Node_Ident_Info_Request : + self.simpleNodeIdentInfoRequest(message, node) + elif message.mti == MTI.Simple_Node_Ident_Info_Reply : + self.simpleNodeIdentInfoReply(message, node) + return True + elif message.mti in (MTI.Producer_Identified_Active, MTI.Producer_Identified_Inactive, MTI.Producer_Identified_Unknown, MTI.Producer_Consumer_Event_Report) : # noqa: E501 + self.producedEventIndicated(message, node) + return True + elif message.mti in (MTI.Consumer_Identified_Active, MTI.Consumer_Identified_Inactive, MTI.Consumer_Identified_Unknown) : # noqa: E501 + self.consumedEventIndicated(message, node) + return True + elif message.mti == MTI.New_Node_Seen : + self.newNodeSeen(message, node) + return True + else : + # we ignore others + return False return False def initializationComplete(self, message, node) : diff --git a/tests/test_physicallayer.py b/tests/test_physicallayer.py index 89d1a03..a9c234b 100644 --- a/tests/test_physicallayer.py +++ b/tests/test_physicallayer.py @@ -7,7 +7,7 @@ class TestPhysicalLayerClass(unittest.TestCase): def testExample(self): - # FIXME: finish this + # TODO: Test what is possible without hardware. pass