summaryrefslogtreecommitdiff
path: root/gpspacket.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2006-12-07 15:13:10 +0000
committerEric S. Raymond <esr@thyrsus.com>2006-12-07 15:13:10 +0000
commit716aeb02b4eb7cbef3c21ded87be582c981cfe01 (patch)
tree37358e9eeebbfa738a4bc4fc100ed040f4954df2 /gpspacket.c
parent6f7473acfbd74e2d909ddb9759ed4f0770a6f6a0 (diff)
downloadgpsd-716aeb02b4eb7cbef3c21ded87be582c981cfe01.tar.gz
Give gpspacket.c a real doc string.
Diffstat (limited to 'gpspacket.c')
-rw-r--r--gpspacket.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/gpspacket.c b/gpspacket.c
index 8dd4d857..d38ff778 100644
--- a/gpspacket.c
+++ b/gpspacket.c
@@ -70,15 +70,21 @@ Getter_init(GetterObject *self)
static PyObject *
Getter_get(GetterObject *self, PyObject *args)
{
+ ssize_t len;
int fd;
if (!PyArg_ParseTuple(args, "i;missing or invalid file descriptor argument to gpspacket.get", &fd))
return NULL;
- packet_get(fd, &self->getter);
+ len = packet_get(fd, &self->getter);
if (PyErr_Occurred())
return NULL;
+ if (len == 0) {
+ self->getter.type = BAD_PACKET;
+ self->getter.outbuffer[0] = '\0';
+ }
+
return Py_BuildValue("(i, s)", self->getter.type, self->getter.outbuffer);
}
@@ -220,7 +226,17 @@ static PyMethodDef gpspacket_methods[] = {
};
PyDoc_STRVAR(module_doc,
-"Python binding of the libgpsd module for recognizing GPS packets.");
+"Python binding of the libgpsd module for recognizing GPS packets.\n\
+The new() function returns a new packet-getter instance. Getter instances\n\
+have two methods:\n\
+ get() takes a file descriptor argument and returns a tuple consisting of\n\
+the integer packet type and string packet value. On end of file it returns\n\
+(-1, '').\n\
+ reset() resets the packet-getter to its initial state.\n\
+ The module also has a register_report() function that accepts a callback\n\
+for debug message reporting. The callback will get two arguments, the error\n\
+level of the message and the message itself.\n\
+");
PyMODINIT_FUNC
initgpspacket(void)