diff options
| author | Qiuwen Lu <[email protected]> | 2017-05-10 12:35:29 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2017-05-10 12:35:29 +0800 |
| commit | d237884f314c0870750208a87f0630eb7d16f1c8 (patch) | |
| tree | ca0679860af69493744715279584fea408325c6f /examples | |
| parent | b989a6062306c140bf25e2717e94fd794254fc68 (diff) | |
增加Feedback样例程序运行参数解析
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/feedback.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/examples/feedback.c b/examples/feedback.c index 443a221..3b32206 100644 --- a/examples/feedback.c +++ b/examples/feedback.c @@ -6,6 +6,7 @@ #include <pthread.h> #include <arpa/inet.h> #include <string.h> +#include <unistd.h> static char appsym[64] = "mrtest-fb"; static char dev_src_symbol[64] = "meth1"; @@ -59,15 +60,71 @@ void * feedback_loop(void * arg) } marsio_send_burst(to_dev_dst_sendpath, sid, feedback_buffs, ret); - marsio_buff_free(mr_instance, feedback_buffs, ret, 0, 0); marsio_buff_free(mr_instance, rx_buff, ret, 0, 0); } return (void *)NULL; } +int help() +{ + return 0; +} + int main(int argc, char * argv[]) { + int opt = 0; + while ((opt = getopt(argc, argv, "s:d:a:c:b:t:h?")) != -1) + { + char * endptr = NULL; + switch (opt) + { + case '?': + case 'h': + { + help(); + break; + } + case 's': + { + snprintf(dev_src_symbol, sizeof(dev_src_symbol), "%s", optarg); + break; + } + case 'd': + { + snprintf(dev_dst_symbol, sizeof(dev_dst_symbol), "%s", optarg); + break; + } + case 't': + { + snprintf(str_target_ipaddr, sizeof(str_target_ipaddr), "%s", optarg); + break; + } + case 'a': + { + snprintf(appsym, sizeof(appsym), "%s", optarg); + break; + } + case 'c': + { + cpu_mask = strtoull(optarg, &endptr, 0); + if (cpu_mask == 0 && endptr == optarg) help(); + break; + } + case 'b': + { + nr_burst = strtoull(optarg, &endptr, 0); + if (nr_burst == 0 && endptr == optarg) help(); + break; + } + + default: + help(); + break; + } + } + + mr_instance = marsio_create(); if (mr_instance == NULL) { |
