]> sigrok.org Git - libsigrokdecode.git/commitdiff
Temporarily revert API changes in preparation of release.
authorUwe Hermann <redacted>
Sun, 20 Jan 2013 20:26:45 +0000 (21:26 +0100)
committerUwe Hermann <redacted>
Sun, 27 Jan 2013 16:53:56 +0000 (17:53 +0100)
The upcoming libsigrokdecode release should not contain any API changes
so it is compatible with existing released frontends (sigrok-cli 0.3.1).

controller.c
decoder.c
sigrokdecode.h.in
type_logic.c

index c265ae7fe0d305af9cd4cb2a2b307eff1b091123..5d19e7a6a142ced06b04349449480fbc0b25739d 100644 (file)
@@ -330,9 +330,9 @@ static gint compare_probe_id(const struct srd_probe *a, const char *probe_id)
  * it overwrites any probes that were already defined (if any).
  *
  * @param di Decoder instance.
  * it overwrites any probes that were already defined (if any).
  *
  * @param di Decoder instance.
- * @param new_probes A GHashTable of probes to set. Key is probe name, value is
- *                   the probe number. Samples passed to this instance will be
- *                   arranged in this order.
+ * @param probes A GHashTable of probes to set. Key is probe name, value is
+ *               the probe number. Samples passed to this instance will be
+ *               arranged in this order.
  *
  * @return SRD_OK upon success, a (negative) error code otherwise.
  */
  *
  * @return SRD_OK upon success, a (negative) error code otherwise.
  */
@@ -344,7 +344,6 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di,
        struct srd_probe *p;
        int *new_probemap, new_probenum;
        char *probe_id, *probenum_str;
        struct srd_probe *p;
        int *new_probemap, new_probenum;
        char *probe_id, *probenum_str;
-       int i, num_required_probes;
 
        srd_dbg("set probes called for instance %s with list of %d probes",
                di->inst_id, g_hash_table_size(new_probes));
 
        srd_dbg("set probes called for instance %s with list of %d probes",
                di->inst_id, g_hash_table_size(new_probes));
@@ -367,13 +366,6 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di,
                return SRD_ERR_MALLOC;
        }
 
                return SRD_ERR_MALLOC;
        }
 
-       /*
-        * For now, map all indexes to probe -1 (can be overridden later).
-        * This -1 is interpreted as an unspecified probe later.
-        */
-       for (i = 0; i < di->dec_num_probes; i++)
-               new_probemap[i] = -1;
-
        for (l = g_hash_table_get_keys(new_probes); l; l = l->next) {
                probe_id = l->data;
                probenum_str = g_hash_table_lookup(new_probes, probe_id);
        for (l = g_hash_table_get_keys(new_probes); l; l = l->next) {
                probe_id = l->data;
                probenum_str = g_hash_table_lookup(new_probes, probe_id);
@@ -398,17 +390,9 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di,
                }
                p = sl->data;
                new_probemap[p->order] = new_probenum;
                }
                p = sl->data;
                new_probemap[p->order] = new_probenum;
-               srd_dbg("Setting probe mapping: %s (index %d) = probe %d.",
-                       p->id, p->order, new_probenum);
-       }
-
-       srd_dbg("Final probe map:");
-       num_required_probes = g_slist_length(di->decoder->probes);
-       for (i = 0; i < di->dec_num_probes; i++) {
-               srd_dbg(" - index %d = probe %d (%s)", i, new_probemap[i],
-                       (i < num_required_probes) ? "required" : "optional");
+               srd_dbg("setting probe mapping for %d = probe %d", p->order,
+                       new_probenum);
        }
        }
-
        g_free(di->dec_probemap);
        di->dec_probemap = new_probemap;
 
        g_free(di->dec_probemap);
        di->dec_probemap = new_probemap;
 
