micrortps_client: more cleanup

This commit is contained in:
TSC21
2019-11-23 17:37:36 +00:00
committed by Nuno Marques
parent ec0803815e
commit d80da97ef5
4 changed files with 29 additions and 39 deletions
@@ -60,7 +60,7 @@
#define DEFAULT_SEND_PORT 2020
void *send(void *data);
void micrortps_start_topics(struct timespec &begin, int &total_read, uint32_t &received, int &loop);
void micrortps_start_topics(struct timespec &begin, uint64_t &total_read, uint64_t &received, int &loop);
struct baudtype {
speed_t code;
@@ -74,14 +74,14 @@ struct options {
};
eTransports transport = options::eTransports::UART;
char device[64] = DEVICE;
uint32_t update_time_ms = UPDATE_TIME_MS;
int loops = LOOPS;
uint32_t sleep_ms = SLEEP_MS;
uint32_t baudrate = BAUDRATE;
uint32_t poll_ms = POLL_MS;
char ip[16] = IP;
uint16_t recv_port = DEFAULT_RECV_PORT;
uint16_t send_port = DEFAULT_SEND_PORT;
uint32_t update_time_ms = UPDATE_TIME_MS;
uint32_t sleep_ms = SLEEP_MS;
uint32_t baudrate = BAUDRATE;
uint32_t poll_ms = POLL_MS;
int loops = LOOPS;
};
extern struct options _options;
@@ -153,23 +153,22 @@ static int micrortps_start(int argc, char *argv[])
return -1;
}
struct timespec begin;
int total_read = 0, loop = 0;
uint32_t received = 0;
micrortps_start_topics(begin, total_read, received, loop);
struct timespec end;
uint64_t total_read = 0, received = 0;
int loop = 0;
micrortps_start_topics(begin, total_read, received, loop);
px4_clock_gettime(CLOCK_REALTIME, &end);
double elapsed_secs = double(end.tv_sec - begin.tv_sec) + double(end.tv_nsec - begin.tv_nsec) / double(1000000000);
double elapsed_secs = static_cast<double>(end.tv_sec - begin.tv_sec + (end.tv_nsec - begin.tv_nsec) / 1e9);
PX4_INFO("RECEIVED: %lu messages in %d LOOPS, %d bytes in %.03f seconds - %.02fKB/s",
(unsigned long)received, loop, total_read, elapsed_secs, (double)total_read / (1000 * elapsed_secs));
PX4_INFO("RECEIVED: %" PRIu64 " messages in %d LOOPS, %" PRIu64 " bytes in %.03f seconds - %.02fKB/s",
received, loop, total_read, elapsed_secs, static_cast<double>(total_read / (1e3 * elapsed_secs)));
delete transport_node;
@@ -235,11 +234,9 @@ int micrortps_client_main(int argc, char *argv[])
if (nullptr != transport_node) { transport_node->close(); }
_rtps_task = -1;
return 0;
}
usage(argv[0]);
return -1;
}