-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements sending message to unknown alias (#197)
This PR adds code to support the case when an outgoing message addresses a Node for which we do not have a valid alias in the AliasMap. This can happen in multiple cases, some more frequent than others: - There was a network partition thus we did not see that node at the time when we pre-filled the alias map after startup. - The node purposefully released its alias using an AMR frame (this is standards compliant). - The target node is a virtual node that does not yet exist, such as a train node operated by a command station. The mechanism to do this is the following: - The AliasMap has a new API to listen to all(...) calls. The MessageBuilder sings up for getting notifications like this. - The MessageBuilder class, when seeing a miss in the AliasMap lookup for an outgoing addressed message, will put this message into a queue by destination ID. It emits a global verify node ID for the given target node ID instead of the specific message. - Normally, the target node answers this, and that answer initializes its entry in the AliasMap. - When this new alias is added to the AliasMap, the MessageBuilder is invoked and takes the pending messages out of the queue ("unblocked messages"). - Upon sending *any* outgoing message, the MessageBuilder first flushes any unblocked messages it has in the queue. - An additional mechanism is added to MessageBuilder and CanInterface that allows waking up the output message processing thread when an unblocked message is found ("trigger message"). This is needed because the openlcb library does not make an assumption on what the threading model of the application is. Misc fixes: - makes AliasMap thread-safe. - Fixes some comments. === * Makes the alias map thread safe. Adds a listener API to alias map to know when new aliases are added. * fixup comment. * Makes the MessageBuilder stash away addressed messages where we don't know the destination alias yet. Instead, we emit a VerifyNodeId message. These pending messages are released automatically when the alias definition of the seeked node arrives. Adds a "null message". This message does not turn into any outgoing frame. * Generates a trigger message when an unblocked message is found after an incoming frame.
- Loading branch information
1 parent
9d7e5ce
commit 3b976a1
Showing
5 changed files
with
262 additions
and
15 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
Oops, something went wrong.