diff options
author | Julian Oes <julian@oes.ch> | 2014-02-12 18:35:45 +0100 |
---|---|---|
committer | Julian Oes <julian@oes.ch> | 2014-02-12 18:35:45 +0100 |
commit | cc5756f61ffa9b84abcbebfcf89d213d99d100d9 (patch) | |
tree | 39b3a0f78845eb6d9eed80f6e4986749d4f0bb07 | |
parent | 3462054f73dda9303fcb1b2b5ba0a6f0882ddbd9 (diff) | |
download | px4-firmware-cc5756f61ffa9b84abcbebfcf89d213d99d100d9.tar.gz px4-firmware-cc5756f61ffa9b84abcbebfcf89d213d99d100d9.tar.bz2 px4-firmware-cc5756f61ffa9b84abcbebfcf89d213d99d100d9.zip |
Mavlink: enable log messages to multiple UARTs
-rw-r--r-- | src/modules/mavlink/mavlink_main.cpp | 20 | ||||
-rw-r--r-- | src/modules/mavlink/mavlink_main.h | 3 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 2585593ea..7e146604b 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -93,9 +93,6 @@ static Mavlink* _head = nullptr; /* TODO: if this is a class member it crashes */ static struct file_operations fops; -static struct mavlink_logbuffer lb; -static unsigned int total_counter; - /** * mavlink app start / stop handling function * @@ -227,11 +224,11 @@ Mavlink* Mavlink::new_instance() ::_head = inst; /* afterwards follow the next and append the instance */ } else { - while (next != nullptr) { + while (next->_next != nullptr) { next = next->_next; } /* now parent has a null pointer, fill it */ - next = inst; + next->_next = inst; } return inst; } @@ -288,8 +285,15 @@ Mavlink::mavlink_dev_ioctl(struct file *filep, int cmd, unsigned long arg) // printf("logmsg: %s\n", txt); struct mavlink_logmessage msg; 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; } @@ -1451,7 +1455,7 @@ Mavlink::task_main(int argc, char *argv[]) fflush(stdout); /* initialize mavlink text message buffering */ - mavlink_logbuffer_init(&lb, 10); + mavlink_logbuffer_init(&lb, 5); int ch; const char *device_name = "/dev/ttyS1"; diff --git a/src/modules/mavlink/mavlink_main.h b/src/modules/mavlink/mavlink_main.h index ce2d2b34a..b812af95a 100644 --- a/src/modules/mavlink/mavlink_main.h +++ b/src/modules/mavlink/mavlink_main.h @@ -293,6 +293,9 @@ private: // XXX probably should be in a header... // extern pthread_t receive_start(int uart); + struct mavlink_logbuffer lb; + unsigned int total_counter; + pthread_t receive_thread; pthread_t uorb_receive_thread; |