gadspot gs1200g

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
tedhuntington
Posts: 3
Joined: Sun Nov 19, 2006 4:08 pm

gadspot gs1200g

Post by tedhuntington »

I got the gs1200 working with linux by disabling the DHCP and just using a static IP for it. With the DHCP it was sending an HTML packet instead of TCP packets, and got caught constantly resending the first packet.

And this allows the camera to work with vlc. But I still can't get ZM to get and image from it. Any ideas? The network address is in red. Also there is Disk: -1% (but there is enough disk space). I click on Zones "1" and it just opens a window with a black square.


Here is the code I use in Linux to get an image from the gs1200:

ipconfig.c
========
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>

//#define BUFFSIZE 32
#define BUFFSIZE 2048
void Die(char *mess) { perror(mess); exit(1); }


//this is a client that establishes a TCP session with another client
int main(int argc, char *argv[]) {

int sock;
struct sockaddr_in echoserver;
char buffer[BUFFSIZE];
unsigned int echolen;
int received = 0,status=0,bytes=0,numbytes;
char ip[20],port[10];
FILE *fptr;
char send1[512]; //http request getimage string

//copy in HTML string to request image
fptr=fopen("ffsend.txt","rb");
fread(&send1,427,1,fptr);
// fptr=fopen("iesend.txt","rb");
// fread(&send1,302,1,fptr);
fclose(fptr);


strcpy(ip,"192.168.0.106");
strcpy(port,"80"); //1047 80

if ((sock = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP)) < 0) {
Die("Failed to create socket\n");
}


memset(&echoserver, 0, sizeof(echoserver));
echoserver.sin_family = AF_INET;
echoserver.sin_addr.s_addr = inet_addr(ip);
echoserver.sin_port = htons(atoi(port));

if (connect(sock,(struct sockaddr *)&echoserver,sizeof(echoserver))<0) {
Die("Failed to connect with server\n");
}


//Send the HTTP request for an image
if (write(sock,send1,427)!= 427) {

// if (send(sock,send1,302,0) != 302) { //ie
Die("Failed to send bytes to client");
}

fptr=fopen("out.jpg","wb");
numbytes=0;
while ((status=read(sock,buffer,sizeof(buffer)-1))>0) {
//remove http info
if (numbytes+status>227) {
if (numbytes<228) {
fwrite(buffer+(227-numbytes),status-(227-numbytes),1,fptr);
} else {
fwrite(buffer,status,1,fptr);
}
}

numbytes+=status;
}
fclose(fptr);


fprintf(stdout,"done\n");
close(sock);
exit(0);

} //end main
=====

and the binary file must have the exact characters:
ffsend.txt:
=========
GET /cgi-bin/getimage.cgi?motion=0 HTTP/1.1
Host: 192.168.0.106
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10)
Gecko/20050716 Firefox/1.0.6
Accept: image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
If-Modified-Since: Sat, 01 Jan 2000 18:09:09 GMT
Cache-Control: max-age=0

(followed by 0d0a cr and lf or just get the file from tedhuntington/ffsend.txt)

then simply add your camera's IP, and compile with
gcc -o ipconfig ipconfig.c

the jpg will write to out.jpg.


Can anybody help me figure out why ZM won't work when vlc does?

thanks
Ted
Post Reply