static uint64_t limit_samples = 0;
static struct sr_output_format *output_format = NULL;
static int default_output_format = FALSE;
static uint64_t limit_samples = 0;
static struct sr_output_format *output_format = NULL;
static int default_output_format = FALSE;
- if (opt_pds)
- srd_session_start(num_enabled_probes, unitsize,
- header->samplerate);
+ if (opt_pds) {
+ if (srd_session_start(num_enabled_probes, unitsize,
+ header->samplerate) != SRD_OK)
+ sr_session_halt();
+ }
if (o->format->event)
o->format->event(o, SR_DF_TRIGGER, &output_buf,
&output_len);
if (o->format->event)
o->format->event(o, SR_DF_TRIGGER, &output_buf,
&output_len);
goto err_out;
}
pd_name = g_strdup(g_hash_table_lookup(pd_opthash, "sigrok_key"));
g_hash_table_remove(pd_opthash, "sigrok_key");
if (srd_decoder_load(pd_name) != SRD_OK) {
goto err_out;
}
pd_name = g_strdup(g_hash_table_lookup(pd_opthash, "sigrok_key"));
g_hash_table_remove(pd_opthash, "sigrok_key");
if (srd_decoder_load(pd_name) != SRD_OK) {
/* If there are no input formats, return NULL right away. */
inputs = sr_input_list();
if (!inputs) {
/* If there are no input formats, return NULL right away. */
inputs = sr_input_list();
if (!inputs) {
for (i = 0; inputs[i]; i++) {
if (strcasecmp(inputs[i]->id, opt_input_format))
continue;
for (i = 0; inputs[i]; i++) {
if (strcasecmp(inputs[i]->id, opt_input_format))
continue;
- fprintf(stderr, "Error: Specified input file format '%s' is "
- "unknown.\n", opt_input_format);
+ g_critical("Error: specified input file format '%s' is "
+ "unknown.", opt_input_format);
- input_format = determine_input_file_format(opt_input_file,
- opt_input_format);
- if (!input_format) {
- fprintf(stderr, "Error: Couldn't detect input file format.\n");
+ if (!(input_format = determine_input_file_format(opt_input_file,
+ opt_input_format)))
+ /* The exact cause was already logged. */
exit(1);
}
in->format = input_format;
in->param = input_format_param;
if (in->format->init) {
if (in->format->init(in) != SR_OK) {
exit(1);
}
in->format = input_format;
in->param = input_format_param;
if (in->format->init) {
if (in->format->init(in) != SR_OK) {
input_format->loadfile(in, opt_input_file);
if (opt_output_file && default_output_format) {
if (sr_session_save(opt_output_file) != SR_OK)
input_format->loadfile(in, opt_input_file);
if (opt_output_file && default_output_format) {
if (sr_session_save(opt_output_file) != SR_OK)
devspec = g_hash_table_lookup(devargs, "sigrok_key");
dev = parse_devstring(devspec);
if (!dev) {
devspec = g_hash_table_lookup(devargs, "sigrok_key");
dev = parse_devstring(devspec);
if (!dev) {
if (sr_driver_hwcap_exists(dev->driver, SR_HWCAP_LIMIT_MSEC)) {
if (dev->driver->dev_config_set(dev->driver_index,
SR_HWCAP_LIMIT_MSEC, &time_msec) != SR_OK) {
if (sr_driver_hwcap_exists(dev->driver, SR_HWCAP_LIMIT_MSEC)) {
if (dev->driver->dev_config_set(dev->driver_index,
SR_HWCAP_LIMIT_MSEC, &time_msec) != SR_OK) {
sr_session_destroy();
return;
}
if (dev->driver->dev_config_set(dev->driver_index,
SR_HWCAP_LIMIT_SAMPLES, &limit_samples) != SR_OK) {
sr_session_destroy();
return;
}
if (dev->driver->dev_config_set(dev->driver_index,
SR_HWCAP_LIMIT_SAMPLES, &limit_samples) != SR_OK) {
if ((sr_parse_sizestring(opt_samples, &limit_samples) != SR_OK)
|| (dev->driver->dev_config_set(dev->driver_index,
SR_HWCAP_LIMIT_SAMPLES, &limit_samples) != SR_OK)) {
if ((sr_parse_sizestring(opt_samples, &limit_samples) != SR_OK)
|| (dev->driver->dev_config_set(dev->driver_index,
SR_HWCAP_LIMIT_SAMPLES, &limit_samples) != SR_OK)) {
if (dev->driver->dev_config_set(dev->driver_index,
SR_HWCAP_PROBECONFIG, (char *)dev->probes) != SR_OK) {
if (dev->driver->dev_config_set(dev->driver_index,
SR_HWCAP_PROBECONFIG, (char *)dev->probes) != SR_OK) {
* All messages, warnings, errors etc. go to stderr (not stdout) in
* order to not mess up the CLI tool data output, e.g. VCD output.
*/
* All messages, warnings, errors etc. go to stderr (not stdout) in
* order to not mess up the CLI tool data output, e.g. VCD output.
*/
error = NULL;
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, optargs, NULL);
if (!g_option_context_parse(context, &argc, &argv, &error)) {
error = NULL;
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, optargs, NULL);
if (!g_option_context_parse(context, &argc, &argv, &error)) {
return 1;
}
/* Set the loglevel (amount of messages to output) for libsigrok. */
if (sr_log_loglevel_set(opt_loglevel) != SR_OK) {
return 1;
}
/* Set the loglevel (amount of messages to output) for libsigrok. */
if (sr_log_loglevel_set(opt_loglevel) != SR_OK) {
- fprintf(stderr, "cli: %s: sr_log_loglevel_set(%d) failed\n",
- __func__, opt_loglevel);
+ g_critical("sr_log_loglevel_set(%d) failed.", opt_loglevel);
return 1;
}
/* Set the loglevel (amount of messages to output) for libsigrokdecode. */
if (srd_log_loglevel_set(opt_loglevel) != SRD_OK) {
return 1;
}
/* Set the loglevel (amount of messages to output) for libsigrokdecode. */
if (srd_log_loglevel_set(opt_loglevel) != SRD_OK) {
- fprintf(stderr, "cli: %s: srd_log_loglevel_set(%d) failed\n",
- __func__, opt_loglevel);
+ g_critical("srd_log_loglevel_set(%d) failed.", opt_loglevel);
return 1;
}
if (srd_pd_output_callback_add(SRD_OUTPUT_ANN,
show_pd_annotation, NULL) != SRD_OK) {
return 1;
}
if (srd_pd_output_callback_add(SRD_OUTPUT_ANN,
show_pd_annotation, NULL) != SRD_OK) {
pds = g_strsplit(opt_pd_stack, ",", 0);
if (g_strv_length(pds) < 2) {
g_strfreev(pds);
pds = g_strsplit(opt_pd_stack, ",", 0);
if (g_strv_length(pds) < 2) {
g_strfreev(pds);
fmtargs = parse_generic_arg(opt_output_format);
fmtspec = g_hash_table_lookup(fmtargs, "sigrok_key");
if (!fmtspec) {
fmtargs = parse_generic_arg(opt_output_format);
fmtspec = g_hash_table_lookup(fmtargs, "sigrok_key");
if (!fmtspec) {