config for useranme and password of cam added.
This commit is contained in:
parent
0f8cc288a5
commit
ff9d8a5042
|
@ -29,7 +29,7 @@
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
<inttypes.h>
|
<inttypes.h>
|
||||||
|
|
||||||
1394056611 source:/home/chch/HengLongUDPclient/main.c
|
1395763961 source:/home/chch/HengLongUDPclient/main.c
|
||||||
<pthread.h>
|
<pthread.h>
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
<stdlib.h>
|
<stdlib.h>
|
||||||
|
@ -52,13 +52,14 @@
|
||||||
"henglong.h"
|
"henglong.h"
|
||||||
<linux/joystick.h>
|
<linux/joystick.h>
|
||||||
"wansview.h"
|
"wansview.h"
|
||||||
|
"extern.h"
|
||||||
|
|
||||||
1393293088 /home/chch/HengLongUDPclient/henglong.h
|
1395699958 /home/chch/HengLongUDPclient/henglong.h
|
||||||
<linux/input.h>
|
<linux/input.h>
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
<inttypes.h>
|
<inttypes.h>
|
||||||
|
|
||||||
1393293088 source:/home/chch/HengLongUDPclient/henglong.c
|
1395699958 source:/home/chch/HengLongUDPclient/henglong.c
|
||||||
"henglong.h"
|
"henglong.h"
|
||||||
|
|
||||||
1393274981 source:/home/stefan/Proj/HengLongUDPclient/henglong.c
|
1393274981 source:/home/stefan/Proj/HengLongUDPclient/henglong.c
|
||||||
|
@ -102,14 +103,14 @@
|
||||||
1393290504 source:/home/stefan/Proj/HengLongUDPclient/wansview.c
|
1393290504 source:/home/stefan/Proj/HengLongUDPclient/wansview.c
|
||||||
"wansview.h"
|
"wansview.h"
|
||||||
|
|
||||||
1394056760 /home/chch/HengLongUDPclient/wansview.h
|
1395762040 /home/chch/HengLongUDPclient/wansview.h
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
<string.h>
|
<string.h>
|
||||||
<unistd.h>
|
<unistd.h>
|
||||||
<arpa/inet.h>
|
<arpa/inet.h>
|
||||||
<sys/time.h>
|
<sys/time.h>
|
||||||
|
|
||||||
1394060723 source:/home/chch/HengLongUDPclient/wansview.c
|
1395763555 source:/home/chch/HengLongUDPclient/wansview.c
|
||||||
"wansview.h"
|
"wansview.h"
|
||||||
|
|
||||||
1395529103 source:/root/HengLongUDPclient/henglong.c
|
1395529103 source:/root/HengLongUDPclient/henglong.c
|
||||||
|
@ -158,3 +159,9 @@
|
||||||
1395529103 source:/root/HengLongUDPclient/wansview.c
|
1395529103 source:/root/HengLongUDPclient/wansview.c
|
||||||
"wansview.h"
|
"wansview.h"
|
||||||
|
|
||||||
|
1395761599 source:/home/chch/HengLongUDPclient/extern.c
|
||||||
|
"extern.h"
|
||||||
|
|
||||||
|
1395699958 /home/chch/HengLongUDPclient/extern.h
|
||||||
|
<stdlib.h>
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
<File name="client.config" open="1" top="0" tabpos="4">
|
<File name="client.config" open="1" top="0" tabpos="4">
|
||||||
<Cursor position="114" topLine="0" />
|
<Cursor position="114" topLine="0" />
|
||||||
</File>
|
</File>
|
||||||
<File name="extern.c" open="1" top="0" tabpos="7">
|
<File name="extern.c" open="1" top="1" tabpos="7">
|
||||||
<Cursor position="0" topLine="0" />
|
<Cursor position="41" topLine="0" />
|
||||||
</File>
|
</File>
|
||||||
<File name="extern.h" open="1" top="1" tabpos="8">
|
<File name="extern.h" open="1" top="0" tabpos="8">
|
||||||
<Cursor position="94" topLine="0" />
|
<Cursor position="127" topLine="0" />
|
||||||
</File>
|
</File>
|
||||||
<File name="henglong.c" open="1" top="0" tabpos="2">
|
<File name="henglong.c" open="1" top="0" tabpos="2">
|
||||||
<Cursor position="804" topLine="0" />
|
<Cursor position="804" topLine="0" />
|
||||||
|
@ -17,10 +17,10 @@
|
||||||
<Cursor position="564" topLine="0" />
|
<Cursor position="564" topLine="0" />
|
||||||
</File>
|
</File>
|
||||||
<File name="main.c" open="1" top="0" tabpos="1">
|
<File name="main.c" open="1" top="0" tabpos="1">
|
||||||
<Cursor position="274" topLine="0" />
|
<Cursor position="14572" topLine="482" />
|
||||||
</File>
|
</File>
|
||||||
<File name="wansview.c" open="1" top="0" tabpos="5">
|
<File name="wansview.c" open="1" top="0" tabpos="5">
|
||||||
<Cursor position="1540" topLine="35" />
|
<Cursor position="861" topLine="32" />
|
||||||
</File>
|
</File>
|
||||||
<File name="wansview.h" open="1" top="0" tabpos="6">
|
<File name="wansview.h" open="1" top="0" tabpos="6">
|
||||||
<Cursor position="342" topLine="0" />
|
<Cursor position="342" topLine="0" />
|
||||||
|
|
Binary file not shown.
|
@ -2,6 +2,8 @@ KEYBOARD /dev/input/event2
|
||||||
JOYSTICK /dev/input/js0
|
JOYSTICK /dev/input/js0
|
||||||
CAM 192.168.1.23
|
CAM 192.168.1.23
|
||||||
CAMINTERVAL 100000
|
CAMINTERVAL 100000
|
||||||
|
USER admin
|
||||||
|
PWD 123456
|
||||||
FRAME_US 100000
|
FRAME_US 100000
|
||||||
SERVER 192.168.1.18:32000
|
SERVER 192.168.1.18:32000
|
||||||
TIMEOUT 250
|
TIMEOUT 250
|
||||||
|
|
1
extern.c
1
extern.c
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
void fire(void)
|
void fire(void)
|
||||||
{
|
{
|
||||||
system("echo bla");
|
|
||||||
system("xte \'key Return\'\n");
|
system("xte \'key Return\'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
main.c
25
main.c
|
@ -264,6 +264,8 @@ typedef struct henglongconf_t
|
||||||
char joystickdevname[256];
|
char joystickdevname[256];
|
||||||
in_addr_t ip; // v4 only
|
in_addr_t ip; // v4 only
|
||||||
char cam[64];
|
char cam[64];
|
||||||
|
char user[64];
|
||||||
|
char pwd[64];
|
||||||
uint32_t caminterval;
|
uint32_t caminterval;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
uint8_t timeout;
|
uint8_t timeout;
|
||||||
|
@ -288,6 +290,8 @@ henglongconf_t getconfig(char* conffilename)
|
||||||
conf.joystickdevname[0] = 0;
|
conf.joystickdevname[0] = 0;
|
||||||
conf.cam[0] = 0;
|
conf.cam[0] = 0;
|
||||||
conf.caminterval = 100000;
|
conf.caminterval = 100000;
|
||||||
|
conf.user[0] = 0;
|
||||||
|
conf.pwd[0] = 0;
|
||||||
while(fgets(line, 256, configFile)){
|
while(fgets(line, 256, configFile)){
|
||||||
sscanf(line, "%16s %256s", parameter, value);
|
sscanf(line, "%16s %256s", parameter, value);
|
||||||
if(0==strcmp(parameter,"KEYBOARD")){
|
if(0==strcmp(parameter,"KEYBOARD")){
|
||||||
|
@ -299,6 +303,12 @@ henglongconf_t getconfig(char* conffilename)
|
||||||
if(0==strcmp(parameter,"CAM")){
|
if(0==strcmp(parameter,"CAM")){
|
||||||
sscanf(value, "%64s", conf.cam);
|
sscanf(value, "%64s", conf.cam);
|
||||||
}
|
}
|
||||||
|
if(0==strcmp(parameter,"USER")){
|
||||||
|
sscanf(value, "%64s", conf.user);
|
||||||
|
}
|
||||||
|
if(0==strcmp(parameter,"PWD")){
|
||||||
|
sscanf(value, "%64s", conf.pwd);
|
||||||
|
}
|
||||||
if(0==strcmp(parameter,"CAMINTERVAL")){
|
if(0==strcmp(parameter,"CAMINTERVAL")){
|
||||||
sscanf(value, "%" SCNu32, &conf.caminterval);
|
sscanf(value, "%" SCNu32, &conf.caminterval);
|
||||||
}
|
}
|
||||||
|
@ -323,6 +333,8 @@ henglongconf_t getconfig(char* conffilename)
|
||||||
typedef struct cam_ctrl_thread_t
|
typedef struct cam_ctrl_thread_t
|
||||||
{
|
{
|
||||||
char* ip;
|
char* ip;
|
||||||
|
char* username;
|
||||||
|
char* password;
|
||||||
int up, down, cw, ccw, nul, end;
|
int up, down, cw, ccw, nul, end;
|
||||||
uint32_t caminterval;
|
uint32_t caminterval;
|
||||||
} cam_ctrl_thread_t;
|
} cam_ctrl_thread_t;
|
||||||
|
@ -338,12 +350,12 @@ void *cam_ctrl_thread_fcn(void* arg)
|
||||||
|
|
||||||
while(!args->end){
|
while(!args->end){
|
||||||
usleep(args->caminterval);
|
usleep(args->caminterval);
|
||||||
if(args->up) cam_up(args->ip);
|
if(args->up) cam_up(args->ip, args->username, args->password);
|
||||||
if(args->down) cam_down(args->ip);
|
if(args->down) cam_down(args->ip, args->username, args->password);
|
||||||
if(args->cw) cam_cw(args->ip);
|
if(args->cw) cam_cw(args->ip, args->username, args->password);
|
||||||
if(args->ccw) cam_ccw(args->ip);
|
if(args->ccw) cam_ccw(args->ip, args->username, args->password);
|
||||||
if(args->nul) {
|
if(args->nul) {
|
||||||
cam_nul(args->ip);
|
cam_nul(args->ip, args->username, args->password);
|
||||||
args->nul = 0;
|
args->nul = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,7 +366,6 @@ void *cam_ctrl_thread_fcn(void* arg)
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
pthread_t keybthread, joythread, refl_thread, cam_ctrl_thread;
|
pthread_t keybthread, joythread, refl_thread, cam_ctrl_thread;
|
||||||
input_thread_t keyboard_thread_args;
|
input_thread_t keyboard_thread_args;
|
||||||
input_thread_t joystick_thread_args;
|
input_thread_t joystick_thread_args;
|
||||||
|
@ -403,6 +414,8 @@ int main(int argc, char* argv[])
|
||||||
cam_ctrl_thread_args.end = 0;
|
cam_ctrl_thread_args.end = 0;
|
||||||
cam_ctrl_thread_args.ip = conf.cam;
|
cam_ctrl_thread_args.ip = conf.cam;
|
||||||
cam_ctrl_thread_args.caminterval = conf.caminterval;
|
cam_ctrl_thread_args.caminterval = conf.caminterval;
|
||||||
|
cam_ctrl_thread_args.username = conf.user;
|
||||||
|
cam_ctrl_thread_args.password = conf.pwd;
|
||||||
if (pthread_create(&cam_ctrl_thread, NULL, cam_ctrl_thread_fcn , (void *) &cam_ctrl_thread_args)) printf("failed to create cam_ctrl thread\n");
|
if (pthread_create(&cam_ctrl_thread, NULL, cam_ctrl_thread_fcn , (void *) &cam_ctrl_thread_args)) printf("failed to create cam_ctrl thread\n");
|
||||||
}else{
|
}else{
|
||||||
printf("no cam config!\n");
|
printf("no cam config!\n");
|
||||||
|
|
Binary file not shown.
Binary file not shown.
BIN
obj/Debug/main.o
BIN
obj/Debug/main.o
Binary file not shown.
Binary file not shown.
29
wansview.c
29
wansview.c
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "wansview.h"
|
#include "wansview.h"
|
||||||
|
|
||||||
int wvcamctrl(char* ip, int cmd)
|
int wvcamctrl(char* ip, char* username, char* password, int cmd)
|
||||||
{
|
{
|
||||||
int sockfd = 0, n = 0;
|
int sockfd = 0, n = 0;
|
||||||
char recvBuff[1024];
|
char recvBuff[1024];
|
||||||
|
@ -33,7 +33,7 @@ int wvcamctrl(char* ip, int cmd)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(sendBuff, "GET /decoder_control.cgi?onestep=1&command=%d&user=chch&pwd=chch HTTP/1.1\r\nHost: %s\r\n\r\n", cmd, ip);
|
sprintf(sendBuff, "GET /decoder_control.cgi?onestep=1&command=%d&user=%s&pwd=%s HTTP/1.1\r\nHost: %s\r\n\r\n", cmd, username, password, ip);
|
||||||
|
|
||||||
n = write(sockfd, sendBuff, strlen(sendBuff));
|
n = write(sockfd, sendBuff, strlen(sendBuff));
|
||||||
|
|
||||||
|
@ -50,42 +50,43 @@ int wvcamctrl(char* ip, int cmd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cam_down(char* ip)
|
int cam_down(char* ip, char* username, char* password)
|
||||||
{
|
{
|
||||||
return wvcamctrl(ip, 0);
|
return wvcamctrl(ip, username, password, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int cam_up(char* ip)
|
int cam_up(char* ip, char* username, char* password)
|
||||||
{
|
{
|
||||||
return wvcamctrl(ip, 2);
|
return wvcamctrl(ip, username, password, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cam_cw(char* ip)
|
int cam_cw(char* ip, char* username, char* password)
|
||||||
{
|
{
|
||||||
return wvcamctrl(ip, 4);
|
return wvcamctrl(ip, username, password, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cam_ccw(char* ip)
|
int cam_ccw(char* ip, char* username, char* password)
|
||||||
{
|
{
|
||||||
return wvcamctrl(ip, 6);
|
return wvcamctrl(ip, username, password, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cam_nul(char* ip)
|
int cam_nul(char* ip, char* username, char* password)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<20;i++){
|
for(i=0;i<20;i++){
|
||||||
usleep(300000);
|
usleep(300000);
|
||||||
cam_down(ip);
|
cam_down(ip, username, password);
|
||||||
}
|
}
|
||||||
for(i=0;i<80;i++){
|
for(i=0;i<80;i++){
|
||||||
|
|
||||||
usleep(300000);
|
usleep(300000);
|
||||||
cam_ccw(ip);
|
cam_ccw(ip, username, password);
|
||||||
}
|
}
|
||||||
for(i=0;i<40;i++){
|
for(i=0;i<40;i++){
|
||||||
usleep(300000);
|
usleep(300000);
|
||||||
cam_cw(ip);
|
cam_cw(ip, username, password);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
12
wansview.h
12
wansview.h
|
@ -8,11 +8,11 @@
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
int wvcamctrl(char* ip, int cmd);
|
int wvcamctrl(char* ip, char* username, char* password, int cmd);
|
||||||
int cam_down(char* ip);
|
int cam_down(char* ip, char* username, char* password);
|
||||||
int cam_up(char* ip);
|
int cam_up(char* ip, char* username, char* password);
|
||||||
int cam_cw(char* ip);
|
int cam_cw(char* ip, char* username, char* password);
|
||||||
int cam_ccw(char* ip);
|
int cam_ccw(char* ip, char* username, char* password);
|
||||||
int cam_nul(char* ip);
|
int cam_nul(char* ip, char* username, char* password);
|
||||||
|
|
||||||
#endif // WANSVIEW_H_INCLUDED
|
#endif // WANSVIEW_H_INCLUDED
|
||||||
|
|
Loading…
Reference in New Issue