Skip to content

Commit ffb18c7

Browse files
committed
Merge branch 'icam_app-communication'
* icam_app-communication: コマンド体系整理
2 parents d4f95fa + d36ae7f commit ffb18c7

File tree

5 files changed

+19
-25
lines changed

5 files changed

+19
-25
lines changed
+6-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/bin/sh
22

3-
# getpos -> <pan(deg)> <tilt(deg)>
4-
pos=`/scripts/cmd getpos`
5-
6-
# setpos <pan(0-355 deg)> <tilt(0-180 deg)> <pri 0:top, 1:high, 2:normal, 3:weak>
7-
/scripts/cmd setpos 0 0 1
8-
/scripts/cmd setpos 355 180 1
9-
/scripts/cmd setpos $pos 1
3+
# move [<pan(0-355 deg)> <tilt(0-180 deg)> [<pri 0:top, 1:high, 2:normal, 3:weak>]]
4+
# move -> <pan(deg)> <tilt(deg)>
5+
pos=`/scripts/cmd move`
6+
/scripts/cmd move 0 0 1
7+
/scripts/cmd move 355 180 1
8+
/scripts/cmd move $pos 1

libcallback/audio_callback.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static int AudioCaptureEnable = 0;
2222
char *AudioCapture(int fd, char *tokenPtr) {
2323

2424
char *p = strtok_r(NULL, " \t\r\n", &tokenPtr);
25-
if(!p) return "error";
25+
if(!p) return AudioCaptureEnable ? "on" : "off";
2626
if(!strcmp(p, "on")) {
2727
AudioCaptureEnable = 1;
2828
fprintf(stderr, "[command] audio capute on\n", p);

libcallback/command.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ static int SelfPipe[2];
1717
extern char *JpegCapture(int fd, char *tokenPtr);
1818
extern char *VideoCapture(int fd, char *tokenPtr);
1919
extern char *AudioCapture(int fd, char *tokenPtr);
20-
extern char *MotorGetPos(int fd, char *tokenPtr);
21-
extern char *MotorSetPos(int fd, char *tokenPtr);
20+
extern char *MotorMove(int fd, char *tokenPtr);
2221

2322
struct CommandTableSt {
2423
const char *cmd;
@@ -29,8 +28,7 @@ struct CommandTableSt CommandTable[] = {
2928
{ "video", &VideoCapture },
3029
{ "audio", &AudioCapture },
3130
{ "jpeg", &JpegCapture },
32-
{ "getpos", &MotorGetPos },
33-
{ "setpos", &MotorSetPos },
31+
{ "move", &MotorMove },
3432
};
3533

3634
void CommandResponse(int fd, const char *res) {

libcallback/motor.c

+9-12
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ extern int local_sdk_motor_get_position(float *step,float *angle);
77
extern int local_sdk_motor_move_abs_angle(float pan, float tilt, int speed, void (*done)(float a, float b), void (*canceled)(void), int mode);
88
extern void CommandResponse(int fd, const char *res);
99

10-
char *MotorGetPos(int fd, char *tokenPtr) {
11-
12-
float pan; // 0-355
13-
float tilt; // 0-180
14-
int ret = local_sdk_motor_get_position(&pan, &tilt);
15-
static char motorResBuf[256];
16-
sprintf(motorResBuf, "%f %f\n", pan, tilt);
17-
return motorResBuf;
18-
}
19-
2010
static int motorFd = 0;
2111
static void motor_move_done(float a, float b) {
2212

@@ -30,10 +20,17 @@ static void motor_move_canceled() {
3020
motorFd = 0;
3121
}
3222

33-
char *MotorSetPos(int fd, char *tokenPtr) {
23+
char *MotorMove(int fd, char *tokenPtr) {
3424

3525
char *p = strtok_r(NULL, " \t\r\n", &tokenPtr);
36-
if(!p) return "error";
26+
if(!p) {
27+
float pan; // 0-355
28+
float tilt; // 0-180
29+
int ret = local_sdk_motor_get_position(&pan, &tilt);
30+
static char motorResBuf[256];
31+
sprintf(motorResBuf, "%f %f\n", pan, tilt);
32+
return motorResBuf;
33+
}
3734
float pan = atof(p); // 0-355
3835
if((pan < 0.0) || (pan > 355.0)) return "error";
3936

libcallback/video_callback.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int VideoCaptureEnable = 0;
2626
char *VideoCapture(int fd, char *tokenPtr) {
2727

2828
char *p = strtok_r(NULL, " \t\r\n", &tokenPtr);
29-
if(!p) return "error";
29+
if(!p) return VideoCaptureEnable ? "on" : "off";
3030
if(!strcmp(p, "on")) {
3131
VideoCaptureEnable = 1;
3232
fprintf(stderr, "[command] video capute on\n", p);

0 commit comments

Comments
 (0)