Commit a38e976bb2788890bf12f6a528ba87f422be3f77

Authored by Stéphane Raimbault
1 parent 3540cd74

Reduce the length defined for the shortest query and add better comment.

Showing 1 changed file with 10 additions and 2 deletions
modbus/modbus.h
@@ -39,8 +39,16 @@ extern "C" { @@ -39,8 +39,16 @@ extern "C" {
39 #define CHECKSUM_LENGTH_RTU 2 39 #define CHECKSUM_LENGTH_RTU 2
40 #define CHECKSUM_LENGTH_TCP 0 40 #define CHECKSUM_LENGTH_TCP 0
41 41
42 -/* 8 + HEADER_LENGTH_TCP */  
43 -#define MIN_QUERY_LENGTH 14 42 +/* It's not really the minimal length (the real one is report slave ID
  43 + * in RTU (4 bytes)) but it's a convenient size to use in RTU or TCP
  44 + * communications to read many values or write a single one.
  45 + * Maximum between :
  46 + * - HEADER_LENGTH_TCP (6) + slave (1) + function (1) + address (2) +
  47 + * number (2)
  48 + * - HEADER_LENGTH_RTU (0) + slave (1) + function (1) + address (2) +
  49 + * number (2) + CRC (2)
  50 +*/
  51 +#define MIN_QUERY_LENGTH 12
44 52
45 /* Page 102, Application Notes of PI–MBUS–300: 53 /* Page 102, Application Notes of PI–MBUS–300:
46 * The maximum length of the entire message must not exceed 256 54 * The maximum length of the entire message must not exceed 256