From: Uwe Hermann Date: Tue, 10 Jan 2012 19:44:22 +0000 (+0100) Subject: srd: Finish consistency rename to ANN/PROTO. X-Git-Tag: libsigrokdecode-0.1.0~180 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=94d43b37bd34263f5ed9f7135aac5fe7413c7f07;p=libsigrokdecode.git srd: Finish consistency rename to ANN/PROTO. --- diff --git a/controller.c b/controller.c index 20364f7..07bf6f2 100644 --- a/controller.c +++ b/controller.c @@ -376,7 +376,7 @@ int srd_session_feed(uint64_t timeoffset, uint64_t duration, uint8_t *inbuf, int pd_add(struct srd_decoder_instance *di, int output_type, - char *protocol_id) + char *proto_id) { struct srd_pd_output *pdo; @@ -387,7 +387,7 @@ int pd_add(struct srd_decoder_instance *di, int output_type, pdo->pdo_id = g_slist_length(di->pd_output); pdo->output_type = output_type; pdo->decoder = di->decoder; - pdo->protocol_id = g_strdup(protocol_id); + pdo->proto_id = g_strdup(proto_id); di->pd_output = g_slist_append(di->pd_output, pdo); return pdo->pdo_id; diff --git a/decoders/ddc.py b/decoders/ddc.py index c4978c9..58c74a4 100644 --- a/decoders/ddc.py +++ b/decoders/ddc.py @@ -45,7 +45,7 @@ class Decoder(sigrokdecode.Decoder): self.state = None def start(self, metadata): - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'ddc') + self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'ddc') def decode(self, start_sample, end_sample, i2c_data): try: diff --git a/decoders/i2c.py b/decoders/i2c.py index 5e63fdf..60558c5 100644 --- a/decoders/i2c.py +++ b/decoders/i2c.py @@ -162,8 +162,8 @@ class Decoder(sigrokdecode.Decoder): self.oldsda = None def start(self, metadata): - self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'i2c') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'i2c') + self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'i2c') + self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'i2c') def report(self): pass diff --git a/decoders/mx25lxx05d.py b/decoders/mx25lxx05d.py index 7ffbfc1..bd1ce16 100644 --- a/decoders/mx25lxx05d.py +++ b/decoders/mx25lxx05d.py @@ -179,8 +179,8 @@ class Decoder(sigrokdecode.Decoder): self.out = [] def start(self, metadata): - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'mx25lxx05d') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'mx25lxx05d') + # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'mx25lxx05d') + self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'mx25lxx05d') def report(self): pass diff --git a/decoders/nunchuk.py b/decoders/nunchuk.py index 111768b..cd2c064 100644 --- a/decoders/nunchuk.py +++ b/decoders/nunchuk.py @@ -87,8 +87,8 @@ class Decoder(sigrokdecode.Decoder): self.databytecount = 0 def start(self, metadata): - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'nunchuk') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'nunchuk') + # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'nunchuk') + self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'nunchuk') def report(self): pass diff --git a/decoders/pan1321.py b/decoders/pan1321.py index edd4162..3c09310 100644 --- a/decoders/pan1321.py +++ b/decoders/pan1321.py @@ -56,8 +56,8 @@ class Decoder(sigrokdecode.Decoder): self.cmd = '' def start(self, metadata): - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'pan1321') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'pan1321') + # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'pan1321') + self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'pan1321') def report(self): pass diff --git a/decoders/spi.py b/decoders/spi.py index 95302ce..a866767 100644 --- a/decoders/spi.py +++ b/decoders/spi.py @@ -46,8 +46,8 @@ class Decoder(sigrokdecode.Decoder): self.out_ann = None def start(self, metadata): - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'spi') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'spi') + # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'spi') + self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'spi') def report(self): return 'SPI: %d bytes received' % self.bytesreceived diff --git a/decoders/srd_usb.py b/decoders/srd_usb.py index c68e82b..c97ef73 100644 --- a/decoders/srd_usb.py +++ b/decoders/srd_usb.py @@ -123,8 +123,8 @@ class Decoder(sigrokdecode.Decoder): def start(self, metadata): self.rate = metadata['samplerate'] - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'usb') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'usb') + # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'usb') + self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'usb') if self.rate < 48000000: raise Exception("Sample rate not sufficient for USB decoding") # Initialise decoder state. diff --git a/decoders/transitioncounter.py b/decoders/transitioncounter.py index 7ad16fd..9d437d1 100644 --- a/decoders/transitioncounter.py +++ b/decoders/transitioncounter.py @@ -42,8 +42,8 @@ class Decoder(sigrokdecode.Decoder): self.lastsample = None def start(self, metadata): - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'transitioncounter') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'transitioncounter') + # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'transitioncounter') + self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'transitioncounter') def report(self): pass diff --git a/decoders/uart.py b/decoders/uart.py index 896cd0a..1c204dc 100644 --- a/decoders/uart.py +++ b/decoders/uart.py @@ -258,8 +258,8 @@ class Decoder(sigrokdecode.Decoder): def start(self, metadata): self.samplerate = metadata['samplerate'] - self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'uart') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'uart') + self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'uart') + self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'uart') # TODO ### self.baudrate = metadata['baudrate'] diff --git a/module_sigrokdecode.c b/module_sigrokdecode.c index 6b636ad..a3872ab 100644 --- a/module_sigrokdecode.c +++ b/module_sigrokdecode.c @@ -26,7 +26,7 @@ extern PyTypeObject srd_logic_type; static int convert_pyobj(struct srd_decoder_instance *di, PyObject *obj, - int *annotation_format, char ***annotation) + int *ann_format, char ***ann) { PyObject *py_tmp; struct srd_pd_output *pdo; @@ -61,7 +61,7 @@ static int convert_pyobj(struct srd_decoder_instance *di, PyObject *obj, di->decoder->name, ann_id); return SRD_ERR_PYTHON; } - *annotation_format = ann_id; + *ann_format = ann_id; /* Second element must be a list */ py_tmp = PyList_GetItem(obj, 1); @@ -70,7 +70,7 @@ static int convert_pyobj(struct srd_decoder_instance *di, PyObject *obj, di->decoder->name); return SRD_ERR_PYTHON; } - if (py_strlist_to_char(py_tmp, annotation) != SRD_OK) { + if (py_strlist_to_char(py_tmp, ann) != SRD_OK) { srd_err("Protocol decoder %s submitted annotation list, but second element was malformed", di->decoder->name); return SRD_ERR_PYTHON; @@ -85,7 +85,7 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) PyObject *data, *py_res; struct srd_decoder_instance *di, *next_di; struct srd_pd_output *pdo; - struct srd_protocol_data *pdata; + struct srd_proto_data *pdata; uint64_t start_sample, end_sample; int output_id; void (*cb)(); @@ -103,18 +103,18 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) } pdo = l->data; - if (!(pdata = g_try_malloc0(sizeof(struct srd_protocol_data)))) + if (!(pdata = g_try_malloc0(sizeof(struct srd_proto_data)))) return NULL; pdata->start_sample = start_sample; pdata->end_sample = end_sample; pdata->pdo = pdo; switch (pdo->output_type) { - case SRD_OUTPUT_ANNOTATION: + case SRD_OUTPUT_ANN: /* Annotations are only fed to callbacks. */ if ((cb = srd_find_callback(pdo->output_type))) { /* Annotations need converting from PyObject. */ - if (convert_pyobj(di, data, &pdata->annotation_format, + if (convert_pyobj(di, data, &pdata->ann_format, (char ***)&pdata->data) != SRD_OK) { /* An error was already logged. */ break; @@ -122,7 +122,7 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) cb(pdata); } break; - case SRD_OUTPUT_PROTOCOL: + case SRD_OUTPUT_PROTO: for (l = di->next_di; l; l = l->next) { next_di = l->data; /* TODO: is this needed? */ @@ -154,7 +154,7 @@ static PyObject *Decoder_add(PyObject *self, PyObject *args) { PyObject *ret; struct srd_decoder_instance *di; - char *protocol_id; + char *proto_id; int output_type, pdo_id; if (!(di = get_di_by_decobject(self))) { @@ -163,13 +163,13 @@ static PyObject *Decoder_add(PyObject *self, PyObject *args) return NULL; } - if (!PyArg_ParseTuple(args, "is", &output_type, &protocol_id)) { + if (!PyArg_ParseTuple(args, "is", &output_type, &proto_id)) { if (PyErr_Occurred()) PyErr_Print(); return NULL; } - pdo_id = pd_add(di, output_type, protocol_id); + pdo_id = pd_add(di, output_type, proto_id); if (pdo_id < 0) Py_RETURN_NONE; else @@ -230,11 +230,11 @@ PyMODINIT_FUNC PyInit_sigrokdecode(void) return NULL; /* expose output types as symbols in the sigrokdecode module */ - if(PyModule_AddObject(mod, "SRD_OUTPUT_ANNOTATION", - PyLong_FromLong(SRD_OUTPUT_ANNOTATION)) == -1) + if(PyModule_AddObject(mod, "SRD_OUTPUT_ANN", + PyLong_FromLong(SRD_OUTPUT_ANN)) == -1) return NULL; - if(PyModule_AddObject(mod, "SRD_OUTPUT_PROTOCOL", - PyLong_FromLong(SRD_OUTPUT_PROTOCOL)) == -1) + if(PyModule_AddObject(mod, "SRD_OUTPUT_PROTO", + PyLong_FromLong(SRD_OUTPUT_PROTO)) == -1) return NULL; if(PyModule_AddObject(mod, "SRD_OUTPUT_BINARY", PyLong_FromLong(SRD_OUTPUT_BINARY)) == -1) diff --git a/sigrokdecode.h b/sigrokdecode.h index cf52264..a4b5c2c 100644 --- a/sigrokdecode.h +++ b/sigrokdecode.h @@ -64,8 +64,8 @@ extern "C" { #define SRD_LOG_SPEW 5 /**< Output very noisy debug messages. */ enum { - SRD_OUTPUT_ANNOTATION, - SRD_OUTPUT_PROTOCOL, + SRD_OUTPUT_ANN, + SRD_OUTPUT_PROTO, SRD_OUTPUT_BINARY, /* When adding an output type, don't forget to expose it to PDs in: * controller.c:PyInit_sigrokdecode() @@ -135,7 +135,7 @@ struct srd_pd_output { int pdo_id; int output_type; struct srd_decoder *decoder; - char *protocol_id; + char *proto_id; }; typedef struct { @@ -147,17 +147,17 @@ typedef struct { PyObject *sample; } srd_logic; -struct srd_protocol_data { +struct srd_proto_data { uint64_t start_sample; uint64_t end_sample; struct srd_pd_output *pdo; - int annotation_format; + int ann_format; void *data; }; struct srd_pd_callback { int output_type; - void (*callback)(struct srd_protocol_data *); + void (*callback)(struct srd_proto_data *); };