nanoMODBUS
nanoMODBUS copied to clipboard
Potential `NMBS_ERROR_INVALID_ARGUMENT` when calling `nmbs_create()`
Following https://github.com/debevv/nanoMODBUS/pull/55 I realized that there was no way to check if the new crc_calc()
function pointer was defined by the user or not, since there is no guarantee that the user initializes the nmbs_platform_conf
struct to zero.
For this reason, with https://github.com/debevv/nanoMODBUS/pull/64 (which marks version 1.18.0), I introduced 2 new _create()
APIs that the user must call to create the nmbs_platform_conf
and nmbs_callbacks
struct, nmbs_platform_conf_create()
and nmbs_callbacks_create()
.
To force the usage of these functions inside old codebases, I introduced a runtime check inside nmbs_create()
and nmbs_server_create()
returning NMBS_ERROR_INVALID_ARGUMENT
when one of these structs is not initialized properly.