+ switch (packet->type) {
+ case SR_DF_LOGIC:
+ logic = packet->payload;
+ if (ctx->header) {
+ /*
+ * First data packet: prime the output with the
+ * previously prepared header.
+ */
+ *out = ctx->header;
+ ctx->header = NULL;
+ } else {
+ *out = g_string_sized_new(512);
+ }
+
+ for (i = 0; i <= logic->length - ctx->unitsize; i += ctx->unitsize) {
+ memcpy(&sample, logic->data + i, ctx->unitsize);
+ for (j = 0; j < ctx->num_enabled_probes; j++) {
+ g_string_append_printf(*out, "%d%c",
+ (int)((sample & (1 << j)) >> j),
+ ctx->separator);
+ }
+ g_string_append_printf(*out, "\n");
+ }