122 lines
2.6 KiB
C++
122 lines
2.6 KiB
C++
//
|
|
// GPS Daemon
|
|
// Neal Probert
|
|
//
|
|
|
|
/* prevent multiple inclusions */
|
|
#ifndef __GpsDaemon__
|
|
#define __GpsDaemon__
|
|
|
|
/* includes *****************************************************************/
|
|
|
|
#include "bzlib.h"
|
|
|
|
#include "TcpDaemon.h"
|
|
#include "UdpClient.h"
|
|
#include "UdpCaster.h"
|
|
|
|
#include "GpsDevice.h"
|
|
#include "GpsdClient.h"
|
|
#include "NmeaParser.h"
|
|
#include "SirfParser.h"
|
|
#include "ApplanixParser.h"
|
|
#include "DgpsClient.h"
|
|
#include "NtripClient.h"
|
|
|
|
#include "Logging.h"
|
|
|
|
/* defines ******************************************************************/
|
|
|
|
/* software details */
|
|
#define GPSD_NAME "gpsd"
|
|
#define GPSD_VERSION "0.1"
|
|
|
|
/* default service and port */
|
|
#define GPSD_SERVICE "gpsd"
|
|
#define GPSD_PORT "2947"
|
|
|
|
/* macros *******************************************************************/
|
|
|
|
/* structs & typedefs *******************************************************/
|
|
|
|
/* c class definitions ******************************************************/
|
|
|
|
//
|
|
// Uses the Peak Systems CAN Linux driver and Nissan CAN data
|
|
//
|
|
class GpsDaemon : public TcpDaemon, public GpsListener, public Logging {
|
|
// public data
|
|
public:
|
|
GpsdClient Gpsd;
|
|
GpsDevice Gps;
|
|
GpsParser *Parser;
|
|
|
|
DgpsClient Dgps;
|
|
NtripClient Ntrip;
|
|
|
|
// TrackClient Track;
|
|
|
|
// for corrections reconnect
|
|
char Uri[1024];
|
|
int nClients;
|
|
|
|
// private data
|
|
private:
|
|
bool gps_source; // 1=gps, 0=gpsd
|
|
bool dgps_corr; // 1=dpgs, 0=ntrip
|
|
|
|
// FDs
|
|
int SourceIn; // GpsdClient or GpsDevice
|
|
int CorrIn; // DpgsIn or NtripIn
|
|
int TrackOut; //
|
|
|
|
// UDP broadcast (data)
|
|
UdpCaster Bcast;
|
|
|
|
// misc
|
|
int clockset; // set to set clock from GPS
|
|
int msgcount;
|
|
|
|
// private methods
|
|
|
|
// static data
|
|
|
|
// public methods
|
|
public:
|
|
// constructors
|
|
GpsDaemon();
|
|
|
|
// destructor
|
|
virtual ~GpsDaemon();
|
|
|
|
// virtual functions
|
|
int ServerTimeout(void);
|
|
int ServerSocket(void);
|
|
int ClientIn( int sock, const char *buf, int n );
|
|
int ClientUp( int sock );
|
|
void ClientDown( int sock );
|
|
void ClientCast( const char *buf, int n );
|
|
|
|
// parser notifications
|
|
void PositionListener( const GpsPoint &Pos, const ErrorInfo &Err );
|
|
void TimeListener( const struct timeval &Time );
|
|
|
|
// public methods
|
|
void SetClock( void ) {clockset=1;};
|
|
int GpsOpen( const char *dev, int baud=38400 );
|
|
int GpsBroadcast( const char *host = NULL );
|
|
|
|
// corrections
|
|
int DgpsConnect( const char *host );
|
|
void DgpsDisconnect( void );
|
|
void DgpsReconnect( void );
|
|
int DgpsListen( const char *host = NULL );
|
|
|
|
// static methods
|
|
|
|
// private methods
|
|
private:
|
|
};
|
|
|
|
#endif
|