Make shell command take run arguments
This commit is contained in:
+37
-14
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user