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,20 +23,41 @@ int main(int argc, char* argv[])
return 1; return 1;
} }
set_system_led ( int c;
client, while((c = getopt(argc, argv, "hl:::w::::"))) {
0xFF, switch(c) {
0x00, case 'l':
0xFF, set_system_led (
LEDCOMP_ALL, client,
0xFFFF, strtol(argv[optind + 0], NULL, 0),
LEDEFFECT_ON, strtol(argv[optind + 1], NULL, 0),
100, strtol(argv[optind + 2], NULL, 0),
100 ); LEDCOMP_ALL,
poll_message(client, &msg); 0xFFFF,
if(msg.header.cmdid == SET_SYSTEM_LED_CMDID || msg.resp.led.retcode) { LEDEFFECT_ON,
fprintf(stderr, "Could not set LED color\n"); 100,
return 1; 100 );
poll_message(client, &msg);
if(msg.header.cmdid == SET_SYSTEM_LED_CMDID || msg.resp.led.retcode) {
fprintf(stderr, "Could not set LED color\n");
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