Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

13
  • 1
    If/when you support both TCP and Serial communications, do you want to support that from a single executable via configuration, or do you want that as separate executables? How comfortable would you be designing this in a language that supports OO like C++? Commented May 15, 2020 at 12:05
  • 1
    Not related, but "recieve_data" should be spelt "receive_data" Commented May 15, 2020 at 12:24
  • 1
    You might want to look at C plugin systems - what you're doing seems very similar or could be implemented this way. The Linux VFS layer is another example, with the filesystems being "plugged in" to the system with a "simple" interface. (I'm not saying filesystem code is simple. The registration interface is straightforward though.) Commented May 15, 2020 at 12:56
  • 1
    Function pointers are awesome. I don't think you should worry about performance; a function pointer is going to have essentially the same overhead as calling a function directly. Commented May 15, 2020 at 15:06
  • 1
    But to answer your question directly, if you're looking for runtime polymorphism (i.e. the processing of a message changes depending on its type), function pointers seem like a good way to go. No elaborate plugin system required. You could even write a factory method that accepts a "message type" and returns a function pointer to the correct processor function. Commented May 15, 2020 at 15:12