Module: xenomai-abe Branch: analogy Commit: ca9d1cd854430b9bcff24bebd88826d4876bfb5b URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=ca9d1cd854430b9bcff24bebd88826d4876bfb5b
Author: Alexis Berlemont <alexis.berlem...@gmail.com> Date: Tue May 10 23:55:29 2011 +0200 analogy: update cmd_read and cmd_write with a wake-count option --- src/utils/analogy/cmd_read.c | 22 +++++++++++++++++++++- src/utils/analogy/cmd_write.c | 32 +++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/utils/analogy/cmd_read.c b/src/utils/analogy/cmd_read.c index e23bf9b..ff8bb48 100644 --- a/src/utils/analogy/cmd_read.c +++ b/src/utils/analogy/cmd_read.c @@ -54,6 +54,7 @@ static unsigned int chans[MAX_NB_CHAN]; static int verbose = 0; static int real_time = 0; static int use_mmap = 0; +static unsigned long wake_count = 0; static RT_TASK rt_task_desc; @@ -84,6 +85,7 @@ struct option cmd_read_opts[] = { {"channels", required_argument, NULL, 'c'}, {"mmap", no_argument, NULL, 'm'}, {"raw", no_argument, NULL, 'w'}, + {"wake-count", required_argument, NULL, 'k'}, {"help", no_argument, NULL, 'h'}, {0}, }; @@ -101,6 +103,9 @@ void do_print_usage(void) fprintf(stdout, "\t\t -c, --channels: channels to use (ex.: -c 0,1)\n"); fprintf(stdout, "\t\t -m, --mmap: mmap the buffer\n"); fprintf(stdout, "\t\t -w, --raw: dump data in raw format\n"); + fprintf(stdout, + "\t\t -k, --wake-count: " + "space available before waking up the process\n"); fprintf(stdout, "\t\t -h, --help: print this help\n"); } @@ -193,7 +198,8 @@ int main(int argc, char *argv[]) /* Compute arguments */ while ((ret = getopt_long(argc, argv, - "vrd:s:S:c:mwh", cmd_read_opts, NULL)) >= 0) { + "vrd:s:S:c:mwk:h", + cmd_read_opts, NULL)) >= 0) { switch (ret) { case 'v': verbose = 1; @@ -219,6 +225,9 @@ int main(int argc, char *argv[]) case 'w': dump_function = dump_raw; break; + case 'k': + wake_count = strtoul(optarg, NULL, 0); + break; case 'h': default: do_print_usage(); @@ -368,6 +377,17 @@ int main(int argc, char *argv[]) map); } + ret = a4l_set_wakesize(&dsc, wake_count); + if (ret < 0) { + fprintf(stderr, + "cmd_read: a4l_set_wakesize failed (ret=%d)\n", ret); + goto out_main; + } + + if (verbose != 0) + printf("cmd_read: wake size successfully set (%lu)\n", + wake_count); + /* Send the command to the input device */ ret = a4l_snd_command(&dsc, &cmd); if (ret < 0) { diff --git a/src/utils/analogy/cmd_write.c b/src/utils/analogy/cmd_write.c index 43926fd..453c033 100644 --- a/src/utils/analogy/cmd_write.c +++ b/src/utils/analogy/cmd_write.c @@ -44,7 +44,8 @@ struct config { unsigned int *chans; int chans_count; char *str_ranges; - int scans_count; + unsigned long scans_count; + unsigned long wake_count; char *filename; FILE *input; @@ -70,6 +71,7 @@ struct option options[] = { {"scans-count", required_argument, NULL, 'S'}, {"channels", required_argument, NULL, 'c'}, {"range", required_argument, NULL, 'c'}, + {"wake-count", required_argument, NULL, 'k'}, {"help", no_argument, NULL, 'h'}, {0}, }; @@ -84,11 +86,15 @@ void print_usage(void) fprintf(stdout, "\t\t -s, --subdevice: subdevice index\n"); fprintf(stdout, "\t\t -S, --scans-count: count of scan to perform\n"); fprintf(stdout, - "\t\t -c, --channels: channels to use " - "<i,j,...> (ex.: -c 0,1)\n"); + "\t\t -c, --channels: " + "channels to use <i,j,...> (ex.: -c 0,1)\n"); fprintf(stdout, - "\t\t -R, --range: range to use " - "<min,max,unit> (ex.: -R 0,1,V)\n"); + "\t\t -R, --range: " + "range to use <min,max,unit> (ex.: -R 0,1,V)\n"); + fprintf(stdout, + "\t\t -k, --wake-count: " + "space available before waking up the process\n"); + fprintf(stdout, "\t\t -h, --help: print this help\n"); } @@ -242,7 +248,8 @@ void print_config(struct config *cfg) printf("\tSubdevice index: %d\n", cfg->subd); printf("\tSelected channels: %s\n", cfg->str_chans); printf("\tSelected range: %s\n", cfg->str_ranges); - printf("\tScans count: %d\n", cfg->scans_count); + printf("\tScans count: %lu\n", cfg->scans_count); + printf("\tWake count: %lu\n", cfg->wake_count); } void cleanup_config(struct config *cfg) @@ -269,7 +276,8 @@ int init_config(struct config *cfg, int argc, char *argv[]) cfg->dsc.fd = -1; while ((err = getopt_long(argc, - argv, "vd:s:S:c:R:h", options, NULL)) >= 0) { + argv, + "vd:s:S:c:R:k:h", options, NULL)) >= 0) { switch (err) { case 'v': cfg->verbose = 1; @@ -289,6 +297,9 @@ int init_config(struct config *cfg, int argc, char *argv[]) case 'R': cfg->str_ranges = optarg; break; + case 'k': + cfg->wake_count = strtoul(optarg, NULL, 0); + break; case 'h': default: print_usage(); @@ -450,6 +461,13 @@ int init_acquisition(struct config *cfg) /* Cancel any former command which might be in progress */ a4l_snd_cancel(&cfg->dsc, cfg->subd); + err = a4l_set_wakesize(&cfg->dsc, cfg->wake_count); + if (err < 0) { + fprintf(stderr, + "cmd_read: a4l_set_wakesize failed (ret=%d)\n", err); + goto out; + } + /* Send the command so as to initialize the asynchronous acquisition */ err = a4l_snd_command(&cfg->dsc, &cmd); _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git