This may be a broad question but I have not been able to find an answer.
In my program I am communicating to a device over serial communication. The data coming through is binary, and formatted with some header/length/checksum bytes. I can decode the data fine, the part I am stuck on is what is a good practice on distributing that data to parts of the program.
In this example lets say there are 10 different message types, that the serial port can receive. Module A in the program wants Messages 1 to 5, and Module B wants messages 6 to 10.
When the serial port finds a valid message, how should it notify Module A and Module B?
Right now I am implementing it by registering callbacks for any module that wants serial data, and send the message to all modules registered, whether its for them or not. I am curious if there is a more accepted design/architecture for this type of problem.
I will have to do the same thing with CAN and ethernet devices, so wanted to try and get this implemented correctly. I am currently working in C.