mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 19:07:45 +08:00
Script cleanup, WIP on mavlink logging
This commit is contained in:
@@ -23,30 +23,6 @@ else
|
|||||||
tone_alarm 2
|
tone_alarm 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
|
||||||
# Check if auto-setup from one of the standard scripts is wanted
|
|
||||||
# SYS_AUTOSTART = 0 means no autostart (default)
|
|
||||||
#
|
|
||||||
if param compare SYS_AUTOSTART 1
|
|
||||||
then
|
|
||||||
sh /etc/init.d/rc.1_fmu_quad_x
|
|
||||||
fi
|
|
||||||
|
|
||||||
if param compare SYS_AUTOSTART 2
|
|
||||||
then
|
|
||||||
sh /etc/init.d/rc.2_fmu_io_quad_x
|
|
||||||
fi
|
|
||||||
|
|
||||||
if param compare SYS_AUTOSTART 30
|
|
||||||
then
|
|
||||||
sh /etc/init.d/rc.30_fmu_io_camflyer
|
|
||||||
fi
|
|
||||||
|
|
||||||
if param compare SYS_AUTOSTART 31
|
|
||||||
then
|
|
||||||
sh /etc/init.d/rc.31_fmu_io_phantom
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Look for an init script on the microSD card.
|
# Look for an init script on the microSD card.
|
||||||
#
|
#
|
||||||
@@ -106,3 +82,42 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check if auto-setup from one of the standard scripts is wanted
|
||||||
|
# SYS_AUTOSTART = 0 means no autostart (default)
|
||||||
|
#
|
||||||
|
if param compare SYS_AUTOSTART 1
|
||||||
|
then
|
||||||
|
sh /etc/init.d/01_fmu_quad_x
|
||||||
|
fi
|
||||||
|
|
||||||
|
if param compare SYS_AUTOSTART 2
|
||||||
|
then
|
||||||
|
sh /etc/init.d/02_io_quad_x
|
||||||
|
fi
|
||||||
|
|
||||||
|
if param compare SYS_AUTOSTART 8
|
||||||
|
then
|
||||||
|
sh /etc/init.d/08_ardrone
|
||||||
|
fi
|
||||||
|
|
||||||
|
if param compare SYS_AUTOSTART 9
|
||||||
|
then
|
||||||
|
sh /etc/init.d/09_ardrone_flow
|
||||||
|
fi
|
||||||
|
|
||||||
|
if param compare SYS_AUTOSTART 10
|
||||||
|
then
|
||||||
|
sh /etc/init.d/10_io_f330
|
||||||
|
fi
|
||||||
|
|
||||||
|
if param compare SYS_AUTOSTART 30
|
||||||
|
then
|
||||||
|
sh /etc/init.d/30_io_camflyer
|
||||||
|
fi
|
||||||
|
|
||||||
|
if param compare SYS_AUTOSTART 31
|
||||||
|
then
|
||||||
|
sh /etc/init.d/31_io_phantom
|
||||||
|
fi
|
||||||
|
|||||||
@@ -41,16 +41,20 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <mavlink/mavlink_log.h>
|
#include <mavlink/mavlink_log.h>
|
||||||
|
|
||||||
|
static FILE* text_recorder_fd = NULL;
|
||||||
|
|
||||||
void mavlink_logbuffer_init(struct mavlink_logbuffer *lb, int size)
|
void mavlink_logbuffer_init(struct mavlink_logbuffer *lb, int size)
|
||||||
{
|
{
|
||||||
lb->size = size;
|
lb->size = size;
|
||||||
lb->start = 0;
|
lb->start = 0;
|
||||||
lb->count = 0;
|
lb->count = 0;
|
||||||
lb->elems = (struct mavlink_logmessage *)calloc(lb->size, sizeof(struct mavlink_logmessage));
|
lb->elems = (struct mavlink_logmessage *)calloc(lb->size, sizeof(struct mavlink_logmessage));
|
||||||
|
text_recorder_fd = fopen("/fs/microsd/text_recorder.txt", "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
int mavlink_logbuffer_is_full(struct mavlink_logbuffer *lb)
|
int mavlink_logbuffer_is_full(struct mavlink_logbuffer *lb)
|
||||||
@@ -82,6 +86,13 @@ int mavlink_logbuffer_read(struct mavlink_logbuffer *lb, struct mavlink_logmessa
|
|||||||
memcpy(elem, &(lb->elems[lb->start]), sizeof(struct mavlink_logmessage));
|
memcpy(elem, &(lb->elems[lb->start]), sizeof(struct mavlink_logmessage));
|
||||||
lb->start = (lb->start + 1) % lb->size;
|
lb->start = (lb->start + 1) % lb->size;
|
||||||
--lb->count;
|
--lb->count;
|
||||||
|
|
||||||
|
if (text_recorder_fd) {
|
||||||
|
fwrite(elem->text, 1, strnlen(elem->text, 50), text_recorder_fd);
|
||||||
|
fputc("\n", text_recorder_fd);
|
||||||
|
fsync(text_recorder_fd);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user