Add PGN keyed sniffing callbacks and passive transport protocol reassembly - #709
Open
sujandumaru wants to merge 2 commits into
Open
Add PGN keyed sniffing callbacks and passive transport protocol reassembly#709sujandumaru wants to merge 2 commits into
sujandumaru wants to merge 2 commits into
Conversation
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Describe your changes
This is the first part of #297. It adds a sniffing callback surface on
CANNetworkManager, and also a passive observer which reassembles the destination specific transport protocol messages that are sent between two external control functions.add_sniffed_message_callback(pgn, callback, parent)and its remove onCANNetworkManager. They are shaped likeadd_any_control_function_parameter_group_number_callback, only without the destination filter. The existing callback families are not touched.is_sniffed_parameter_group_number_of_interest(pgn)tells if somebody asked for a PGN or not. This is what makes the sniffing enabled implicitly, like we discussed, so there is no new configuration option. Registering the first callback is the switch.TransportProtocolSniffer, one per channel. It follows RTS, CTS, DT and EOMACK between two external control functions and gives the assembled message to those callbacks. It is passive by construction and not by a flag, because the class does not hold any send frame callback at all, so nothing inside it can answer somebody else connection with a CTS or an abort. I did not want to thread a passive bool throughTransportProtocolManager, because one mistake there will put frames on a real machine bus.T2_T3_TIMEOUT_MSof silence.How has this been tested?
11 new tests in
test/core_network_management_tests.cpp, on the network manager level withVirtualCAN. They cover the callback surface, the assembled BAM and connection mode paths, and every way that a passive session can be dropped.Out of scope
MAX_PROTOCOL_DATA_LENGTHis around 117 MB, so passively assembling a transfer which nobody asked for is a real memory hazard on a microcontroller. TP is bounded to 1785 bytes per session, that is why it is safe to ship it alone. Need some more discussion on how to handle ETP.message.get_source_control_function()in two lines, so I did not want to add the API surface speculatively.