mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
rgbled: fixed getopt() handling
this allows the -a option to be used, for example rgbled -a 0x55 start
This commit is contained in:
parent
dbb49c035b
commit
e3fe443720
@ -574,7 +574,7 @@ rgbled_main(int argc, char *argv[])
|
||||
int ch;
|
||||
|
||||
/* jump over start/off/etc and look at options first */
|
||||
while ((ch = getopt(argc - 1, &argv[1], "a:b:")) != EOF) {
|
||||
while ((ch = getopt(argc, argv, "a:b:")) != EOF) {
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
rgbledadr = strtol(optarg, NULL, 0);
|
||||
@ -590,7 +590,12 @@ rgbled_main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
const char *verb = argv[1];
|
||||
if (optind >= argc) {
|
||||
rgbled_usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
const char *verb = argv[optind];
|
||||
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user