|
@@ -34,10 +34,10 @@ int test_raw_request(modbus_t *, int);
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
int main(int argc, char *argv[])
|
|
{
|
|
{
|
|
- uint8_t *tab_rp_bits;
|
|
|
|
- uint16_t *tab_rp_registers;
|
|
|
|
- uint16_t *tab_rp_registers_bad;
|
|
|
|
- modbus_t *ctx;
|
|
|
|
|
|
+ uint8_t *tab_rp_bits = NULL;
|
|
|
|
+ uint16_t *tab_rp_registers = NULL;
|
|
|
|
+ uint16_t *tab_rp_registers_bad = NULL;
|
|
|
|
+ modbus_t *ctx = NULL;
|
|
int i;
|
|
int i;
|
|
uint8_t value;
|
|
uint8_t value;
|
|
int nb_points;
|
|
int nb_points;
|
|
@@ -46,6 +46,8 @@ int main(int argc, char *argv[])
|
|
uint32_t ireal;
|
|
uint32_t ireal;
|
|
uint32_t old_response_to_sec;
|
|
uint32_t old_response_to_sec;
|
|
uint32_t old_response_to_usec;
|
|
uint32_t old_response_to_usec;
|
|
|
|
+ uint32_t new_response_to_sec;
|
|
|
|
+ uint32_t new_response_to_usec;
|
|
uint32_t old_byte_to_sec;
|
|
uint32_t old_byte_to_sec;
|
|
uint32_t old_byte_to_usec;
|
|
uint32_t old_byte_to_usec;
|
|
int use_backend;
|
|
int use_backend;
|
|
@@ -86,11 +88,24 @@ int main(int argc, char *argv[])
|
|
modbus_set_slave(ctx, SERVER_ID);
|
|
modbus_set_slave(ctx, SERVER_ID);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ modbus_get_response_timeout(ctx, &old_response_to_sec, &old_response_to_usec);
|
|
if (modbus_connect(ctx) == -1) {
|
|
if (modbus_connect(ctx) == -1) {
|
|
fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno));
|
|
fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno));
|
|
modbus_free(ctx);
|
|
modbus_free(ctx);
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+ modbus_get_response_timeout(ctx, &new_response_to_sec, &new_response_to_usec);
|
|
|
|
+
|
|
|
|
+ printf("** UNIT TESTING **\n");
|
|
|
|
+
|
|
|
|
+ printf("1/1 No response timeout modification on connect: ");
|
|
|
|
+ if (old_response_to_sec == new_response_to_sec &&
|
|
|
|
+ old_response_to_usec == new_response_to_usec) {
|
|
|
|
+ printf("OK\n");
|
|
|
|
+ } else {
|
|
|
|
+ printf("FAILED\n");
|
|
|
|
+ goto close;
|
|
|
|
+ }
|
|
|
|
|
|
/* Allocate and initialize the memory to store the bits */
|
|
/* Allocate and initialize the memory to store the bits */
|
|
nb_points = (UT_BITS_NB > UT_INPUT_BITS_NB) ? UT_BITS_NB : UT_INPUT_BITS_NB;
|
|
nb_points = (UT_BITS_NB > UT_INPUT_BITS_NB) ? UT_BITS_NB : UT_INPUT_BITS_NB;
|
|
@@ -103,8 +118,6 @@ int main(int argc, char *argv[])
|
|
tab_rp_registers = (uint16_t *) malloc(nb_points * sizeof(uint16_t));
|
|
tab_rp_registers = (uint16_t *) malloc(nb_points * sizeof(uint16_t));
|
|
memset(tab_rp_registers, 0, nb_points * sizeof(uint16_t));
|
|
memset(tab_rp_registers, 0, nb_points * sizeof(uint16_t));
|
|
|
|
|
|
- printf("** UNIT TESTING **\n");
|
|
|
|
-
|
|
|
|
printf("\nTEST WRITE/READ:\n");
|
|
printf("\nTEST WRITE/READ:\n");
|
|
|
|
|
|
/** COIL BITS **/
|
|
/** COIL BITS **/
|