Bug fixed: killwitch checkinterval

This commit is contained in:
root 2014-04-03 01:13:46 +02:00
parent 824ec1c1d9
commit 74531ce35e
6 changed files with 10 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@ -11,3 +11,4 @@ CLINBR 0
VIDEO 192.168.1.66:8080 VIDEO 192.168.1.66:8080
KILLSW 192.168.1.20:8080/status KILLSW 192.168.1.20:8080/status
KILLSWTO_US 600000 KILLSWTO_US 600000
KILLSWINT 100000

10
main.c
View File

@ -276,6 +276,7 @@ typedef struct henglongconf_t
uint8_t timeout; uint8_t timeout;
uint8_t clinbr; uint8_t clinbr;
uint32_t killswtimeoutus; uint32_t killswtimeoutus;
uint32_t killswint;
} henglongconf_t; } henglongconf_t;
henglongconf_t getconfig(char* conffilename) henglongconf_t getconfig(char* conffilename)
@ -304,6 +305,7 @@ henglongconf_t getconfig(char* conffilename)
conf.killport = 0; conf.killport = 0;
conf.killurl[0] = 0; conf.killurl[0] = 0;
conf.killswtimeoutus = 500000; conf.killswtimeoutus = 500000;
conf.killswint = 100000;
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")){
@ -346,6 +348,9 @@ henglongconf_t getconfig(char* conffilename)
if(0==strcmp(parameter,"KILLSWTO_US")){ if(0==strcmp(parameter,"KILLSWTO_US")){
sscanf(value, "%" SCNu32 , &conf.killswtimeoutus); sscanf(value, "%" SCNu32 , &conf.killswtimeoutus);
} }
if(0==strcmp(parameter,"KILLSWINT")){
sscanf(value, "%" SCNu32, &conf.killswint);
}
} }
return conf; return conf;
} }
@ -391,6 +396,7 @@ typedef struct killsw_thread_t
uint16_t port; uint16_t port;
char* url; char* url;
uint32_t timeout_us; uint32_t timeout_us;
uint32_t killswint;
int state; int state;
} killsw_thread_t; } killsw_thread_t;
@ -401,7 +407,8 @@ void *killsw_thread_fcn(void* arg)
args = (killsw_thread_t*) arg; args = (killsw_thread_t*) arg;
args->state = 0; args->state = 0;
while(1){ while(1){
args->state = checkkillswitch(args->ip, args->port, args->url, args->timeout_us); usleep(args->killswint);
args->state = checkkillswitch(args->ip, args->port, args->url, args->timeout_us);
} }
pthread_exit(0); pthread_exit(0);
} }
@ -473,6 +480,7 @@ int main(int argc, char* argv[])
killsw_thread_args.url = conf.killurl; killsw_thread_args.url = conf.killurl;
killsw_thread_args.state = 0; killsw_thread_args.state = 0;
killsw_thread_args.timeout_us = conf.killswtimeoutus; killsw_thread_args.timeout_us = conf.killswtimeoutus;
killsw_thread_args.killswint = conf.killswint;
if (pthread_create(&killsw_thread, NULL, killsw_thread_fcn , (void *) &killsw_thread_args)) printf("failed to create killsw thread\n"); if (pthread_create(&killsw_thread, NULL, killsw_thread_fcn , (void *) &killsw_thread_args)) printf("failed to create killsw thread\n");
}else{ }else{
printf("no killswitch!\n"); printf("no killswitch!\n");

Binary file not shown.

Binary file not shown.