Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of return values in ModbusServer.h and Arduino Reference does not match source code #120

Open
smacinnes opened this issue Aug 16, 2023 · 0 comments
Labels
topic: documentation Related to documentation for the project type: imperfection Perceived defect in any part of project

Comments

@smacinnes
Copy link

smacinnes commented Aug 16, 2023

The documentation of return values in ModbusServer.h for configure functions are reversed from the actual source code. This error then shows up in the Arduino Reference site.

Comments in src/ModbusServer.h claiming return value of 0 on success, 1 on failure

/**
* Configure the servers coils.
*
* @param startAddress start address of coils
* @param nb number of coils to configure
*
* @return 0 on success, 1 on failure
*/
int configureCoils(int startAddress, int nb);

Source code in src/ModbusServer.cpp showing a return value of 0 on failure, 1 on success:

int ModbusServer::configureCoils(int startAddress, int nb)
{
if (startAddress < 0 || nb < 1) {
errno = EINVAL;
return -1;
}
size_t s = sizeof(_mbMapping.tab_bits[0]) * nb;
_mbMapping.tab_bits = (uint8_t*)realloc(_mbMapping.tab_bits, s);
if (_mbMapping.tab_bits == NULL) {
_mbMapping.start_bits = 0;
_mbMapping.nb_bits = 0;
return 0;
}
memset(_mbMapping.tab_bits, 0x00, s);
_mbMapping.start_bits = startAddress;
_mbMapping.nb_bits = nb;
return 1;
}

Error showing in Arduino Reference:

https://www.arduino.cc/reference/en/libraries/arduinomodbus/modbusserver.configurecoils/

This is the case for:

  • configureCoils()
  • configureDiscreteInputs()
  • configureHoldingRegisters()
  • configureInputRegisters()
  • poll()
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: documentation Related to documentation for the project labels Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: documentation Related to documentation for the project type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

2 participants