Make shell command take run arguments

refactor
PgSocks 2 years ago
parent 35cc588ae9
commit 07a0d7eca7

@ -1,6 +1,8 @@
#include "robomaster.h" #include "robomaster.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
@ -21,11 +23,15 @@ int main(int argc, char* argv[])
return 1; return 1;
} }
int c;
while((c = getopt(argc, argv, "hl:::w::::"))) {
switch(c) {
case 'l':
set_system_led ( set_system_led (
client, client,
0xFF, strtol(argv[optind + 0], NULL, 0),
0x00, strtol(argv[optind + 1], NULL, 0),
0xFF, strtol(argv[optind + 2], NULL, 0),
LEDCOMP_ALL, LEDCOMP_ALL,
0xFFFF, 0xFFFF,
LEDEFFECT_ON, LEDEFFECT_ON,
@ -36,6 +42,23 @@ int main(int argc, char* argv[])
fprintf(stderr, "Could not set LED color\n"); fprintf(stderr, "Could not set LED color\n");
return 1; return 1;
} }
break;
case 'w':
set_wheel_speed (
client,
strtol(argv[optind + 0], NULL, 0),
strtol(argv[optind + 1], NULL, 0),
strtol(argv[optind + 2], NULL, 0),
strtol(argv[optind + 3], NULL, 0) );
break;
case '?':
default:
fprintf(stderr, "Unknown argument %c\n", optopt);
case 'h':
printf("Usage: [-h] [-l r g b] [-w w1 w2 w3 w4]");
break;
}
}
return 0; return 0;
} }

Loading…
Cancel
Save