From: James C. <ja...@ca...> - 2006-08-31 16:14:30
|
Hey Rodrigo, Its not really like that. There are a few options: 1) Use just perl - this= =20 is what i use as perl is good at parsing strings. The script i have grabs= =20 the data from the gps, converts it into something useful and then logs it.= =20 2)Run GPSD as a daemon and use some C to access it (via a sort of telnet=20 system) to get commands. This is pretty easy to do, something like this: int gpsd_connect(void) { //int hSocket; /* handle to socket */ struct hostent* pHostInfo; /* holds info about a machine */ struct sockaddr_in Address; /* Internet socket address stuct */ long nHostAddress; // char pBuffer[BUFFER_SIZE]; //=09unsigned nReadAmount; char strHostName[HOST_NAME_SIZE]; int nHostPort; printf("\nMaking a socket"); /* make a socket */ hSocket=3Dsocket(AF_INET,SOCK_STREAM,IPPROTO_TCP); if(hSocket =3D=3D SOCKET_ERROR) { printf("\nCould not make a socket\n"); return 0; } /* get IP address from name */ pHostInfo=3Dgethostbyname(GPSD_HOSTNAME); /* copy address into long */ memcpy(&nHostAddress,pHostInfo->h_addr,pHostInfo->h_length); /* fill address struct */ Address.sin_addr.s_addr=3DnHostAddress; Address.sin_port=3Dhtons(GPSD_PORT); Address.sin_family=3DAF_INET; printf("\nConnecting to %s on port %d\n",strHostName,nHostPort); /* connect to host */ if(connect(hSocket,(struct sockaddr*)&Address,sizeof(Address))=20 =3D=3D SOCKET_ERROR) { printf("\nCould not connect to host\n"); return 0; } } int gps_lock(void){ =09write(hSocket,"s",1); =09nReadAmount=3Dread(hSocket,pBuffer,BUFFER_SIZE); =09printf("%s",pBuffer);=09 } Though it isn't complete that will connect to GPSD and then send an "s"=20 command to find out whether the gps has a lock. 3)Or you can look into using libgps directly to access the gps from you=20 code which is probably the best option though i don't actually have any=20 working code available - Ben(phatmonkey) do you? James On Aug 31 2006, Rodrigo Sosa wrote: >Hey James, > >That sounds interesting, verry, in particular the part of libgps >communicating with the gpsd >Im doing all in C, as is what i "know" most than others ("know"=3Dnoob >speeching), so the libgps sounds cool. >So if i understand correctly you use the perl script to setup the GPS to >your needs and then access it with your code using libgps? >If you can send me some code as a guideline of all what you have used MUCH >appreciated :D >best regards > >Rodrigo > |