GPS Manager API functions


Modules

 gpsd status dbus signal
 Status dbus signal defines
 Value of mode parameter in gpsmgr_is_gpsd_running()
 Return values for gpsmgr_is_gpsd_running()

Functions

int gpsmgr_start (char *path, char **gps_devices, char *ctrl_sock, int debug_level, short port, gpsmgr_t *ctx)
int gpsmgr_stop (gpsmgr_t *ctx)
int gpsmgr_is_gpsd_running (gpsmgr_t *ctx, int *num_of_clients, int mode)
int gpsmgr_set_debug_mode (int mode)
int gpsmgr_request_restart (void)

Function Documentation

int gpsmgr_is_gpsd_running ( gpsmgr_t *  ctx,
int *  num_of_clients,
int  mode 
)

Check if the gpsd is running and optionally return number of clients using this library. The function can be called periodically in application in order to check if the gpsd is running and how many other processes are using gpsd service at the moment.

Parameters:
ctx context returned by gpsmgr_start(), optional. If the param is not given, then num_of_clients cannot be returned.
num_of_clients if user supplies this then the API will place number of library users to it (only when mode is set to GPSMGR_MODE_JUST_CHECK)
mode if set to GPSMGR_MODE_JUST_CHECK, then the library just checks if the gpsd is running. The value GPSMGR_MODE_LOCK_IF_POSSIBLE means that the library locks the gpsd lockfile (which means that gpsd is running) if the gpsd is not yet running. In this case the caller should call gpsmgr_start() to really start the gpsd.
Return values:
GPSMGR_NOT_RUNNING not running or an error happened
GPSMGR_RUNNING running
GPSMGR_READY_TO_RUN was not running, but is now ready to be run
GPSMGR_RESTART if the system requires that API is to be restarted e.g., because of configuration change etc

int gpsmgr_request_restart ( void   ) 

The function sets flag saying that each process using GPS API should restart itself. Typically this function is called from some managing application which has changed the configuration.

Return values:
0 ok
<0 gpsd pid was invalid

int gpsmgr_set_debug_mode ( int  mode  ) 

Set the debug mode. Debug mode can be activated if the library is compiled with DEBUG defined.

Parameters:
mode new mode (0=no debugging, >0 activate debugging)
Return values:
-1 the program was not compiled with debugging mode
other previous debugging mode value

int gpsmgr_start ( char *  path,
char **  gps_devices,
char *  ctrl_sock,
int  debug_level,
short  port,
gpsmgr_t *  ctx 
)

Start function starts the gps daemon if it is not running. Path points to gpsd location, if it does not start with '/' then $PATH is used when searching the gpsd executable location. The API daemonizes the gpsd (uses fork/exec system call combination).

Parameters:
path name of the program (gpsd) to start (if the path does not start with / then PATH is checked when starting the program)
gps_device list of pointers to device name of the GPS device (like /dev/rfcomm0), so there can be multiple GPS devices configured in the system. The list is null terminated list of null terminated strings.
ctrl_sock control socket location
debug_level gpsd debug level (set to 0 to use the default)
port gpsd port (set to 0 to use the default (2947))
ctx caller must allocate this
Return values:
<0 error, check errno for more details
0 ok

int gpsmgr_stop ( gpsmgr_t *  ctx  ) 

Stop function stops the gps daemon if this is the only user of the gpsd

Parameters:
ctx context returned by gpsmgr_start()
Return values:
<0 error, check errno for more details
0 ok, we were the only one using gpsd
1 ok, there are other users of gpsd that have a master lock
2 ok, there are other users of gpsd but we have a master lock


Generated on Sat Jun 14 12:37:49 2008 for libgpsmgr by  doxygen 1.5.1