Commit 9da1b6ada41e5c2247e932d4c0d1f33a3ad23a66

Authored by Stéphane Raimbault
1 parent 845110db

Rename req_* variables to msg_* in send_msg()

Showing 1 changed file with 6 additions and 6 deletions
src/modbus.c
@@ -140,23 +140,23 @@ static unsigned int compute_response_length_from_request(modbus_t *ctx, uint8_t @@ -140,23 +140,23 @@ static unsigned int compute_response_length_from_request(modbus_t *ctx, uint8_t
140 } 140 }
141 141
142 /* Sends a request/response */ 142 /* Sends a request/response */
143 -static int send_msg(modbus_t *ctx, uint8_t *req, int req_length) 143 +static int send_msg(modbus_t *ctx, uint8_t *msg, int msg_length)
144 { 144 {
145 int rc; 145 int rc;
146 int i; 146 int i;
147 147
148 - req_length = ctx->backend->send_msg_pre(req, req_length); 148 + msg_length = ctx->backend->send_msg_pre(msg, msg_length);
149 149
150 if (ctx->debug) { 150 if (ctx->debug) {
151 - for (i = 0; i < req_length; i++)  
152 - printf("[%.2X]", req[i]); 151 + for (i = 0; i < msg_length; i++)
  152 + printf("[%.2X]", msg[i]);
153 printf("\n"); 153 printf("\n");
154 } 154 }
155 155
156 /* In recovery mode, the write command will be issued until to be 156 /* In recovery mode, the write command will be issued until to be
157 successful! Disabled by default. */ 157 successful! Disabled by default. */
158 do { 158 do {
159 - rc = ctx->backend->send(ctx, req, req_length); 159 + rc = ctx->backend->send(ctx, msg, msg_length);
160 if (rc == -1) { 160 if (rc == -1) {
161 _error_print(ctx, NULL); 161 _error_print(ctx, NULL);
162 if (ctx->error_recovery && 162 if (ctx->error_recovery &&
@@ -167,7 +167,7 @@ static int send_msg(modbus_t *ctx, uint8_t *req, int req_length) @@ -167,7 +167,7 @@ static int send_msg(modbus_t *ctx, uint8_t *req, int req_length)
167 } 167 }
168 } while (ctx->error_recovery && rc == -1); 168 } while (ctx->error_recovery && rc == -1);
169 169
170 - if (rc > 0 && rc != req_length) { 170 + if (rc > 0 && rc != msg_length) {
171 errno = EMBBADDATA; 171 errno = EMBBADDATA;
172 return -1; 172 return -1;
173 } 173 }