Commit 7e42fcf024f8b1032b3df6354e15d453869f2e15
1 parent
0c131f83
Fix wrong usleep value to wait 5 ms between bytes in test server
Showing
2 changed files
with
6 additions
and
4 deletions
tests/unit-test-client.c
| @@ -538,7 +538,8 @@ int main(int argc, char *argv[]) | @@ -538,7 +538,8 @@ int main(int argc, char *argv[]) | ||
| 538 | old_response_to_usec); | 538 | old_response_to_usec); |
| 539 | 539 | ||
| 540 | if (use_backend == TCP) { | 540 | if (use_backend == TCP) { |
| 541 | - /* Test server is only able to test byte timeout with the TCP backend */ | 541 | + /* The test server is only able to test byte timeouts with the TCP |
| 542 | + * backend */ | ||
| 542 | 543 | ||
| 543 | /* Timeout of 3ms between bytes */ | 544 | /* Timeout of 3ms between bytes */ |
| 544 | modbus_set_byte_timeout(ctx, 0, 3000); | 545 | modbus_set_byte_timeout(ctx, 0, 3000); |
| @@ -551,7 +552,7 @@ int main(int argc, char *argv[]) | @@ -551,7 +552,7 @@ int main(int argc, char *argv[]) | ||
| 551 | usleep(11 * 5000); | 552 | usleep(11 * 5000); |
| 552 | modbus_flush(ctx); | 553 | modbus_flush(ctx); |
| 553 | 554 | ||
| 554 | - /* Timeout of 10ms between bytes */ | 555 | + /* Timeout of 7ms between bytes */ |
| 555 | modbus_set_byte_timeout(ctx, 0, 7000); | 556 | modbus_set_byte_timeout(ctx, 0, 7000); |
| 556 | rc = modbus_read_registers(ctx, UT_REGISTERS_ADDRESS_BYTE_SLEEP_5_MS, | 557 | rc = modbus_read_registers(ctx, UT_REGISTERS_ADDRESS_BYTE_SLEEP_5_MS, |
| 557 | 1, tab_rp_registers); | 558 | 1, tab_rp_registers); |
tests/unit-test-server.c
| @@ -84,7 +84,8 @@ int main(int argc, char*argv[]) | @@ -84,7 +84,8 @@ int main(int argc, char*argv[]) | ||
| 84 | return -1; | 84 | return -1; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | - /* Unit tests of modbus_mapping_new (tests would not be sufficient if two nb_* were identical) */ | 87 | + /* Unit tests of modbus_mapping_new (tests would not be sufficient if two |
| 88 | + nb_* were identical) */ | ||
| 88 | if (mb_mapping->nb_bits != UT_BITS_ADDRESS + UT_BITS_NB) { | 89 | if (mb_mapping->nb_bits != UT_BITS_ADDRESS + UT_BITS_NB) { |
| 89 | printf("Invalid nb bits (%d != %d)\n", UT_BITS_ADDRESS + UT_BITS_NB, mb_mapping->nb_bits); | 90 | printf("Invalid nb bits (%d != %d)\n", UT_BITS_ADDRESS + UT_BITS_NB, mb_mapping->nb_bits); |
| 90 | modbus_free(ctx); | 91 | modbus_free(ctx); |
| @@ -194,7 +195,7 @@ int main(int argc, char*argv[]) | @@ -194,7 +195,7 @@ int main(int argc, char*argv[]) | ||
| 194 | req[1] = query[1]; | 195 | req[1] = query[1]; |
| 195 | for (i=0; i < req_length; i++) { | 196 | for (i=0; i < req_length; i++) { |
| 196 | printf("(%.2X)", req[i]); | 197 | printf("(%.2X)", req[i]); |
| 197 | - usleep(500); | 198 | + usleep(5000); |
| 198 | send(w_s, (const char*)(req + i), 1, MSG_NOSIGNAL); | 199 | send(w_s, (const char*)(req + i), 1, MSG_NOSIGNAL); |
| 199 | } | 200 | } |
| 200 | continue; | 201 | continue; |