aboutsummaryrefslogtreecommitdiff
path: root/apps/sdlog/sdlog.c
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-01-19 01:31:05 +0100
committerLorenz Meier <lm@inf.ethz.ch>2013-01-19 01:31:05 +0100
commit3128529c3b67e3352de6a483292b74c22dafd377 (patch)
treea78a03b4d7138b6fb8a448927a8d8222f619204a /apps/sdlog/sdlog.c
parentbc35bb23dd8cb035c080f8ef8b4cd7a30d5184c2 (diff)
downloadpx4-firmware-3128529c3b67e3352de6a483292b74c22dafd377.tar.gz
px4-firmware-3128529c3b67e3352de6a483292b74c22dafd377.tar.bz2
px4-firmware-3128529c3b67e3352de6a483292b74c22dafd377.zip
Added logging improvements for microSD
Diffstat (limited to 'apps/sdlog/sdlog.c')
-rw-r--r--apps/sdlog/sdlog.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/apps/sdlog/sdlog.c b/apps/sdlog/sdlog.c
index f8668a2e3..d79343cd9 100644
--- a/apps/sdlog/sdlog.c
+++ b/apps/sdlog/sdlog.c
@@ -319,8 +319,25 @@ sysvector_write_start(struct sdlog_logbuffer *logbuf)
int sdlog_thread_main(int argc, char *argv[])
{
+ /* log every 2nd value (skip one) */
+ int skip_value = 1;
+
+ if (argc > 1) {
+ if (!strcmp(argv[1], "-s") && argc > 2) {
+ int s = atoi(argv[2]);
+
+ if (s > 0 && s < 250) {
+ skip_value = s;
+ } else {
+ warnx("Ignoring skip value of %d, out of range (1..250)\n", s);
+ }
+ }
+ }
+
warnx("starting\n");
+ warnx("skipping %d sensor packets between logged packets.\n", skip_value);
+
if (file_exist(mountpoint) != OK) {
errx(1, "logging mount point %s not present, exiting.", mountpoint);
}
@@ -565,8 +582,6 @@ int sdlog_thread_main(int argc, char *argv[])
gyro_fd.fd = subs.sensor_sub;
gyro_fd.events = POLLIN;
- /* log every 2nd value (skip one) */
- int skip_value = 0;
/* track skipping */
int skip_count = 0;
@@ -717,7 +732,10 @@ int sdlog_thread_main(int argc, char *argv[])
pthread_mutex_lock(&sysvector_mutex);
sdlog_logbuffer_write(&lb, &sysvect);
/* signal the other thread new data, but not yet unlock */
- pthread_cond_signal(&sysvector_cond);
+ if (lb.count > lb.size / 3) {
+ /* only request write if several packets can be written at once */
+ pthread_cond_signal(&sysvector_cond);
+ }
/* unlock, now the writer thread may run */
pthread_mutex_unlock(&sysvector_mutex);
}