@@ -418,9 +402,9 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di,
 /**
  * Create a new protocol decoder instance.
  *
 /**
  * Create a new protocol decoder instance.
  *
- * @param decoder_id Decoder 'id' field.
+ * @param id Decoder 'id' field.
  * @param options GHashtable of options which override the defaults set in
  * @param options GHashtable of options which override the defaults set in
- *                the decoder class. May be NULL.
+ *                the decoder class.
  *
  * @return Pointer to a newly allocated struct srd_decoder_inst, or
  *         NULL in case of failure.
  *
  * @return Pointer to a newly allocated struct srd_decoder_inst, or
  *         NULL in case of failure.
@@ -445,13 +429,10 @@ SRD_API struct srd_decoder_inst *srd_inst_new(const char *decoder_id,
                return NULL;
        }
 
                return NULL;
        }
 
+       inst_id = g_hash_table_lookup(options, "id");
        di->decoder = dec;
        di->decoder = dec;
-       if (options) {
-               inst_id = g_hash_table_lookup(options, "id");
-               di->inst_id = g_strdup(inst_id ? inst_id : decoder_id);
-               g_hash_table_remove(options, "id");
-       } else
-               di->inst_id = g_strdup(decoder_id);
+       di->inst_id = g_strdup(inst_id ? inst_id : decoder_id);
+       g_hash_table_remove(options, "id");
 
        /*
         * Prepare a default probe map, where samples come in the
 
        /*
         * Prepare a default probe map, where samples come in the
@@ -480,7 +461,7 @@ SRD_API struct srd_decoder_inst *srd_inst_new(const char *decoder_id,
                return NULL;
        }
 
                return NULL;
        }
 
-       if (options && srd_inst_option_set(di, options) != SRD_OK) {
+       if (srd_inst_option_set(di, options) != SRD_OK) {
                g_free(di->dec_probemap);
                g_free(di);
                return NULL;
                g_free(di->dec_probemap);
                g_free(di);
                return NULL;
@@ -736,8 +717,6 @@ SRD_API int srd_session_start(int num_probes, int unitsize, uint64_t samplerate)
        struct srd_decoder_inst *di;
        int ret;
 
        struct srd_decoder_inst *di;
        int ret;
 
-       ret = SRD_OK;
-
        srd_dbg("Calling start() on all instances with %d probes, "
                "unitsize %d samplerate %d.", num_probes, unitsize, samplerate);
 
        srd_dbg("Calling start() on all instances with %d probes, "
                "unitsize %d samplerate %d.", num_probes, unitsize, samplerate);
 
@@ -756,7 +735,7 @@ SRD_API int srd_session_start(int num_probes, int unitsize, uint64_t samplerate)
                di->data_num_probes = num_probes;
                di->data_unitsize = unitsize;
                di->data_samplerate = samplerate;
                di->data_num_probes = num_probes;
                di->data_unitsize = unitsize;
                di->data_samplerate = samplerate;
-               if ((ret = srd_inst_start(di, args)) != SRD_OK)
+               if ((ret = srd_inst_start(di, args) != SRD_OK))
                        break;
        }
 
                        break;
        }
 
@@ -770,7 +749,7 @@ SRD_API int srd_session_start(int num_probes, int unitsize, uint64_t samplerate)
  *
  * @param start_samplenum The sample number of the first sample in this chunk.
  * @param inbuf Pointer to sample data.
  *
  * @param start_samplenum The sample number of the first sample in this chunk.
  * @param inbuf Pointer to sample data.
- * @param inbuflen Length in bytes of the buffer.
+ * @param inbuf Length in bytes of the buffer.
  *
  * @return SRD_OK upon success, a (negative) error code otherwise.
  */
  *
  * @return SRD_OK upon success, a (negative) error code otherwise.
  */
index cbca0b840376c60de504dcc1bd91cdd449c6bef4..6290add071b64865cb36c9a392d15e7da6440d1f 100644 (file)
--- a/decoder.c
+++ b/decoder.c
@@ -36,7 +36,7 @@ extern SRD_PRIV PyObject *mod_sigrokdecode;
  *
  * @return List of decoders, NULL if none are supported or loaded.
  */
  *
  * @return List of decoders, NULL if none are supported or loaded.
  */
-SRD_API const GSList *srd_decoder_list(void)
+SRD_API GSList *srd_decoder_list(void)
 {
        return pd_list;
 }
 {
        return pd_list;
 }
@@ -53,7 +53,7 @@ SRD_API struct srd_decoder *srd_decoder_get_by_id(const char *id)
        GSList *l;
        struct srd_decoder *dec;
 
        GSList *l;
        struct srd_decoder *dec;
 
