* out_unitsize, data_out, and length_out are undefined.
*/
SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
- const int *probelist, const unsigned char *data_in,
- uint64_t length_in, char **data_out,
+ const int *probelist, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
uint64_t *length_out)
{
unsigned int in_offset, out_offset;
int line_offset;
int linebuf_len;
char *probelist[SR_MAX_NUM_PROBES + 1];
- char *linebuf;
+ uint8_t *linebuf;
int spl_cnt;
uint8_t *linevalues;
char *header;
enum outputmode mode;
};
-static void flush_linebufs(struct context *ctx, char *outbuf)
+static void flush_linebufs(struct context *ctx, uint8_t *outbuf)
{
static int max_probename_len = 0;
int len, i;
return SR_OK;
}
-static int event(struct sr_output *o, int event_type, char **data_out,
+static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out)
{
struct context *ctx;
int outsize;
- char *outbuf;
+ uint8_t *outbuf;
ctx = o->internal;
switch (event_type) {
return init(o, DEFAULT_BPL_BITS, MODE_BITS);
}
-static int data_bits(struct sr_output *o, const char *data_in,
- uint64_t length_in, char **data_out, uint64_t *length_out)
+static int data_bits(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
+ uint64_t *length_out)
{
struct context *ctx;
unsigned int outsize, offset, p;
int max_linelen;
struct sr_analog_sample *sample;
- char *outbuf, c;
+ uint8_t *outbuf, c;
ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
return init(o, DEFAULT_BPL_HEX, MODE_HEX);
}
-static int data_hex(struct sr_output *o, const char *data_in,
- uint64_t length_in, char **data_out, uint64_t *length_out)
+static int data_hex(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
+ uint64_t *length_out)
{
struct context *ctx;
unsigned int outsize, offset, p;
int max_linelen;
uint64_t sample;
- char *outbuf;
+ uint8_t *outbuf;
ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
return init(o, DEFAULT_BPL_ASCII, MODE_ASCII);
}
-static int data_ascii(struct sr_output *o, const char *data_in,
- uint64_t length_in, char **data_out, uint64_t *length_out)
+static int data_ascii(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
+ uint64_t *length_out)
{
struct context *ctx;
unsigned int outsize, offset, p;
int max_linelen;
uint64_t sample;
- char *outbuf;
+ uint8_t *outbuf;
ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
#include "sigrok.h"
#include "sigrok-internal.h"
-static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
- char **data_out, uint64_t *length_out)
+static int data(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{
- char *outbuf;
+ uint8_t *outbuf;
/* Prevent compiler warnings. */
(void)o;
return 0; /* TODO: SR_OK? */
}
-static int event(struct sr_output *o, int event_type, char **data_out,
+static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out)
{
struct context *ctx;
- char *outbuf;
+ uint8_t *outbuf;
if (!o) {
sr_warn("la8 out: %s: o was NULL", __func__);
return SR_OK;
}
-static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
- char **data_out, uint64_t *length_out)
+static int data(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{
struct context *ctx;
- char *outbuf;
+ uint8_t *outbuf;
if (!o) {
sr_warn("la8 out: %s: o was NULL", __func__);
return 0; /* TODO: SR_OK? */
}
-static int event(struct sr_output *o, int event_type, char **data_out,
+static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out)
{
struct context *ctx;
return SR_OK;
}
-static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
- char **data_out, uint64_t *length_out)
+static int data(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{
struct context *ctx;
GString *outstr;
g_string_append_printf(outstr, "\n");
}
- *data_out = outstr->str;
+ *data_out = (uint8_t *)outstr->str;
*length_out = outstr->len;
g_string_free(outstr, FALSE);
/* Columns / channels */
wbuf[0] = '\0';
for (i = 0; i < ctx->num_enabled_probes; i++) {
- c = (char *)&wbuf + strlen((char *)&wbuf);
+ c = (char *)&wbuf + strlen((const char *)&wbuf);
sprintf(c, "# %d\t\t%s\n", i + 1, ctx->probelist[i]);
}
return 0;
}
-static int event(struct sr_output *o, int event_type, char **data_out,
+static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out)
{
if (!o) {
return SR_OK;
}
-static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
- char **data_out, uint64_t *length_out)
+static int data(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{
struct context *ctx;
unsigned int max_linelen, outsize, p, curbit, i;
uint64_t sample;
static uint64_t samplecount = 0, old_sample = 0;
- char *outbuf, *c;
+ uint8_t *outbuf, *c;
if (!o) {
sr_err("gnuplot out: %s: o was NULL", __func__);
outbuf[0] = '\0';
if (ctx->header) {
/* The header is still here, this must be the first packet. */
- strncpy(outbuf, ctx->header, outsize);
+ strncpy((char *)outbuf, ctx->header, outsize);
g_free(ctx->header);
ctx->header = NULL;
}
old_sample = sample;
/* The first column is a counter (needed for gnuplot). */
- c = outbuf + strlen(outbuf);
- sprintf(c, "%" PRIu64 "\t", samplecount++);
+ c = outbuf + strlen((const char *)outbuf);
+ sprintf((char *)c, "%" PRIu64 "\t", samplecount++);
/* The next columns are the values of all channels. */
for (p = 0; p < ctx->num_enabled_probes; p++) {
curbit = (sample & ((uint64_t) (1 << p))) >> p;
- c = outbuf + strlen(outbuf);
- sprintf(c, "%d ", curbit);
+ c = outbuf + strlen((const char *)outbuf);
+ sprintf((char *)c, "%d ", curbit);
}
- c = outbuf + strlen(outbuf);
- sprintf(c, "\n");
+ c = outbuf + strlen((const char *)outbuf);
+ sprintf((char *)c, "\n");
}
*data_out = outbuf;
- *length_out = strlen(outbuf);
+ *length_out = strlen((const char *)outbuf);
return SR_OK;
}
return 0;
}
-static int analog_data(struct sr_output *o, char *data_in, uint64_t length_in,
- char **data_out, uint64_t *length_out)
+static int analog_data(struct sr_output *o, uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
+ uint64_t *length_out)
{
struct context *ctx;
unsigned int max_linelen, outsize, p, /* curbit, */ i;
// uint64_t sample;
static uint64_t samplecount = 0;
- char *outbuf, *c;
+ uint8_t *outbuf, *c;
struct sr_analog_sample *sample;
ctx = o->internal;
return SR_OK;
}
-static int event(struct sr_output *o, int event_type, char **data_out,
+static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out)
{
struct context *ctx;
return SR_OK;
}
-static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
- char **data_out, uint64_t *length_out)
+static int data(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{
GString *out;
struct context *ctx;
g_string_append_printf(out, "%08x@%"PRIu64"\n",
(uint32_t) sample, ctx->num_samples++);
}
- *data_out = out->str;
+ *data_out = (uint8_t *)out->str;
*length_out = out->len;
g_string_free(out, FALSE);
return init(o, DEFAULT_BPL_ASCII, MODE_ASCII);
}
-SR_PRIV int data_ascii(struct sr_output *o, const char *data_in,
- uint64_t length_in, char **data_out,
+SR_PRIV int data_ascii(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
uint64_t *length_out)
{
struct context *ctx;
unsigned int outsize, offset, p;
int max_linelen;
uint64_t sample;
- char *outbuf;
+ uint8_t *outbuf;
ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
outbuf[0] = '\0';
if (ctx->header) {
/* The header is still here, this must be the first packet. */
- strncpy(outbuf, ctx->header, outsize);
+ strncpy((char *)outbuf, ctx->header, outsize);
g_free(ctx->header);
ctx->header = NULL;
}
}
*data_out = outbuf;
- *length_out = strlen(outbuf);
+ *length_out = strlen((const char *)outbuf);
return SR_OK;
}
return init(o, DEFAULT_BPL_BITS, MODE_BITS);
}
-SR_PRIV int data_bits(struct sr_output *o, const char *data_in,
- uint64_t length_in, char **data_out, uint64_t *length_out)
+SR_PRIV int data_bits(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
+ uint64_t *length_out)
{
struct context *ctx;
unsigned int outsize, offset, p;
int max_linelen;
uint64_t sample;
- char *outbuf, c;
+ uint8_t *outbuf, c;
ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
outbuf[0] = '\0';
if (ctx->header) {
/* The header is still here, this must be the first packet. */
- strncpy(outbuf, ctx->header, outsize);
+ strncpy((char *)outbuf, ctx->header, outsize);
g_free(ctx->header);
ctx->header = NULL;
}
*data_out = outbuf;
- *length_out = strlen(outbuf);
+ *length_out = strlen((const char *)outbuf);
return SR_OK;
}
return init(o, DEFAULT_BPL_HEX, MODE_HEX);
}
-SR_PRIV int data_hex(struct sr_output *o, const char *data_in,
- uint64_t length_in, char **data_out, uint64_t *length_out)
+SR_PRIV int data_hex(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
+ uint64_t *length_out)
{
struct context *ctx;
unsigned int outsize, offset, p;
int max_linelen;
uint64_t sample;
- char *outbuf;
+ uint8_t *outbuf;
ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
outbuf[0] = '\0';
if (ctx->header) {
/* The header is still here, this must be the first packet. */
- strncpy(outbuf, ctx->header, outsize);
+ strncpy((char *)outbuf, ctx->header, outsize);
g_free(ctx->header);
ctx->header = NULL;
}
ctx->linevalues[p] <<= 1;
if (sample & ((uint64_t) 1 << p))
ctx->linevalues[p] |= 1;
- sprintf(ctx->linebuf + (p * ctx->linebuf_len) +
+ sprintf((char *)ctx->linebuf + (p * ctx->linebuf_len) +
ctx->line_offset, "%.2x", ctx->linevalues[p]);
}
ctx->spl_cnt++;
}
*data_out = outbuf;
- *length_out = strlen(outbuf);
+ *length_out = strlen((const char *)outbuf);
return SR_OK;
}
#include "sigrok-internal.h"
#include "text.h"
-SR_PRIV void flush_linebufs(struct context *ctx, char *outbuf)
+SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf)
{
static int max_probename_len = 0;
int len, i;
}
for (i = 0; ctx->probelist[i]; i++) {
- sprintf(outbuf + strlen(outbuf), "%*s:%s\n", max_probename_len,
+ sprintf((char *)outbuf + strlen((const char *)outbuf),
+ "%*s:%s\n", max_probename_len,
ctx->probelist[i], ctx->linebuf + i * ctx->linebuf_len);
}
if (ctx->mode == MODE_ASCII)
space_offset = 0;
- sprintf(outbuf + strlen(outbuf), "T:%*s^\n",
- ctx->mark_trigger + space_offset, "");
+ sprintf((char *)outbuf + strlen((const char *)outbuf),
+ "T:%*s^\n", ctx->mark_trigger + space_offset, "");
}
memset(ctx->linebuf, 0, i * ctx->linebuf_len);
return SR_OK;
}
-SR_PRIV int event(struct sr_output *o, int event_type, char **data_out,
+SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out)
{
struct context *ctx;
int outsize;
- char *outbuf;
+ uint8_t *outbuf;
ctx = o->internal;
switch (event_type) {
}
flush_linebufs(ctx, outbuf);
*data_out = outbuf;
- *length_out = strlen(outbuf);
+ *length_out = strlen((const char *)outbuf);
g_free(o->internal);
o->internal = NULL;
break;
int line_offset;
int linebuf_len;
char *probelist[SR_MAX_NUM_PROBES + 1];
- char *linebuf;
+ uint8_t *linebuf;
int spl_cnt;
uint8_t *linevalues;
char *header;
enum outputmode mode;
};
-SR_PRIV void flush_linebufs(struct context *ctx, char *outbuf);
+SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf);
SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode);
-SR_PRIV int event(struct sr_output *o, int event_type, char **data_out,
+SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out);
SR_PRIV int init_bits(struct sr_output *o);
-SR_PRIV int data_bits(struct sr_output *o, const char *data_in,
- uint64_t length_in, char **data_out,
+SR_PRIV int data_bits(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
uint64_t *length_out);
SR_PRIV int init_hex(struct sr_output *o);
-SR_PRIV int data_hex(struct sr_output *o, const char *data_in,
- uint64_t length_in, char **data_out, uint64_t *length_out);
+SR_PRIV int data_hex(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
+ uint64_t *length_out);
SR_PRIV int init_ascii(struct sr_output *o);
-SR_PRIV int data_ascii(struct sr_output *o, const char *data_in,
- uint64_t length_in, char **data_out,
+SR_PRIV int data_ascii(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
uint64_t *length_out);
#endif
return SR_OK;
}
-static int event(struct sr_output *o, int event_type, char **data_out,
+static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out)
{
- char *outbuf;
+ uint8_t *outbuf;
switch (event_type) {
case SR_DF_END:
- outbuf = g_strdup("$dumpoff\n$end\n");
+ outbuf = (uint8_t *)g_strdup("$dumpoff\n$end\n");
*data_out = outbuf;
- *length_out = strlen(outbuf);
+ *length_out = strlen((const char *)outbuf);
g_free(o->internal);
o->internal = NULL;
break;
return SR_OK;
}
-static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
- char **data_out, uint64_t *length_out)
+static int data(struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{
struct context *ctx;
unsigned int i;
ctx->prevsample = sample;
}
- *data_out = out->str;
+ *data_out = (uint8_t *)out->str;
*length_out = out->len;
g_string_free(out, FALSE);
/*--- filter.c --------------------------------------------------------------*/
SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
- const int *probelist, const unsigned char *data_in,
- uint64_t length_in, char **data_out,
+ const int *probelist, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
uint64_t *length_out);
/*--- hwdriver.c ------------------------------------------------------------*/
char *description;
int df_type;
int (*init) (struct sr_output *o);
- int (*data) (struct sr_output *o, const char *data_in,
- uint64_t length_in, char **data_out, uint64_t *length_out);
- int (*event) (struct sr_output *o, int event_type, char **data_out,
+ int (*data) (struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
+ uint64_t *length_out);
+ int (*event) (struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out);
};