Hotfix for mavlink logbuffer, needs another round of validation.

This commit is contained in:
Lorenz Meier 2013-08-31 11:21:57 +02:00
parent ff14a1192c
commit 7292e8c722
2 changed files with 12 additions and 1 deletions

View File

@ -516,7 +516,7 @@ void mavlink_update_system(void)
int mavlink_thread_main(int argc, char *argv[])
{
/* initialize mavlink text message buffering */
mavlink_logbuffer_init(&lb, 5);
mavlink_logbuffer_init(&lb, 2);
int ch;
char *device_name = "/dev/ttyS1";
@ -738,6 +738,9 @@ int mavlink_thread_main(int argc, char *argv[])
/* Reset the UART flags to original state */
tcsetattr(uart, TCSANOW, &uart_config_original);
/* destroy log buffer */
mavlink_logbuffer_destroy(&lb);
thread_running = false;
exit(0);

View File

@ -54,6 +54,14 @@ __EXPORT void mavlink_logbuffer_init(struct mavlink_logbuffer *lb, int size)
lb->elems = (struct mavlink_logmessage *)calloc(lb->size, sizeof(struct mavlink_logmessage));
}
__EXPORT void mavlink_logbuffer_destroy(struct mavlink_logbuffer *lb)
{
lb->size = 0;
lb->start = 0;
lb->count = 0;
free(lb->elems);
}
__EXPORT int mavlink_logbuffer_is_full(struct mavlink_logbuffer *lb)
{
return lb->count == (int)lb->size;