added feature to stop the robot remote control if video stream is not watched.
This commit is contained in:
parent
ff9d8a5042
commit
7326835f39
|
@ -29,7 +29,7 @@
|
|||
<stdio.h>
|
||||
<inttypes.h>
|
||||
|
||||
1395763961 source:/home/chch/HengLongUDPclient/main.c
|
||||
1395876570 source:/home/chch/HengLongUDPclient/main.c
|
||||
<pthread.h>
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
@ -53,6 +53,7 @@
|
|||
<linux/joystick.h>
|
||||
"wansview.h"
|
||||
"extern.h"
|
||||
"checkvideo.h"
|
||||
|
||||
1395699958 /home/chch/HengLongUDPclient/henglong.h
|
||||
<linux/input.h>
|
||||
|
@ -110,7 +111,7 @@
|
|||
<arpa/inet.h>
|
||||
<sys/time.h>
|
||||
|
||||
1395763555 source:/home/chch/HengLongUDPclient/wansview.c
|
||||
1395764006 source:/home/chch/HengLongUDPclient/wansview.c
|
||||
"wansview.h"
|
||||
|
||||
1395529103 source:/root/HengLongUDPclient/henglong.c
|
||||
|
@ -165,3 +166,12 @@
|
|||
1395699958 /home/chch/HengLongUDPclient/extern.h
|
||||
<stdlib.h>
|
||||
|
||||
1395871885 /home/chch/HengLongUDPclient/checkvideo.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
<inttypes.h>
|
||||
<arpa/inet.h>
|
||||
|
||||
1395876458 source:/home/chch/HengLongUDPclient/checkvideo.c
|
||||
"checkvideo.h"
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="client.config" open="1" top="0" tabpos="4">
|
||||
<Cursor position="114" topLine="0" />
|
||||
<File name="client.config" open="1" top="1" tabpos="8">
|
||||
<Cursor position="66" topLine="0" />
|
||||
</File>
|
||||
<File name="extern.c" open="1" top="1" tabpos="7">
|
||||
<File name="extern.c" open="1" top="0" tabpos="6">
|
||||
<Cursor position="41" topLine="0" />
|
||||
</File>
|
||||
<File name="extern.h" open="1" top="0" tabpos="8">
|
||||
<File name="extern.h" open="1" top="0" tabpos="7">
|
||||
<Cursor position="127" topLine="0" />
|
||||
</File>
|
||||
<File name="henglong.c" open="1" top="0" tabpos="2">
|
||||
|
@ -17,12 +17,12 @@
|
|||
<Cursor position="564" topLine="0" />
|
||||
</File>
|
||||
<File name="main.c" open="1" top="0" tabpos="1">
|
||||
<Cursor position="14572" topLine="482" />
|
||||
<Cursor position="9478" topLine="499" />
|
||||
</File>
|
||||
<File name="wansview.c" open="1" top="0" tabpos="5">
|
||||
<Cursor position="861" topLine="32" />
|
||||
<File name="wansview.c" open="1" top="0" tabpos="4">
|
||||
<Cursor position="941" topLine="3" />
|
||||
</File>
|
||||
<File name="wansview.h" open="1" top="0" tabpos="6">
|
||||
<Cursor position="342" topLine="0" />
|
||||
<File name="wansview.h" open="1" top="0" tabpos="5">
|
||||
<Cursor position="534" topLine="0" />
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,32 @@
|
|||
|
||||
#include "checkvideo.h"
|
||||
|
||||
int connectionstate(char* remip, uint16_t remport)
|
||||
{
|
||||
FILE* tcpfile;
|
||||
char line[256];
|
||||
uint32_t remipi;
|
||||
uint32_t remporti;
|
||||
uint32_t statei;
|
||||
|
||||
statei = 0;
|
||||
remipi = 0;
|
||||
remporti = 0;
|
||||
tcpfile = fopen("/proc/net/tcp","r");
|
||||
while(fgets(line,256,tcpfile)){
|
||||
sscanf(line, "%*u: %*x:%*x %x:%x %x", &remipi, &remporti, &statei);
|
||||
if((inet_addr(remip)==remipi) & (remport==remporti)) {
|
||||
fclose(tcpfile);
|
||||
return statei;
|
||||
}
|
||||
}
|
||||
fclose(tcpfile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int checkvideo(char* remip, uint16_t remport)
|
||||
{
|
||||
if(0==remip[0]) return 2;
|
||||
if(1==connectionstate(remip, remport)) return 1;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef CHECKVIDEO_H_INCLUDED
|
||||
#define CHECKVIDEO_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
int connectionstate(char* remip, uint16_t remport);
|
||||
int checkvideo(char* remip, uint16_t remport);
|
||||
|
||||
#endif // CHECKVIDEO_H_INCLUDED
|
|
@ -5,6 +5,7 @@ CAMINTERVAL 100000
|
|||
USER admin
|
||||
PWD 123456
|
||||
FRAME_US 100000
|
||||
SERVER 192.168.1.18:32000
|
||||
SERVER 192.168.1.13:32000
|
||||
TIMEOUT 250
|
||||
CLINBR 0
|
||||
VIDEO 192.168.1.20:8080
|
||||
|
|
17
main.c
17
main.c
|
@ -23,6 +23,7 @@
|
|||
#include <linux/joystick.h>
|
||||
#include "wansview.h"
|
||||
#include "extern.h"
|
||||
#include "checkvideo.h"
|
||||
|
||||
typedef struct outtty_t
|
||||
{
|
||||
|
@ -264,10 +265,11 @@ typedef struct henglongconf_t
|
|||
char joystickdevname[256];
|
||||
in_addr_t ip; // v4 only
|
||||
char cam[64];
|
||||
char video[16];
|
||||
char user[64];
|
||||
char pwd[64];
|
||||
uint32_t caminterval;
|
||||
uint16_t port;
|
||||
uint16_t port, videoport;
|
||||
uint8_t timeout;
|
||||
uint8_t clinbr;
|
||||
} henglongconf_t;
|
||||
|
@ -292,6 +294,8 @@ henglongconf_t getconfig(char* conffilename)
|
|||
conf.caminterval = 100000;
|
||||
conf.user[0] = 0;
|
||||
conf.pwd[0] = 0;
|
||||
conf.video[0] = 0;
|
||||
conf.videoport = 0;
|
||||
while(fgets(line, 256, configFile)){
|
||||
sscanf(line, "%16s %256s", parameter, value);
|
||||
if(0==strcmp(parameter,"KEYBOARD")){
|
||||
|
@ -325,6 +329,9 @@ henglongconf_t getconfig(char* conffilename)
|
|||
if(0==strcmp(parameter,"CLINBR")){
|
||||
sscanf(value, "%" SCNu8 , &conf.clinbr);
|
||||
}
|
||||
if(0==strcmp(parameter,"VIDEO")){
|
||||
sscanf(value, "%16[^:]:%" SCNu16, conf.video, &conf.videoport);
|
||||
}
|
||||
}
|
||||
return conf;
|
||||
}
|
||||
|
@ -366,6 +373,7 @@ void *cam_ctrl_thread_fcn(void* arg)
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
pthread_t keybthread, joythread, refl_thread, cam_ctrl_thread;
|
||||
input_thread_t keyboard_thread_args;
|
||||
input_thread_t joystick_thread_args;
|
||||
|
@ -443,6 +451,11 @@ int main(int argc, char* argv[])
|
|||
while(1){
|
||||
usleep(conf.frame_us);
|
||||
|
||||
// do not send control commands if live video is not watched
|
||||
if(0==checkvideo(conf.video, conf.videoport)){
|
||||
printf("No video stream connection from %s:%u, remote control locked!\n", conf.video, conf.videoport);
|
||||
continue;
|
||||
}
|
||||
frame = 0xc0ffee;
|
||||
|
||||
time_us = get_us();
|
||||
|
@ -505,7 +518,7 @@ int main(int argc, char* argv[])
|
|||
if(senddata.outtty.servo_tilt<-50) senddata.outtty.servo_tilt = -50;
|
||||
|
||||
// Return-Button on Keyboard via Joystick-Fire for screenshot in Browser
|
||||
if(0==fire_old & 1==joystick_thread_args.hl.fire){
|
||||
if((0==fire_old) & (1==joystick_thread_args.hl.fire)){
|
||||
fire();
|
||||
}
|
||||
fire_old = joystick_thread_args.hl.fire;
|
||||
|
|
Binary file not shown.
BIN
obj/Debug/main.o
BIN
obj/Debug/main.o
Binary file not shown.
Loading…
Reference in New Issue