5
0
Fork 0
mirror of https://github.com/TheTesla/HengLongUDPclient.git synced 2025-07-01 12:56:14 +02:00

added feature to stop the robot remote control if video stream is not watched.

This commit is contained in:
root 2014-03-27 00:31:38 +01:00
parent ff9d8a5042
commit 7326835f39
9 changed files with 82 additions and 14 deletions

32
checkvideo.c Normal file
View file

@ -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;
}