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*
-
1If/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++?Bart van Ingen Schenau– Bart van Ingen Schenau2020-05-15 12:05:08 +00:00Commented May 15, 2020 at 12:05
-
1Not related, but "recieve_data" should be spelt "receive_data"Peter M– Peter M2020-05-15 12:24:37 +00:00Commented May 15, 2020 at 12:24
-
1You 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.)Mat– Mat2020-05-15 12:56:06 +00:00Commented May 15, 2020 at 12:56
-
1Function 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.Robert Harvey– Robert Harvey2020-05-15 15:06:28 +00:00Commented May 15, 2020 at 15:06
-
1But 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.Robert Harvey– Robert Harvey2020-05-15 15:12:21 +00:00Commented May 15, 2020 at 15:12
|
Show 8 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-c