diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-03-18 13:57:13 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-03-18 13:57:13 -0400 |
commit | cf684b2a9909561a537a5189c4a2b6a76e3c105d (patch) | |
tree | 52c6271ecb6331cf77a0cf3a2db00df194322455 | |
parent | cd86d4410bcff417de15a0fc5eb905ef56c26596 (diff) | |
download | gpsd-cf684b2a9909561a537a5189c4a2b6a76e3c105d.tar.gz |
Sync the Python and C++ bindings to the C one. Document it properly.
-rw-r--r-- | gps/client.py | 4 | ||||
-rw-r--r-- | libgpsmm.cpp | 19 | ||||
-rw-r--r-- | libgpsmm.h | 7 | ||||
-rw-r--r-- | www/client-howto.txt | 4 |
4 files changed, 23 insertions, 11 deletions
diff --git a/gps/client.py b/gps/client.py index f38e9a1b..45dd3ab7 100644 --- a/gps/client.py +++ b/gps/client.py @@ -109,6 +109,10 @@ class gpscommon: # We got a \n-terminated line return len(self.response) + def data(self): + "Return the client data buffer." + return self.response + def send(self, commands): "Ship commands to the daemon." if not commands.endswith("\n"): diff --git a/libgpsmm.cpp b/libgpsmm.cpp index 1c672c65..4f02361c 100644 --- a/libgpsmm.cpp +++ b/libgpsmm.cpp @@ -13,7 +13,7 @@ struct gps_data_t* gpsmm::gps_inner_open(const char *host, const char *port) { - const bool err = (gps_open(host, port, gps_data()) != 0); + const bool err = (gps_open(host, port, gps_state()) != 0); if ( err ) { return NULL; } @@ -25,7 +25,7 @@ struct gps_data_t* gpsmm::gps_inner_open(const char *host, const char *port) struct gps_data_t* gpsmm::stream(int flags) { - if (gps_stream(gps_data(),flags, NULL)==-1) { + if (gps_stream(gps_state(),flags, NULL)==-1) { return NULL; } else { @@ -35,7 +35,7 @@ struct gps_data_t* gpsmm::stream(int flags) struct gps_data_t* gpsmm::send(const char *request) { - if (gps_send(gps_data(),request)==-1) { + if (gps_send(gps_state(),request)==-1) { return NULL; } else { @@ -45,7 +45,7 @@ struct gps_data_t* gpsmm::send(const char *request) struct gps_data_t* gpsmm::read(void) { - if (gps_read(gps_data())<=0) { + if (gps_read(gps_state())<=0) { // we return null if there was a read() error, if no // data was ready in POLL_NOBLOCK mode, or if the // connection is closed by gpsd @@ -58,12 +58,17 @@ struct gps_data_t* gpsmm::read(void) bool gpsmm::waiting(int timeout) { - return gps_waiting(gps_data(), timeout); + return gps_waiting(gps_state(), timeout); +} + +const char *gpsmm::data(void) +{ + return gps_data(gps_state()); } void gpsmm::clear_fix(void) { - gps_clear_fix(&(gps_data()->fix)); + gps_clear_fix(&(gps_state()->fix)); } void gpsmm::enable_debug(int level, FILE *fp) @@ -76,7 +81,7 @@ void gpsmm::enable_debug(int level, FILE *fp) gpsmm::~gpsmm() { if ( to_user != NULL ) { - gps_close(gps_data()); + gps_close(gps_state()); delete to_user; } } @@ -31,6 +31,7 @@ class LIBQGPSMMSHARED_EXPORT gpsmm { struct gps_data_t* send(const char *request); //put a command to gpsd and return the updated struct struct gps_data_t* stream(int); //set watcher and policy flags struct gps_data_t* read(void); //block until gpsd returns new data, then return the updated struct + const char *data(void); // return the client data buffer int close(void); // close the GPS bool waiting(int); // blocking check for data waiting void clear_fix(void); @@ -40,8 +41,8 @@ class LIBQGPSMMSHARED_EXPORT gpsmm { //integrity loss for the entire class struct gps_data_t* gps_inner_open(const char *host, const char *port); - struct gps_data_t _gps_data; - struct gps_data_t * gps_data() { return &_gps_data; } - struct gps_data_t* backup(void) { *to_user=*gps_data(); return to_user;}; //return the backup copy + struct gps_data_t _gps_state; + struct gps_data_t * gps_state() { return &_gps_state; } + struct gps_data_t* backup(void) { *to_user=*gps_state(); return to_user;}; //return the backup copy }; #endif // _GPSD_GPSMM_H_ diff --git a/www/client-howto.txt b/www/client-howto.txt index 3dbf341f..e3610c2e 100644 --- a/www/client-howto.txt +++ b/www/client-howto.txt @@ -350,6 +350,8 @@ Blocking check with timeout to see in input is waiting. Nonblocking read for data from the daemon. |gps_close() |gpsmm.~gpsmm() |gps.close() | Close the daemon socket and end the session. +|gps_data() |gpsmm.data() |gps.data() | +Get the contents of the client buffer. |gps_enable_debug() |gpsmm_enable_debug() | | Enable debug tracing. Only useful for GPSD developers. |gps_clear_fix() |gpsmm.clear_fix() | | @@ -377,7 +379,7 @@ is on, which is the library's way of telling you that at least one complete JSON response has arrived since the last read. Data may accumulate on the blackboard over multiple reads, -with new TPV reports overwriting old ones;it is guaranteed that +with new TPV reports overwriting old ones; it is guaranteed that overwrites are not partial. Expect this pattern to be replicated in any compiled language with only fixed-extent structures. |