-
Notifications
You must be signed in to change notification settings - Fork 131
Open
Labels
topic: documentationRelated to documentation for the projectRelated to documentation for the projecttype: imperfectionPerceived defect in any part of projectPerceived defect in any part of project
Description
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
ArduinoModbus/src/ModbusServer.h
Lines 32 to 40 in 12c32ce
/** | |
* 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:
ArduinoModbus/src/ModbusServer.cpp
Lines 53 to 77 in 12c32ce
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
Labels
topic: documentationRelated to documentation for the projectRelated to documentation for the projecttype: imperfectionPerceived defect in any part of projectPerceived defect in any part of project