I am reading data from a sensor (UBlox receiver), type not super important to the question. My question is, internally how would one manage and design an interface like this. I want to create something similar for my works binary protocol.
I have come across this style of interface across many sensors but haven’t been able to find any words/architecture/designs to investigate and learn more about. Wondering if anyone can point me in the right direction and describe this type of interface.
What I mean in particular is the device (and many devices I have seen) can:
- support user enabling or disabling streaming of certain data during run time. “I want message type 6, 10, and 14, or I don’t want message 8”.
- Change rates of messages. Send message 8 1hz, and message 10 at 20hz.
- Accepting multiple types of input messages.
- Change the output source. So through a serial interface enable/configure a I2C output.
- Logging and streaming of different messages (stream message 6 and 10, but only log 10).
And if we use the ublox receiver example, internally there will be (given gps is my research area) logical units of separation. Doesn’t mean they implemented that way. But let’s say they did. So let’s say internally there are 5 logical units that do different things and exchange data/events between these units. Each responsible for different parts of the processing. However as a user I can request or send data to any of these units (from the supported interface doc). All from the same interface.
How would you handle that internally in code? Obviously there must be a class/object/function to handle just I/O (connecting, read, write). I’m guessing on input the handler pushes out new messages (once validated with checksum and start bytes for example) to all units to see if it’s theirs? This is just a guess since there are 100s of messages and the IO can’t/shouldn’t be processing all of them. Pass them off in their binary form and move on? “Hey I got a message 6, here it is in binary form. Have fun”.
How does the system handle sending data out? Should Each logical unit knows “hey it’s time to send message 8 out”, send it to the I/O manager for writing? Would you also only generate a message type 8 for example if it’s enabled. So send a type 8, in binary form (serialized) to the IO manager?
So I’m wondering if there are any key patterns/styles I can research that this would resemble.
Aucun commentaire:
Enregistrer un commentaire