Output modules: Use message logging helpers.
This commit is contained in:
parent
8e7f1cfd99
commit
a944a84b17
|
@ -19,10 +19,19 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <glib.h>
|
||||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
#include <math.h>
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/analog: "
|
||||
#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)
|
||||
|
||||
struct context {
|
||||
int num_enabled_probes;
|
||||
|
@ -36,12 +45,13 @@ static int init(struct sr_output *o)
|
|||
struct sr_probe *probe;
|
||||
GSList *l;
|
||||
|
||||
sr_spew("output/analog: initializing");
|
||||
sr_spew("Initializing output module.");
|
||||
|
||||
if (!o || !o->sdi)
|
||||
return SR_ERR_ARG;
|
||||
|
||||
if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
|
||||
sr_err("output/analog: Context malloc failed.");
|
||||
sr_err("Output module context malloc failed.");
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
o->internal = ctx;
|
||||
|
@ -91,7 +101,6 @@ static void si_printf(float value, GString *out, char *unitstr)
|
|||
|
||||
static void fancyprint(int unit, int mqflags, float value, GString *out)
|
||||
{
|
||||
|
||||
switch (unit) {
|
||||
case SR_UNIT_VOLT:
|
||||
si_printf(value, out, "V");
|
||||
|
@ -174,7 +183,6 @@ static void fancyprint(int unit, int mqflags, float value, GString *out)
|
|||
else if (mqflags & SR_MQFLAG_DC)
|
||||
g_string_append_printf(out, " DC");
|
||||
g_string_append_c(out, '\n');
|
||||
|
||||
}
|
||||
|
||||
static GString *receive(struct sr_output *o, const struct sr_dev_inst *sdi,
|
||||
|
@ -234,7 +242,6 @@ static int cleanup(struct sr_output *o)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
|
||||
SR_PRIV struct sr_output_format output_analog = {
|
||||
.id = "analog",
|
||||
.description = "Analog data",
|
||||
|
|
|
@ -24,6 +24,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/binary: "
|
||||
#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)
|
||||
|
||||
static int data(struct sr_output *o, const uint8_t *data_in,
|
||||
uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
|
||||
{
|
||||
|
@ -32,22 +41,22 @@ static int data(struct sr_output *o, const uint8_t *data_in,
|
|||
(void)o;
|
||||
|
||||
if (!data_in) {
|
||||
sr_err("binary out: %s: data_in was NULL", __func__);
|
||||
sr_err("%s: data_in was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!length_out) {
|
||||
sr_err("binary out: %s: length_out was NULL", __func__);
|
||||
sr_err("%s: length_out was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (length_in == 0) {
|
||||
sr_err("binary out: %s: length_in was 0", __func__);
|
||||
sr_err("%s: length_in was 0", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(outbuf = g_try_malloc0(length_in))) {
|
||||
sr_err("binary out: %s: outbuf malloc failed", __func__);
|
||||
sr_err("%s: outbuf malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/chronovu-la8: "
|
||||
#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)
|
||||
|
||||
struct context {
|
||||
unsigned int num_enabled_probes;
|
||||
unsigned int unitsize;
|
||||
|
@ -48,7 +57,7 @@ static int is_valid_samplerate(uint64_t samplerate)
|
|||
return 1;
|
||||
}
|
||||
|
||||
sr_warn("la8 out: %s: invalid samplerate (%" PRIu64 "Hz)",
|
||||
sr_warn("%s: invalid samplerate (%" PRIu64 "Hz)",
|
||||
__func__, samplerate);
|
||||
|
||||
return 0;
|
||||
|
@ -68,13 +77,12 @@ static int is_valid_samplerate(uint64_t samplerate)
|
|||
static uint8_t samplerate_to_divcount(uint64_t samplerate)
|
||||
{
|
||||
if (samplerate == 0) {
|
||||
sr_warn("la8 out: %s: samplerate was 0", __func__);
|
||||
sr_warn("%s: samplerate was 0", __func__);
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
if (!is_valid_samplerate(samplerate)) {
|
||||
sr_warn("la8 out: %s: can't get divcount, samplerate invalid",
|
||||
__func__);
|
||||
sr_warn("%s: can't get divcount, samplerate invalid", __func__);
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
|
@ -89,22 +97,22 @@ static int init(struct sr_output *o)
|
|||
uint64_t *samplerate;
|
||||
|
||||
if (!o) {
|
||||
sr_warn("la8 out: %s: o was NULL", __func__);
|
||||
sr_warn("%s: o was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!o->sdi) {
|
||||
sr_warn("la8 out: %s: o->sdi was NULL", __func__);
|
||||
sr_warn("%s: o->sdi was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!o->sdi->driver) {
|
||||
sr_warn("la8 out: %s: o->sdi->driver was NULL", __func__);
|
||||
sr_warn("%s: o->sdi->driver was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
|
||||
sr_warn("la8 out: %s: ctx malloc failed", __func__);
|
||||
sr_warn("%s: ctx malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -137,28 +145,28 @@ static int event(struct sr_output *o, int event_type, uint8_t **data_out,
|
|||
uint8_t *outbuf;
|
||||
|
||||
if (!o) {
|
||||
sr_warn("la8 out: %s: o was NULL", __func__);
|
||||
sr_warn("%s: o was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(ctx = o->internal)) {
|
||||
sr_warn("la8 out: %s: o->internal was NULL", __func__);
|
||||
sr_warn("%s: o->internal was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!data_out) {
|
||||
sr_warn("la8 out: %s: data_out was NULL", __func__);
|
||||
sr_warn("%s: data_out was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
switch (event_type) {
|
||||
case SR_DF_TRIGGER:
|
||||
sr_dbg("la8 out: %s: SR_DF_TRIGGER event", __func__);
|
||||
sr_dbg("%s: SR_DF_TRIGGER event", __func__);
|
||||
/* Save the trigger point for later (SR_DF_END). */
|
||||
ctx->trigger_point = 0; /* TODO: Store _actual_ value. */
|
||||
break;
|
||||
case SR_DF_END:
|
||||
sr_dbg("la8 out: %s: SR_DF_END event", __func__);
|
||||
sr_dbg("%s: SR_DF_END event", __func__);
|
||||
if (!(outbuf = g_try_malloc(4 + 1))) {
|
||||
sr_warn("la8 out: %s: outbuf malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
|
@ -167,7 +175,7 @@ static int event(struct sr_output *o, int event_type, uint8_t **data_out,
|
|||
/* One byte for the 'divcount' value. */
|
||||
outbuf[0] = samplerate_to_divcount(ctx->samplerate);
|
||||
// if (outbuf[0] == 0xff) {
|
||||
// sr_warn("la8 out: %s: invalid divcount", __func__);
|
||||
// sr_warn("%s: invalid divcount", __func__);
|
||||
// return SR_ERR;
|
||||
// }
|
||||
|
||||
|
@ -183,7 +191,7 @@ static int event(struct sr_output *o, int event_type, uint8_t **data_out,
|
|||
o->internal = NULL;
|
||||
break;
|
||||
default:
|
||||
sr_warn("la8 out: %s: unsupported event type: %d", __func__,
|
||||
sr_warn("%s: unsupported event type: %d", __func__,
|
||||
event_type);
|
||||
*data_out = NULL;
|
||||
*length_out = 0;
|
||||
|
@ -200,22 +208,22 @@ static int data(struct sr_output *o, const uint8_t *data_in,
|
|||
uint8_t *outbuf;
|
||||
|
||||
if (!o) {
|
||||
sr_warn("la8 out: %s: o was NULL", __func__);
|
||||
sr_warn("%s: o was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(ctx = o->internal)) {
|
||||
sr_warn("la8 out: %s: o->internal was NULL", __func__);
|
||||
sr_warn("%s: o->internal was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!data_in) {
|
||||
sr_warn("la8 out: %s: data_in was NULL", __func__);
|
||||
sr_warn("%s: data_in was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(outbuf = g_try_malloc0(length_in))) {
|
||||
sr_warn("la8 out: %s: outbuf malloc failed", __func__);
|
||||
sr_warn("%s: outbuf malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
|
36
output/csv.c
36
output/csv.c
|
@ -25,6 +25,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/csv: "
|
||||
#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)
|
||||
|
||||
struct context {
|
||||
unsigned int num_enabled_probes;
|
||||
unsigned int unitsize;
|
||||
|
@ -57,22 +66,22 @@ static int init(struct sr_output *o)
|
|||
unsigned int i;
|
||||
|
||||
if (!o) {
|
||||
sr_err("csv out: %s: o was NULL", __func__);
|
||||
sr_err("%s: o was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!o->sdi) {
|
||||
sr_err("csv out: %s: o->sdi was NULL", __func__);
|
||||
sr_err("%s: o->sdi was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!o->sdi->driver) {
|
||||
sr_err("csv out: %s: o->sdi->driver was NULL", __func__);
|
||||
sr_err("%s: o->sdi->driver was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
|
||||
sr_err("csv out: %s: ctx malloc failed", __func__);
|
||||
sr_err("%s: ctx malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -124,29 +133,29 @@ static int event(struct sr_output *o, int event_type, uint8_t **data_out,
|
|||
struct context *ctx;
|
||||
|
||||
if (!o) {
|
||||
sr_err("csv out: %s: o was NULL", __func__);
|
||||
sr_err("%s: o was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(ctx = o->internal)) {
|
||||
sr_err("csv out: %s: o->internal was NULL", __func__);
|
||||
sr_err("%s: o->internal was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!data_out) {
|
||||
sr_err("csv out: %s: data_out was NULL", __func__);
|
||||
sr_err("%s: data_out was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
switch (event_type) {
|
||||
case SR_DF_TRIGGER:
|
||||
sr_dbg("csv out: %s: SR_DF_TRIGGER event", __func__);
|
||||
sr_dbg("%s: SR_DF_TRIGGER event", __func__);
|
||||
/* TODO */
|
||||
*data_out = NULL;
|
||||
*length_out = 0;
|
||||
break;
|
||||
case SR_DF_END:
|
||||
sr_dbg("csv out: %s: SR_DF_END event", __func__);
|
||||
sr_dbg("%s: SR_DF_END event", __func__);
|
||||
/* TODO */
|
||||
*data_out = NULL;
|
||||
*length_out = 0;
|
||||
|
@ -154,8 +163,7 @@ static int event(struct sr_output *o, int event_type, uint8_t **data_out,
|
|||
o->internal = NULL;
|
||||
break;
|
||||
default:
|
||||
sr_err("csv out: %s: unsupported event type: %d", __func__,
|
||||
event_type);
|
||||
sr_err("%s: unsupported event type: %d", __func__, event_type);
|
||||
*data_out = NULL;
|
||||
*length_out = 0;
|
||||
break;
|
||||
|
@ -173,17 +181,17 @@ static int data(struct sr_output *o, const uint8_t *data_in,
|
|||
int j;
|
||||
|
||||
if (!o) {
|
||||
sr_err("csv out: %s: o was NULL", __func__);
|
||||
sr_err("%s: o was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(ctx = o->internal)) {
|
||||
sr_err("csv out: %s: o->internal was NULL", __func__);
|
||||
sr_err("%s: o->internal was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!data_in) {
|
||||
sr_err("csv out: %s: data_in was NULL", __func__);
|
||||
sr_err("%s: data_in was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/gnuplot: "
|
||||
#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)
|
||||
|
||||
struct context {
|
||||
unsigned int num_enabled_probes;
|
||||
unsigned int unitsize;
|
||||
|
@ -62,27 +71,27 @@ static int init(struct sr_output *o)
|
|||
time_t t;
|
||||
|
||||
if (!o) {
|
||||
sr_err("gnuplot out: %s: o was NULL", __func__);
|
||||
sr_err("%s: o was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!o->sdi) {
|
||||
sr_err("gnuplot out: %s: o->sdi was NULL", __func__);
|
||||
sr_err("%s: o->sdi was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!o->sdi->driver) {
|
||||
sr_err("gnuplot out: %s: o->sdi->driver was NULL", __func__);
|
||||
sr_err("%s: o->sdi->driver was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
|
||||
sr_err("gnuplot out: %s: ctx malloc failed", __func__);
|
||||
sr_err("%s: ctx malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
if (!(ctx->header = g_try_malloc0(MAX_HEADER_LEN + 1))) {
|
||||
sr_err("gnuplot out: %s: ctx->header malloc failed", __func__);
|
||||
sr_err("%s: ctx->header malloc failed", __func__);
|
||||
g_free(ctx);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
@ -104,8 +113,7 @@ static int init(struct sr_output *o)
|
|||
o->sdi->driver->info_get(SR_DI_CUR_SAMPLERATE,
|
||||
(const void **)&samplerate, o->sdi);
|
||||
if (!(frequency_s = sr_samplerate_string(*samplerate))) {
|
||||
sr_err("gnuplot out: %s: sr_samplerate_string failed",
|
||||
__func__);
|
||||
sr_err("%s: sr_samplerate_string failed", __func__);
|
||||
g_free(ctx->header);
|
||||
g_free(ctx);
|
||||
return SR_ERR;
|
||||
|
@ -123,7 +131,7 @@ static int init(struct sr_output *o)
|
|||
}
|
||||
|
||||
if (!(frequency_s = sr_period_string(*samplerate))) {
|
||||
sr_err("gnuplot out: %s: sr_period_string failed", __func__);
|
||||
sr_err("%s: sr_period_string failed", __func__);
|
||||
g_free(ctx->header);
|
||||
g_free(ctx);
|
||||
return SR_ERR;
|
||||
|
@ -136,7 +144,7 @@ static int init(struct sr_output *o)
|
|||
g_free(frequency_s);
|
||||
|
||||
if (b < 0) {
|
||||
sr_err("gnuplot out: %s: sprintf failed", __func__);
|
||||
sr_err("%s: sprintf failed", __func__);
|
||||
g_free(ctx->header);
|
||||
g_free(ctx);
|
||||
return SR_ERR;
|
||||
|
@ -149,17 +157,17 @@ static int event(struct sr_output *o, int event_type, uint8_t **data_out,
|
|||
uint64_t *length_out)
|
||||
{
|
||||
if (!o) {
|
||||
sr_err("gnuplot out: %s: o was NULL", __func__);
|
||||
sr_err("%s: o was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!data_out) {
|
||||
sr_err("gnuplot out: %s: data_out was NULL", __func__);
|
||||
sr_err("%s: data_out was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!length_out) {
|
||||
sr_err("gnuplot out: %s: length_out was NULL", __func__);
|
||||
sr_err("%s: length_out was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
|
@ -172,8 +180,7 @@ static int event(struct sr_output *o, int event_type, uint8_t **data_out,
|
|||
o->internal = NULL;
|
||||
break;
|
||||
default:
|
||||
sr_err("gnuplot out: %s: unsupported event type: %d",
|
||||
__func__, event_type);
|
||||
sr_err("%s: unsupported event type: %d", __func__, event_type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -193,27 +200,27 @@ static int data(struct sr_output *o, const uint8_t *data_in,
|
|||
uint8_t *outbuf, *c;
|
||||
|
||||
if (!o) {
|
||||
sr_err("gnuplot out: %s: o was NULL", __func__);
|
||||
sr_err("%s: o was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!o->internal) {
|
||||
sr_err("gnuplot out: %s: o->internal was NULL", __func__);
|
||||
sr_err("%s: o->internal was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!data_in) {
|
||||
sr_err("gnuplot out: %s: data_in was NULL", __func__);
|
||||
sr_err("%s: data_in was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!data_out) {
|
||||
sr_err("gnuplot out: %s: data_out was NULL", __func__);
|
||||
sr_err("%s: data_out was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!length_out) {
|
||||
sr_err("gnuplot out: %s: length_out was NULL", __func__);
|
||||
sr_err("%s: length_out was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
|
@ -224,7 +231,7 @@ static int data(struct sr_output *o, const uint8_t *data_in,
|
|||
outsize += strlen(ctx->header);
|
||||
|
||||
if (!(outbuf = g_try_malloc0(outsize))) {
|
||||
sr_err("gnuplot out: %s: outbuf malloc failed", __func__);
|
||||
sr_err("%s: outbuf malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
|
11
output/ols.c
11
output/ols.c
|
@ -31,6 +31,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/ols: "
|
||||
#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)
|
||||
|
||||
struct context {
|
||||
GString *header;
|
||||
uint64_t num_samples;
|
||||
|
@ -46,7 +55,7 @@ static int init(struct sr_output *o)
|
|||
int num_enabled_probes;
|
||||
|
||||
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
|
||||
sr_err("ols out: %s: ctx malloc failed", __func__);
|
||||
sr_err("%s: ctx malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
o->internal = ctx;
|
||||
|
|
|
@ -25,6 +25,15 @@
|
|||
#include "libsigrok-internal.h"
|
||||
#include "text.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/ascii: "
|
||||
#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)
|
||||
|
||||
SR_PRIV int init_ascii(struct sr_output *o)
|
||||
{
|
||||
return init(o, DEFAULT_BPL_ASCII, MODE_ASCII);
|
||||
|
@ -51,7 +60,7 @@ SR_PRIV int data_ascii(struct sr_output *o, const uint8_t *data_in,
|
|||
* (ctx->num_enabled_probes * max_linelen);
|
||||
|
||||
if (!(outbuf = g_try_malloc0(outsize + 1))) {
|
||||
sr_err("ascii out: %s: outbuf malloc failed", __func__);
|
||||
sr_err("%s: outbuf malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -108,8 +117,7 @@ SR_PRIV int data_ascii(struct sr_output *o, const uint8_t *data_in,
|
|||
ctx->prevsample = sample;
|
||||
}
|
||||
} else {
|
||||
sr_info("ascii out: short buffer (length_in=%" PRIu64 ")",
|
||||
length_in);
|
||||
sr_info("Short buffer (length_in=%" PRIu64 ").", length_in);
|
||||
}
|
||||
|
||||
*data_out = outbuf;
|
||||
|
|
|
@ -25,6 +25,15 @@
|
|||
#include "libsigrok-internal.h"
|
||||
#include "text.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/bits: "
|
||||
#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)
|
||||
|
||||
SR_PRIV int init_bits(struct sr_output *o)
|
||||
{
|
||||
return init(o, DEFAULT_BPL_BITS, MODE_BITS);
|
||||
|
@ -51,7 +60,7 @@ SR_PRIV int data_bits(struct sr_output *o, const uint8_t *data_in,
|
|||
* (ctx->num_enabled_probes * max_linelen);
|
||||
|
||||
if (!(outbuf = g_try_malloc0(outsize + 1))) {
|
||||
sr_err("bits out: %s: outbuf malloc failed", __func__);
|
||||
sr_err("%s: outbuf malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -95,8 +104,7 @@ SR_PRIV int data_bits(struct sr_output *o, const uint8_t *data_in,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
sr_info("bits out: short buffer (length_in=%" PRIu64 ")",
|
||||
length_in);
|
||||
sr_info("Short buffer (length_in=%" PRIu64 ").", length_in);
|
||||
}
|
||||
|
||||
*data_out = outbuf;
|
||||
|
|
|
@ -25,6 +25,15 @@
|
|||
#include "libsigrok-internal.h"
|
||||
#include "text.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/hex: "
|
||||
#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)
|
||||
|
||||
SR_PRIV int init_hex(struct sr_output *o)
|
||||
{
|
||||
return init(o, DEFAULT_BPL_HEX, MODE_HEX);
|
||||
|
@ -47,7 +56,7 @@ SR_PRIV int data_hex(struct sr_output *o, const uint8_t *data_in,
|
|||
/ ctx->samples_per_line * max_linelen + 512;
|
||||
|
||||
if (!(outbuf = g_try_malloc0(outsize + 1))) {
|
||||
sr_err("hex out: %s: outbuf malloc failed", __func__);
|
||||
sr_err("%s: outbuf malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,15 @@
|
|||
#include "libsigrok-internal.h"
|
||||
#include "text.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/text: "
|
||||
#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)
|
||||
|
||||
SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf)
|
||||
{
|
||||
static int max_probename_len = 0;
|
||||
|
@ -75,7 +84,7 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
|
|||
char *samplerate_s;
|
||||
|
||||
if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
|
||||
sr_err("text out: %s: ctx malloc failed", __func__);
|
||||
sr_err("%s: ctx malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -107,7 +116,7 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
|
|||
ctx->samples_per_line = default_spl;
|
||||
|
||||
if (!(ctx->header = g_try_malloc0(512))) {
|
||||
sr_err("text out: %s: ctx->header malloc failed", __func__);
|
||||
sr_err("%s: ctx->header malloc failed", __func__);
|
||||
ret = SR_ERR_MALLOC;
|
||||
goto err;
|
||||
}
|
||||
|
@ -132,13 +141,13 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
|
|||
|
||||
ctx->linebuf_len = ctx->samples_per_line * 2 + 4;
|
||||
if (!(ctx->linebuf = g_try_malloc0(num_probes * ctx->linebuf_len))) {
|
||||
sr_err("text out: %s: ctx->linebuf malloc failed", __func__);
|
||||
sr_err("%s: ctx->linebuf malloc failed", __func__);
|
||||
ret = SR_ERR_MALLOC;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!(ctx->linevalues = g_try_malloc0(num_probes))) {
|
||||
sr_err("text out: %s: ctx->linevalues malloc failed", __func__);
|
||||
sr_err("%s: ctx->linevalues malloc failed", __func__);
|
||||
ret = SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -169,7 +178,7 @@ SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
|
|||
outsize = ctx->num_enabled_probes
|
||||
* (ctx->samples_per_line + 20) + 512;
|
||||
if (!(outbuf = g_try_malloc0(outsize))) {
|
||||
sr_err("text out: %s: outbuf malloc failed", __func__);
|
||||
sr_err("%s: outbuf malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
flush_linebufs(ctx, outbuf);
|
||||
|
|
15
output/vcd.c
15
output/vcd.c
|
@ -26,6 +26,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "output/vcd: "
|
||||
#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)
|
||||
|
||||
struct context {
|
||||
int num_enabled_probes;
|
||||
int unitsize;
|
||||
|
@ -51,7 +60,7 @@ static int init(struct sr_output *o)
|
|||
time_t t;
|
||||
|
||||
if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
|
||||
sr_err("vcd out: %s: ctx malloc failed", __func__);
|
||||
sr_err("%s: ctx malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -65,7 +74,7 @@ static int init(struct sr_output *o)
|
|||
ctx->probelist[ctx->num_enabled_probes++] = probe->name;
|
||||
}
|
||||
if (ctx->num_enabled_probes > 94) {
|
||||
sr_err("vcd out: VCD only supports 94 probes.");
|
||||
sr_err("VCD only supports 94 probes.");
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
|
@ -130,7 +139,7 @@ static int init(struct sr_output *o)
|
|||
if (!(ctx->prevbits = g_try_malloc0(sizeof(int) * num_probes))) {
|
||||
g_string_free(ctx->header, TRUE);
|
||||
g_free(ctx);
|
||||
sr_err("vcd out: %s: ctx->prevbits malloc failed", __func__);
|
||||
sr_err("%s: ctx->prevbits malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue