int pd_add(struct srd_decoder_instance *di, int output_type,
- char *protocol_id)
+ char *proto_id)
{
struct srd_pd_output *pdo;
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;
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:
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
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
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
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
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
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.
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
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']
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;
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);
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;
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)();
}
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;
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? */
{
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))) {
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
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)
#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()
int pdo_id;
int output_type;
struct srd_decoder *decoder;
- char *protocol_id;
+ char *proto_id;
};
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 *);
};