- 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)
-{
- struct context *ctx;
- unsigned int outsize, offset, p;
- int max_linelen;
- struct sr_analog_sample *sample;
- char *outbuf, c;
-
- ctx = o->internal;
- max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
- + ctx->samples_per_line / 8;
- /*
- * Calculate space needed for probes. Set aside 512 bytes for
- * extra output, e.g. trigger.
- */
- outsize = 512 + (1 + (length_in / ctx->unitsize) / ctx->samples_per_line)
- * (ctx->num_enabled_probes * max_linelen);
-
- if (!(outbuf = calloc(1, outsize + 1)))
- return SR_ERR_MALLOC;
-
- outbuf[0] = '\0';
- if (ctx->header) {
- /* The header is still here, this must be the first packet. */
- strncpy(outbuf, ctx->header, outsize);
- free(ctx->header);
- ctx->header = NULL;
-
- /* Ensure first transition. */
-// memcpy(&ctx->prevsample, data_in, ctx->unitsize);
-// ctx->prevsample = ~ctx->prevsample;
- }
-
- if (length_in >= ctx->unitsize) {
- for (offset = 0; offset <= length_in - ctx->unitsize;
- offset += ctx->unitsize) {
- sample = (struct sr_analog_sample *) (data_in + offset);
- for (p = 0; p < ctx->num_enabled_probes; p++) {
- int val = sample->probes[p].val;
- int res = sample->probes[p].res;
- if (res == 1)
- c = '0' + (val & ((1 << res) - 1));
- else
- /*
- * Scale analog resolution down so it
- * fits 25 letters
- */
- c = 'A' + (((val & ((1 << res) - 1)) /
- (res * res)) / 10);
- ctx->linebuf[p * ctx->linebuf_len +
- ctx->line_offset] = c;
- }
- ctx->line_offset++;
- ctx->spl_cnt++;
-
- /* Add a space every 8th bit. */
- if ((ctx->spl_cnt & 7) == 0) {
- for (p = 0; p < ctx->num_enabled_probes; p++)
- ctx->linebuf[p * ctx->linebuf_len +
- ctx->line_offset] = ' ';
- ctx->line_offset++;
- }