mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 20:23:34 +08:00
Mavlink: enable log messages to multiple UARTs
This commit is contained in:
@@ -93,9 +93,6 @@ static Mavlink* _head = nullptr;
|
|||||||
/* TODO: if this is a class member it crashes */
|
/* TODO: if this is a class member it crashes */
|
||||||
static struct file_operations fops;
|
static struct file_operations fops;
|
||||||
|
|
||||||
static struct mavlink_logbuffer lb;
|
|
||||||
static unsigned int total_counter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mavlink app start / stop handling function
|
* mavlink app start / stop handling function
|
||||||
*
|
*
|
||||||
@@ -227,11 +224,11 @@ Mavlink* Mavlink::new_instance()
|
|||||||
::_head = inst;
|
::_head = inst;
|
||||||
/* afterwards follow the next and append the instance */
|
/* afterwards follow the next and append the instance */
|
||||||
} else {
|
} else {
|
||||||
while (next != nullptr) {
|
while (next->_next != nullptr) {
|
||||||
next = next->_next;
|
next = next->_next;
|
||||||
}
|
}
|
||||||
/* now parent has a null pointer, fill it */
|
/* now parent has a null pointer, fill it */
|
||||||
next = inst;
|
next->_next = inst;
|
||||||
}
|
}
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
@@ -288,8 +285,15 @@ Mavlink::mavlink_dev_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|||||||
// printf("logmsg: %s\n", txt);
|
// printf("logmsg: %s\n", txt);
|
||||||
struct mavlink_logmessage msg;
|
struct mavlink_logmessage msg;
|
||||||
strncpy(msg.text, txt, sizeof(msg.text));
|
strncpy(msg.text, txt, sizeof(msg.text));
|
||||||
mavlink_logbuffer_write(&lb, &msg);
|
|
||||||
total_counter++;
|
Mavlink* inst = ::_head;
|
||||||
|
while (inst != nullptr) {
|
||||||
|
|
||||||
|
mavlink_logbuffer_write(&inst->lb, &msg);
|
||||||
|
inst->total_counter++;
|
||||||
|
inst = inst->_next;
|
||||||
|
|
||||||
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1451,7 +1455,7 @@ Mavlink::task_main(int argc, char *argv[])
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
/* initialize mavlink text message buffering */
|
/* initialize mavlink text message buffering */
|
||||||
mavlink_logbuffer_init(&lb, 10);
|
mavlink_logbuffer_init(&lb, 5);
|
||||||
|
|
||||||
int ch;
|
int ch;
|
||||||
const char *device_name = "/dev/ttyS1";
|
const char *device_name = "/dev/ttyS1";
|
||||||
|
|||||||
@@ -293,6 +293,9 @@ private:
|
|||||||
// XXX probably should be in a header...
|
// XXX probably should be in a header...
|
||||||
// extern pthread_t receive_start(int uart);
|
// extern pthread_t receive_start(int uart);
|
||||||
|
|
||||||
|
struct mavlink_logbuffer lb;
|
||||||
|
unsigned int total_counter;
|
||||||
|
|
||||||
pthread_t receive_thread;
|
pthread_t receive_thread;
|
||||||
pthread_t uorb_receive_thread;
|
pthread_t uorb_receive_thread;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user