-       for (l = pd_list; l; l = l->next) {
+       for (l = srd_decoder_list(); l; l = l->next) {
                dec = l->data;
                if (!strcmp(dec->id, id))
                        return dec;
                dec = l->data;
                if (!strcmp(dec->id, id))
                        return dec;
@@ -124,7 +124,7 @@ err_out:
 /**
  * Load a protocol decoder module into the embedded Python interpreter.
  *
 /**
  * Load a protocol decoder module into the embedded Python interpreter.
  *
- * @param module_name The module name to be loaded.
+ * @param name The module name to be loaded.
  *
  * @return SRD_OK upon success, a (negative) error code otherwise.
  */
  *
  * @return SRD_OK upon success, a (negative) error code otherwise.
  */
@@ -134,8 +134,6 @@ SRD_API int srd_decoder_load(const char *module_name)
        struct srd_decoder *d;
        int alen, ret, i;
        char **ann;
        struct srd_decoder *d;
        int alen, ret, i;
        char **ann;
-       struct srd_probe *p;
-       GSList *l;
 
        srd_dbg("Loading protocol decoder '%s'.", module_name);
 
 
        srd_dbg("Loading protocol decoder '%s'.", module_name);
 
@@ -224,19 +222,6 @@ SRD_API int srd_decoder_load(const char *module_name)
        if (get_probes(d, "optional_probes", &d->opt_probes) != SRD_OK)
                goto err_out;
 
        if (get_probes(d, "optional_probes", &d->opt_probes) != SRD_OK)
                goto err_out;
 
-       /*
-        * Fix order numbers for the optional probes.
-        *
-        * Example:
-        * Required probes: r1, r2, r3. Optional: o1, o2, o3, o4.
-        * 'order' fields in the d->probes list = 0, 1, 2.
-        * 'order' fields in the d->opt_probes list = 3, 4, 5, 6.
-        */
-       for (l = d->opt_probes; l; l = l->next) {
-               p = l->data;
-               p->order += g_slist_length(d->probes);
-       }
-
        /* Store required fields in newly allocated strings. */
        if (py_attr_as_str(d->py_dec, "id", &(d->id)) != SRD_OK)
                goto err_out;
        /* Store required fields in newly allocated strings. */
        if (py_attr_as_str(d->py_dec, "id", &(d->id)) != SRD_OK)
                goto err_out;
@@ -415,7 +400,7 @@ SRD_API int srd_decoder_unload_all(void)
        GSList *l;
        struct srd_decoder *dec;
 
        GSList *l;
        struct srd_decoder *dec;
 
-       for (l = pd_list; l; l = l->next) {
+       for (l = srd_decoder_list(); l; l = l->next) {
                dec = l->data;
                srd_decoder_unload(dec);
        }
                dec = l->data;
                srd_decoder_unload(dec);
        }
index 033e30ee4652e557097c2facd5f62998eebde4db..470332f322acba9c057185370528979ae4c45801 100644 (file)
@@ -268,7 +268,7 @@ SRD_API int srd_pd_output_callback_add(int output_type,
 
 /*--- decoder.c -------------------------------------------------------------*/
 
 
 /*--- decoder.c -------------------------------------------------------------*/
 
-SRD_API const GSList *srd_decoder_list(void);
+SRD_API GSList *srd_decoder_list(void);
 SRD_API struct srd_decoder *srd_decoder_get_by_id(const char *id);
 SRD_API int srd_decoder_load(const char *name);
 SRD_API int srd_decoder_unload(struct srd_decoder *dec);
 SRD_API struct srd_decoder *srd_decoder_get_by_id(const char *id);
 SRD_API int srd_decoder_load(const char *name);
 SRD_API int srd_decoder_unload(struct srd_decoder *dec);
index 098e34d84d3af9d1471fa936ec17a0cec254efa2..b284ebf73d09744215a72784a5567dd246b78235 100644 (file)
@@ -45,26 +45,11 @@ static PyObject *srd_logic_iternext(PyObject *self)
         * Convert the bit-packed sample to an array of bytes, with only 0x01
         * and 0x00 values, so the PD doesn't need to do any bitshifting.
         */
         * Convert the bit-packed sample to an array of bytes, with only 0x01
         * and 0x00 values, so the PD doesn't need to do any bitshifting.
         */
-
-       /* Get probe bits into the 'sample' variable. */
        memcpy(&sample,
               logic->inbuf + logic->itercnt * logic->di->data_unitsize,
               logic->di->data_unitsize);
        memcpy(&sample,
               logic->inbuf + logic->itercnt * logic->di->data_unitsize,
               logic->di->data_unitsize);
-
-       /* All probe values (required + optional) are pre-set to 42. */
-       memset(probe_samples, 42, logic->di->dec_num_probes);
-       /* TODO: None or -1 in Python would be better. */
-
-       /*
-        * Set probe values of specified/used probes to their resp. values.
-        * Unused probe values (those not specified by the user) remain at 42.
-        */
-       for (i = 0; i < logic->di->dec_num_probes; i++) {
-               /* A probemap value of -1 means "unused optional probe". */
-               if (logic->di->dec_probemap[i] == -1)
-                       continue;
+       for (i = 0; i < logic->di->dec_num_probes; i++)
                probe_samples[i] = sample & (1 << logic->di->dec_probemap[i]) ? 1 : 0;
                probe_samples[i] = sample & (1 << logic->di->dec_probemap[i]) ? 1 : 0;
-       }
 
        /* Prepare the next samplenum/sample list in this iteration. */
        py_samplenum =
 
        /* Prepare the next samplenum/sample list in this iteration. */
        py_samplenum =