Bladeren bron

Minor comment improvements

Stéphane Raimbault 11 jaren geleden
bovenliggende
commit
558538ab5b
2 gewijzigde bestanden met toevoegingen van 4 en 6 verwijderingen
  1. 4 4
      src/modbus-rtu.c
  2. 0 2
      src/modbus.c

+ 4 - 4
src/modbus-rtu.c

@@ -351,7 +351,7 @@ static int _modbus_rtu_pre_check_confirmation(modbus_t *ctx, const uint8_t *req,
     if (req[0] != rsp[0] && req[0] != MODBUS_BROADCAST_ADDRESS) {
         if (ctx->debug) {
             fprintf(stderr,
-                    "The responding slave %d isn't the requested slave %d",
+                    "The responding slave %d isn't the requested slave %d\n",
                     rsp[0], req[0]);
         }
         errno = EMBBADSLAVE;
@@ -371,13 +371,13 @@ static int _modbus_rtu_check_integrity(modbus_t *ctx, uint8_t *msg,
     uint16_t crc_received;
     int slave = msg[0];
 
-    /* Filter on the Modbus unit identifier (slave) in RTU mode */
+    /* Filter on the Modbus unit identifier (slave) in RTU mode to avoid useless
+     * CRC computing. */
     if (slave != ctx->slave && slave != MODBUS_BROADCAST_ADDRESS) {
-        /* Ignores the request (not for me) */
         if (ctx->debug) {
             printf("Request for slave %d ignored (not %d)\n", slave, ctx->slave);
         }
-
+        /* Following call to check_confirmation handles this error */
         return 0;
     }
 

+ 0 - 2
src/modbus.c

@@ -1468,8 +1468,6 @@ int modbus_write_and_read_registers(modbus_t *ctx,
             return -1;
 
         offset = ctx->backend->header_length;
-
-        /* If rc is negative, the loop is jumped ! */
         for (i = 0; i < rc; i++) {
             /* shift reg hi_byte to temp OR with lo_byte */
             dest[i] = (rsp[offset + 2 + (i << 1)] << 8) |