mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-26 00:50:35 +08:00
micrortps_client: more cleanup
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user