Selaa lähdekoodia

Prefix hexadecimal values with 0x to avoid confusion

Stéphane Raimbault 10 vuotta sitten
vanhempi
commit
9c809805f9
2 muutettua tiedostoa jossa 12 lisäystä ja 12 poistoa
  1. 1 1
      src/modbus-rtu.c
  2. 11 11
      src/modbus.c

+ 1 - 1
src/modbus-rtu.c

@@ -389,7 +389,7 @@ static int _modbus_rtu_check_integrity(modbus_t *ctx, uint8_t *msg,
         return msg_length;
     } else {
         if (ctx->debug) {
-            fprintf(stderr, "ERROR CRC received %0X != CRC calculated %0X\n",
+            fprintf(stderr, "ERROR CRC received 0x%0X != CRC calculated 0x%0X\n",
                     crc_received, crc_calculated);
         }
 

+ 11 - 11
src/modbus.c

@@ -725,7 +725,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
                 MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp);
         } else if ((address + nb) > mb_mapping->nb_bits) {
             if (ctx->debug) {
-                fprintf(stderr, "Illegal data address %0X in read_bits\n",
+                fprintf(stderr, "Illegal data address 0x%0X in read_bits\n",
                         address + nb);
             }
             rsp_length = response_exception(
@@ -758,7 +758,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
                 MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp);
         } else if ((address + nb) > mb_mapping->nb_input_bits) {
             if (ctx->debug) {
-                fprintf(stderr, "Illegal data address %0X in read_input_bits\n",
+                fprintf(stderr, "Illegal data address 0x%0X in read_input_bits\n",
                         address + nb);
             }
             rsp_length = response_exception(
@@ -789,7 +789,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
                 MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp);
         } else if ((address + nb) > mb_mapping->nb_registers) {
             if (ctx->debug) {
-                fprintf(stderr, "Illegal data address %0X in read_registers\n",
+                fprintf(stderr, "Illegal data address 0x%0X in read_registers\n",
                         address + nb);
             }
             rsp_length = response_exception(
@@ -825,7 +825,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
                 MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp);
         } else if ((address + nb) > mb_mapping->nb_input_registers) {
             if (ctx->debug) {
-                fprintf(stderr, "Illegal data address %0X in read_input_registers\n",
+                fprintf(stderr, "Illegal data address 0x%0X in read_input_registers\n",
                         address + nb);
             }
             rsp_length = response_exception(
@@ -847,7 +847,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
         if (address >= mb_mapping->nb_bits) {
             if (ctx->debug) {
                 fprintf(stderr,
-                        "Illegal data address %0X in write_bit\n",
+                        "Illegal data address 0x%0X in write_bit\n",
                         address);
             }
             _sleep_response_timeout(ctx);
@@ -865,7 +865,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
             } else {
                 if (ctx->debug) {
                     fprintf(stderr,
-                            "Illegal data value %0X in write_bit request at address %0X\n",
+                            "Illegal data value 0x%0X in write_bit request at address %0X\n",
                             data, address);
                 }
                 rsp_length = response_exception(
@@ -877,7 +877,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
     case MODBUS_FC_WRITE_SINGLE_REGISTER:
         if (address >= mb_mapping->nb_registers) {
             if (ctx->debug) {
-                fprintf(stderr, "Illegal data address %0X in write_register\n",
+                fprintf(stderr, "Illegal data address 0x%0X in write_register\n",
                         address);
             }
             _sleep_response_timeout(ctx);
@@ -912,7 +912,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
                 MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp);
         } else if ((address + nb) > mb_mapping->nb_bits) {
             if (ctx->debug) {
-                fprintf(stderr, "Illegal data address %0X in write_bits\n",
+                fprintf(stderr, "Illegal data address 0x%0X in write_bits\n",
                         address + nb);
             }
             rsp_length = response_exception(
@@ -947,7 +947,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
                 MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp);
         } else if ((address + nb) > mb_mapping->nb_registers) {
             if (ctx->debug) {
-                fprintf(stderr, "Illegal data address %0X in write_registers\n",
+                fprintf(stderr, "Illegal data address 0x%0X in write_registers\n",
                         address + nb);
             }
             rsp_length = response_exception(
@@ -995,7 +995,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
     case MODBUS_FC_MASK_WRITE_REGISTER:
         if (address >= mb_mapping->nb_registers) {
             if (ctx->debug) {
-                fprintf(stderr, "Illegal data address %0X in write_register\n",
+                fprintf(stderr, "Illegal data address 0x%0X in write_register\n",
                         address);
             }
             rsp_length = response_exception(
@@ -1036,7 +1036,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
                    (address_write + nb_write) > mb_mapping->nb_registers) {
             if (ctx->debug) {
                 fprintf(stderr,
-                        "Illegal data read address %0X or write address %0X write_and_read_registers\n",
+                        "Illegal data read address 0x%0X or write address 0x%0X write_and_read_registers\n",
                         address + nb, address_write + nb_write);
             }
             rsp_length = response_exception(ctx, &sft,