Add custom flush function feature#108
Conversation
| void nmbs_platform_conf_create(nmbs_platform_conf* platform_conf) { | ||
| memset(platform_conf, 0, sizeof(nmbs_platform_conf)); | ||
| platform_conf->crc_calc = nmbs_crc_calc; | ||
| platform_conf->flush = flush; |
There was a problem hiding this comment.
I did a similar thing, but I try to keep original code
It makes nmbs->platform.flush an optional
static void flush(nmbs_t* nmbs) {
if (nmbs->platform.flush) {
nmbs->platform.flush(nmbs->platform.arg);
} else {
nmbs->platform.read(nmbs->msg.buf, sizeof(nmbs->msg.buf), 0, nmbs->platform.arg);
}
}
|
@debevv Could you please check this PR? |
|
Hi, sorry for the absence. The rest seems all ok |
|
My intention was exactly same as you mentioned in embedded system. |
|
Since we already know that info won't be always available and we really don't use it, I would keep it as a |
|
Merged and fixed. Thank you |
Like in #105, a custom flush function can help reduce the blocking time of the read API, especially when using an intermediate buffer with DMA. I’ll also update my embedded example if this pull request is accepted.
This PR also includes the following minor changes:
__suseconds_tis not available on Apple arm64, so I added an alias for it.launch.jsonconfiguration to debug the tests directly in VS Code using thecppdbgdebugger.tests/nanomodbus_test.cto pass clang-format ci stepI've already ran tests and checked all passed.