runtc: Output binary as ASCII timestamp/class/hex bytes instead.
authorBert Vermeulen <bert@biot.com>
Wed, 18 Dec 2013 11:04:26 +0000 (12:04 +0100)
committerBert Vermeulen <bert@biot.com>
Wed, 18 Dec 2013 11:04:26 +0000 (12:04 +0100)
This allows for verifying timestamps and classes as well.

tests/runtc.c

index 902ca8e1dd4aff2b1295cbe822dc620c00d9f632..33cc8f260c77948289f7abe6239455ee4539e658 100644 (file)
@@ -191,6 +191,8 @@ static void srd_cb_bin(struct srd_proto_data *pdata, void *cb_data)
 {
        struct srd_proto_data_binary *pdb;
        struct output *op;
+       GString *out;
+       unsigned int i;
 
        DBG("Binary output from %s", pdata->pdo->di->inst_id);
        op = cb_data;
@@ -207,7 +209,15 @@ static void srd_cb_bin(struct srd_proto_data *pdata, void *cb_data)
                 */
                return;
 
-       if (write(op->outfd, pdb->data, pdb->size) == -1)
+       out = g_string_sized_new(128);
+       g_string_printf(out, "%"PRIu64"-%"PRIu64" %s:",
+                       pdata->start_sample, pdata->end_sample,
+                       pdata->pdo->di->inst_id);
+       for (i = 0; i < pdb->size; i++) {
+               g_string_append_printf(out, " %.2x", pdb->data[i]);
+       }
+       g_string_append(out, "\n");
+       if (write(op->outfd, out->str, out->len) == -1)
                ERR("SRD_OUTPUT_BINARY callback write failure!");
 
 }