-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds the safety checks on Factory Reset datagrams that are in the standard. Specifically, a factory reset datagram payload is supposed to carry the node ID that is being factory reset. This PR enforces this argument to be present and correct. Adds provisions for virtual nodes when factory resets are happening. Specifically, a virtual node's factory reset does NOT invoke the stack's config update / factory reset feature. This is important for command stations, because factory resetting a locomotive node is not intended to lose all the command station's settings. A weak function is added as a hook to implement some application-specific factory reset mechanism for virtual nodes, but the default implementation is to reject the datagram. Adds implementation for factory reset command to MemoryConfigClient. This is needed for user interfaces to send factory reset commands to openlcb targets. Misc / dependency: - Adds a function `get_default_node_id()` on the abstract If object. This function returns the node ID of the default node on an interface. For single-node interfaces like SimpleStack this is always the same as the node ID of that single node. === * Adds a virtual function to If object called `get_default_node_id`. This function returns the node ID of the default node on an interface. For single-node interfaces like SimpleStack this is always the same as the node ID of that single node. Generally SimpleStack takes a NodeID on the constructor, and that node ID is returned. This is well defined, because a default node ID is needed for both CAN and TCP interfaces by the transport standard: - The CAN interface needs a node ID while allocating aliases. - The TCP interface needs to add a last gateway node ID into every message header. * Updates to the handle factory reset function: - separates to a standard implementation and an application specific weak implementation. - adds openlcb error code as return - add the node ID that is being factory reset as an argument - The standard function delegates to the app function if it detects that a non-default node is being factory reset (virtual node on the same interface) - the config service factoy reset is only called when the default node is being factory reset. * Adds standard safety check to factory reset command carrying a node ID argument. The standard requires the factory reset datagram to contain a redundant parameter which repeats the target node's node ID. This PR checks that this parameter is supplied and correctly filled in. * Adds unit test for factory reset of a virtual node. * Adds support to MemoryConfigClient for sending factory reset command. This is different from generic metadata command because there might be no currently known remote node ID. Therefore the system uses a node ID lookup flow as well. * Adds unit tests covering the special cases in the memory config client for sending factory reset datagrams. * fix whitespace
- Loading branch information
1 parent
6aac408
commit e40bcd6
Showing
14 changed files
with
393 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.