@@ -111,7 +111,7 @@ void modbusSlaveDestroy(ModbusSlave *status)
111111 response frame is going to be discarded (when the request was broadcast).
112112
113113 \warning This function expects ModbusSlave::response::pduOffset and
114- ModbusSlave::response::padding to be set properly! If you're looking for a
114+ ModbusSlave::response::padding to be set properly! If you're looking for a
115115 function to manually build an exception please use modbusBuildExceptionPDU(),
116116 modbusBuildExceptionRTU() or modbusBuildExceptionTCP()
117117*/
@@ -147,7 +147,7 @@ LIGHTMODBUS_RET_ERROR modbusBuildExceptionPDU(
147147{
148148 status -> response .pduOffset = 0 ;
149149 status -> response .padding = 0 ;
150-
150+
151151 ModbusErrorInfo err = modbusBuildException (status , function , code );
152152 if (!modbusIsOk (err ))
153153 return err ;
@@ -176,17 +176,17 @@ LIGHTMODBUS_RET_ERROR modbusBuildExceptionRTU(
176176
177177 status -> response .pduOffset = MODBUS_RTU_PDU_OFFSET ;
178178 status -> response .padding = MODBUS_RTU_ADU_PADDING ;
179-
179+
180180 ModbusErrorInfo errinfo = modbusBuildException (status , function , code );
181-
181+
182182 if (!modbusIsOk (errinfo ))
183183 return errinfo ;
184184
185185 ModbusError err = modbusPackRTU (
186186 & status -> response .data [0 ],
187187 status -> response .length ,
188188 address );
189-
189+
190190 // There's literally no reason for modbusPackRTU()
191191 // to return MODBUS_ERROR_LENGTH here
192192 (void ) err ;
@@ -196,7 +196,7 @@ LIGHTMODBUS_RET_ERROR modbusBuildExceptionRTU(
196196
197197/**
198198 \brief Builds a Modbus TCP exception
199- \param transactionID transaction ID
199+ \param transactionID transaction ID
200200 \param unitID unit ID to be reported in the exception
201201 \param function function that reported the exception
202202 \param code Modbus exception code
@@ -213,9 +213,9 @@ LIGHTMODBUS_RET_ERROR modbusBuildExceptionTCP(
213213{
214214 status -> response .pduOffset = MODBUS_TCP_PDU_OFFSET ;
215215 status -> response .padding = MODBUS_TCP_ADU_PADDING ;
216-
216+
217217 ModbusErrorInfo errinfo = modbusBuildException (status , function , code );
218-
218+
219219 if (!modbusIsOk (errinfo ))
220220 return errinfo ;
221221
@@ -240,10 +240,10 @@ LIGHTMODBUS_RET_ERROR modbusBuildExceptionTCP(
240240 \returns Any errors from parsing functions
241241
242242 \warning This function expects ModbusSlave::response::pduOffset and
243- ModbusSlave::response::padding to be set properly! If you're looking for a
243+ ModbusSlave::response::padding to be set properly! If you're looking for a
244244 function to parse PDU and generate a PDU response, please use modbusParseRequestPDU() instead.
245245
246- \warning The response frame can only be accessed if modbusIsOk() called
246+ \warning The response frame can only be accessed if modbusIsOk() called
247247 on the return value of this function evaluates to true.
248248*/
249249LIGHTMODBUS_RET_ERROR modbusParseRequest (ModbusSlave * status , const uint8_t * request , uint8_t requestLength )
@@ -266,7 +266,7 @@ LIGHTMODBUS_RET_ERROR modbusParseRequest(ModbusSlave *status, const uint8_t *req
266266 \returns MODBUS_REQUEST_ERROR(LENGTH) if length of the frame is invalid
267267 \returns Any errors from parsing functions
268268
269- \warning The response frame can only be accessed if modbusIsOk() called
269+ \warning The response frame can only be accessed if modbusIsOk() called
270270 on the return value from this function evaluates to true.
271271
272272 \warning The `requestLength` argument is of type `uint8_t` and not `uint16_t`
@@ -293,15 +293,15 @@ LIGHTMODBUS_RET_ERROR modbusParseRequestPDU(ModbusSlave *status, const uint8_t *
293293 \returns MODBUS_GENERAL_ERROR(LENGTH) if the resulting response frame has invalid length
294294 \returns Any errors from parsing functions
295295
296- \warning The response frame can only be accessed if modbusIsOk() called
296+ \warning The response frame can only be accessed if modbusIsOk() called
297297 on the return value of this function evaluates to true.
298298*/
299299LIGHTMODBUS_RET_ERROR modbusParseRequestRTU (ModbusSlave * status , uint8_t slaveAddress , const uint8_t * request , uint16_t requestLength )
300300{
301301 // Unpack the request
302- const uint8_t * pdu ;
303- uint16_t pduLength ;
304- uint8_t requestAddress ;
302+ const uint8_t * pdu = NULL ;
303+ uint16_t pduLength = 0 ;
304+ uint8_t requestAddress = 0 ;
305305 ModbusError err = modbusUnpackRTU (
306306 request ,
307307 requestLength ,
@@ -323,7 +323,7 @@ LIGHTMODBUS_RET_ERROR modbusParseRequestRTU(ModbusSlave *status, uint8_t slaveAd
323323 modbusBufferModeRTU (& status -> response );
324324 if (!modbusIsOk (errinfo = modbusParseRequest (status , pdu , pduLength )))
325325 return errinfo ;
326-
326+
327327 if (status -> response .length )
328328 {
329329 // Discard any response frames if the request
@@ -343,7 +343,7 @@ LIGHTMODBUS_RET_ERROR modbusParseRequestRTU(ModbusSlave *status, uint8_t slaveAd
343343 if (err != MODBUS_OK )
344344 return MODBUS_MAKE_ERROR (MODBUS_ERROR_SOURCE_GENERAL , err );
345345 }
346-
346+
347347 return MODBUS_NO_ERROR ();
348348}
349349
@@ -356,7 +356,7 @@ LIGHTMODBUS_RET_ERROR modbusParseRequestRTU(ModbusSlave *status, uint8_t slaveAd
356356 \returns MODBUS_GENERAL_ERROR(LENGTH) if the resulting response frame has invalid length
357357 \returns Any errors from parsing functions
358358
359- \warning The response frame can only be accessed if modbusIsOk() called
359+ \warning The response frame can only be accessed if modbusIsOk() called
360360 on the return value of this function evaluates to true.
361361*/
362362LIGHTMODBUS_RET_ERROR modbusParseRequestTCP (ModbusSlave * status , const uint8_t * request , uint16_t requestLength )
@@ -377,7 +377,7 @@ LIGHTMODBUS_RET_ERROR modbusParseRequestTCP(ModbusSlave *status, const uint8_t *
377377
378378 if (err != MODBUS_OK )
379379 return MODBUS_MAKE_ERROR (MODBUS_ERROR_SOURCE_REQUEST , err );
380-
380+
381381 // Parse the request
382382 ModbusErrorInfo errinfo ;
383383 modbusBufferModeTCP (& status -> response );
0 commit comments