#include <sched.h>
#endif
-int debug = FALSE;
-int statistics = FALSE;
-char *coverage_report;
+static int debug = FALSE;
+static int statistics = FALSE;
+static char *coverage_report;
+static struct sr_context *ctx;
struct channel {
char *name;
GSList *missed_lines;
};
-struct cvg *get_mod_cov(PyObject *py_cov, char *module_name);
-void cvg_add(struct cvg *dst, struct cvg *src);
-struct cvg *cvg_new(void);
-gboolean find_missed_line(struct cvg *cvg, char *linespec);
+static struct cvg *get_mod_cov(PyObject *py_cov, char *module_name);
+static void cvg_add(struct cvg *dst, struct cvg *src);
+static struct cvg *cvg_new(void);
+static gboolean find_missed_line(struct cvg *cvg, char *linespec);
static void logmsg(char *prefix, FILE *out, const char *format, va_list args)
{
uint64_t samplerate;
int num_samples;
static int samplecnt = 0;
+ struct sr_dev_driver *driver;
sess = cb_data;
+ driver = sr_dev_inst_driver_get(sdi);
+
switch (packet->type) {
case SR_DF_HEADER:
DBG("Received SR_DF_HEADER");
- if (sr_config_get(sdi->driver, sdi, NULL, SR_CONF_SAMPLERATE,
+ if (sr_config_get(driver, sdi, NULL, SR_CONF_SAMPLERATE,
&gvar) != SR_OK) {
ERR("Getting samplerate failed");
break;
case SR_DF_LOGIC:
logic = packet->payload;
num_samples = logic->length / logic->unitsize;
- DBG("Received SR_DF_LOGIC: %d samples", num_samples);
+ DBG("Received SR_DF_LOGIC (%"PRIu64" bytes, unitsize = %d).",
+ logic->length, logic->unitsize);
srd_session_send(sess, samplecnt, samplecnt + num_samples,
logic->data, logic->length);
samplecnt += logic->length / logic->unitsize;
struct option *option;
GVariant *gvar;
GHashTable *channels, *opts;
- GSList *pdl, *l;
- int idx;
+ GSList *pdl, *l, *devices;
+ int idx, i;
int max_channel;
char **decoder_class;
struct sr_session *sr_sess;
+ gboolean is_number;
+ const char *s;
+ struct sr_dev_inst *sdi;
+ uint64_t unitsize;
+ struct sr_dev_driver *driver;
if (op->outfile) {
if ((op->outfd = open(op->outfile, O_CREAT|O_WRONLY, 0600)) == -1) {
}
}
- if (sr_session_load(infile, &sr_sess) != SR_OK)
+ if (sr_session_load(ctx, infile, &sr_sess) != SR_OK)
return FALSE;
+ sr_session_dev_list(sr_sess, &devices);
+ sdi = devices->data;
+ driver = sr_dev_inst_driver_get(sdi);
+ sr_config_get(driver, sdi, NULL, SR_CONF_CAPTURE_UNITSIZE, &gvar);
+ unitsize = g_variant_get_uint64(gvar);
+ g_variant_unref(gvar);
+
if (srd_session_new(&sess) != SRD_OK)
return FALSE;
sr_session_datafeed_callback_add(sr_sess, sr_cb, sess);
(GDestroyNotify)g_variant_unref);
for (l = pd->options; l; l = l->next) {
option = l->data;
- g_hash_table_insert(opts, option->key, option->value);
+
+ is_number = TRUE;
+ s = g_variant_get_string(option->value, NULL);
+ for (i = 0; i < (int)strlen(s); i++) {
+ if (!isdigit(s[i]))
+ is_number = FALSE;
+ }
+
+ if (is_number) {
+ /* Integer option value */
+ g_hash_table_insert(opts, option->key,
+ g_variant_new_int64(strtoull(s, NULL, 10)));
+ } else {
+ /* String option value */
+ g_hash_table_insert(opts, option->key, option->value);
+ }
}
if (!(di = srd_inst_new(sess, pd->name, opts)))
return FALSE;
g_variant_ref_sink(gvar);
g_hash_table_insert(channels, channel->name, gvar);
}
- if (srd_inst_channel_set_all(di, channels,
- (max_channel + 8) / 8) != SRD_OK)
+
+ if (srd_inst_channel_set_all(di, channels, unitsize) != SRD_OK)
return FALSE;
g_hash_table_destroy(channels);
}
return py_cov;
}
-struct cvg *get_mod_cov(PyObject *py_cov, char *module_name)
+static struct cvg *get_mod_cov(PyObject *py_cov, char *module_name)
{
PyObject *py_mod, *py_pathlist, *py_path, *py_func, *py_pd;
PyObject *py_result, *py_missed, *py_item;
return cvg_mod;
}
-struct cvg *cvg_new(void)
+static struct cvg *cvg_new(void)
{
struct cvg *cvg;
return cvg;
}
-gboolean find_missed_line(struct cvg *cvg, char *linespec)
+static gboolean find_missed_line(struct cvg *cvg, char *linespec)
{
GSList *l;
return FALSE;
}
-void cvg_add(struct cvg *dst, struct cvg *src)
+static void cvg_add(struct cvg *dst, struct cvg *src)
{
GSList *l;
char *linespec;
int main(int argc, char **argv)
{
- struct sr_context *ctx;
PyObject *coverage;
GSList *pdlist;
struct pd *pd;