#include "libsigrok.h"
#include "libsigrok-internal.h"
+/* Message logging helpers with driver-specific prefix string. */
+#define DRIVER_LOG_DOMAIN "demo: "
+#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
+#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
+#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
+#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
+#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
+#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
+
/* TODO: Number of probes should be configurable. */
#define NUM_PROBES 8
struct drv_context *drvc;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
- sr_err("demo: driver context malloc failed.");
+ sr_err("Driver context malloc failed.");
return SR_ERR_MALLOC;
}
ddi->priv = drvc;
sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi) {
- sr_err("demo: %s: sr_dev_inst_new failed", __func__);
+ sr_err("%s: sr_dev_inst_new failed", __func__);
return 0;
}
sdi->driver = ddi;
if (hwcap == SR_HWCAP_SAMPLERATE) {
cur_samplerate = *(const uint64_t *)value;
- sr_dbg("demo: %s: setting samplerate to %" PRIu64, __func__,
+ sr_dbg("%s: setting samplerate to %" PRIu64, __func__,
cur_samplerate);
ret = SR_OK;
} else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) {
limit_msec = 0;
limit_samples = *(const uint64_t *)value;
- sr_dbg("demo: %s: setting limit_samples to %" PRIu64, __func__,
+ sr_dbg("%s: setting limit_samples to %" PRIu64, __func__,
limit_samples);
ret = SR_OK;
} else if (hwcap == SR_HWCAP_LIMIT_MSEC) {
limit_msec = *(const uint64_t *)value;
limit_samples = 0;
- sr_dbg("demo: %s: setting limit_msec to %" PRIu64, __func__,
+ sr_dbg("%s: setting limit_msec to %" PRIu64, __func__,
limit_msec);
ret = SR_OK;
} else if (hwcap == SR_HWCAP_PATTERN_MODE) {
} else {
ret = SR_ERR;
}
- sr_dbg("demo: %s: setting pattern to %d", __func__,
- default_pattern);
+ sr_dbg("%s: setting pattern to %d", __func__, default_pattern);
} else {
ret = SR_ERR;
}
memset(buf, 0xff, size);
break;
default:
- sr_err("demo: %s: unknown pattern %d", __func__,
- devc->sample_generator);
+ sr_err("Unknown pattern: %d.", devc->sample_generator);
break;
}
}
/* TODO: 'devc' is never g_free()'d? */
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
- sr_err("demo: %s: devc malloc failed", __func__);
+ sr_err("%s: devc malloc failed", __func__);
return SR_ERR_MALLOC;
}
if (pipe(devc->pipe_fds)) {
/* TODO: Better error message. */
- sr_err("demo: %s: pipe() failed", __func__);
+ sr_err("%s: pipe() failed", __func__);
return SR_ERR;
}
my_thread = g_thread_try_new("sigrok demo generator",
(GThreadFunc)thread_func, devc, NULL);
if (!my_thread) {
- sr_err("demo: %s: g_thread_try_new failed", __func__);
+ sr_err("%s: g_thread_try_new failed", __func__);
return SR_ERR; /* TODO */
}
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
- sr_err("demo: %s: packet malloc failed", __func__);
+ sr_err("%s: packet malloc failed", __func__);
return SR_ERR_MALLOC;
}
if (!(header = g_try_malloc(sizeof(struct sr_datafeed_header)))) {
- sr_err("demo: %s: header malloc failed", __func__);
+ sr_err("%s: header malloc failed", __func__);
return SR_ERR_MALLOC;
}