Skip to content

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

Open
@smacinnes

Description

@smacinnes

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()

Additional context

Additional reports

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: documentationRelated to documentation for the projecttype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions