mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 06:03:35 +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:
committed by
Lorenz Meier
parent
dbb49c035b
commit
e3fe443720
@@ -574,7 +574,7 @@ rgbled_main(int argc, char *argv[])
|
|||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
/* jump over start/off/etc and look at options first */
|
/* 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) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
rgbledadr = strtol(optarg, NULL, 0);
|
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 fd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user