47 #include <px4_platform_common/px4_config.h> 48 #include <px4_platform_common/defines.h> 49 #include <px4_platform_common/tasks.h> 54 #include <sys/ioctl.h> 60 #include "../messages.h" 62 #define DEFAULT_UART "/dev/ttyS6"; 69 "usage: hott_telemetry start|status|stop [-d <device>] [-t <timeout ms>] [-r <read delay us>] [-w <write delay us>]";
96 static int send_data(
int uart, uint8_t *buffer,
size_t size);
109 read(uart, &mode,
sizeof(mode));
114 for (
int x = 15; x > 0; x--) {
126 read(uart,
id,
sizeof(*
id));
129 warnx(
"UART timeout on TX/RX port");
141 uint16_t checksum = 0;
143 for (
size_t i = 0; i < size; i++) {
146 buffer[i] = checksum & 0xff;
149 checksum += buffer[i];
152 write(uart, &buffer[i],
sizeof(buffer[i]));
161 read(uart, &dummy, size);
182 for (
int i = 0; i < argc && argv[i]; i++) {
183 if (strcmp(argv[i],
"-d") == 0 || strcmp(argv[i],
"--device") == 0) {
185 device = argv[i + 1];
198 errx(1,
"Failed opening HoTT UART, exiting.");
208 bool connected =
true;
294 for (
int i = 0; i < argc && argv[i]; i++) {
295 if (strcmp(argv[i],
"-t") == 0 || strcmp(argv[i],
"--timeout") == 0) {
304 if (strcmp(argv[i],
"-r") == 0 || strcmp(argv[i],
"--read-delay") == 0) {
313 if (strcmp(argv[i],
"-w") == 0 || strcmp(argv[i],
"--write-delay") == 0) {
323 if (!strcmp(argv[1],
"start")) {
326 warnx(
"already running");
333 SCHED_PRIORITY_DEFAULT,
336 (argv) ? (
char *
const *)&argv[2] : (
char *
const *)NULL);
340 if (!strcmp(argv[1],
"stop")) {
345 if (!strcmp(argv[1],
"status")) {
350 for (
int x = 15; x >= 0; x--) {
354 printf(
"\npoll timeout : %i ms\n",
timeout_ms);
366 warnx(
"not started");
#define BINARY_MODE_REQUEST_ID
static const char daemon_name[]
void build_gam_response(uint8_t *buffer, size_t *size)
#define MAX_MESSAGE_BUFFER_SIZE
__EXPORT int hott_telemetry_main(int argc, char *argv[])
Deamon management function.
perf_counter_t dead_reply
Namespace encapsulating all device framework classes, functions and data.
count the number of times an event occurs
static int thread_running
Deamon status flag.
static void read(bootloader_app_shared_t *pshared)
void perf_reset(perf_counter_t handle)
Reset a performance counter.
void init_sub_messages(void)
void perf_count(perf_counter_t handle)
Count a performance event.
static int send_data(int uart, uint8_t *buffer, size_t size)
static int write_delay_us
static int thread_should_exit
Deamon exit flag.
#define POLL_TIMEOUT_IN_MSECS
void perf_free(perf_counter_t handle)
Free a counter.
static int deamon_task
Handle of deamon task / thread.
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
perf_counter_t reqs_count
#define POST_WRITE_DELAY_IN_USECS
#define POST_READ_DELAY_IN_USECS
int open_uart(const char *device)
void build_eam_response(uint8_t *buffer, size_t *size)
static void write(bootloader_app_shared_t *pshared)
perf_counter_t recon_port
void perf_print_counter(perf_counter_t handle)
Print one performance counter to stdout.
perf_counter_t connect_count
static int recv_req_id(int uart, uint8_t *id)
int hott_telemetry_thread_main(int argc, char *argv[])
Mainloop of daemon.
#define DEFAULT_UART
Serial4.
static uint8_t read_log[16]
void build_gps_response(uint8_t *buffer, size_t *size)
Performance measuring tools.
static const char commandline_usage[]