- 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;
+ switch (unit) {
+ case SR_UNIT_VOLT:
+ si_printf(value, out, "V");
+ break;
+ case SR_UNIT_AMPERE:
+ si_printf(value, out, "A");
+ break;
+ case SR_UNIT_OHM:
+ si_printf(value, out, "");
+ g_string_append_unichar(out, 0x2126);
+ break;
+ case SR_UNIT_FARAD:
+ si_printf(value, out, "F");
+ break;
+ case SR_UNIT_KELVIN:
+ si_printf(value, out, "K");
+ break;
+ case SR_UNIT_CELSIUS:
+ si_printf(value, out, "");
+ g_string_append_unichar(out, 0x00b0);
+ g_string_append_c(out, 'C');
+ break;
+ case SR_UNIT_FAHRENHEIT:
+ si_printf(value, out, "");
+ g_string_append_unichar(out, 0x00b0);
+ g_string_append_c(out, 'F');
+ break;
+ case SR_UNIT_HERTZ:
+ si_printf(value, out, "Hz");
+ break;
+ case SR_UNIT_PERCENTAGE:
+ g_string_append_printf(out, "%f%%", value);
+ break;
+ case SR_UNIT_BOOLEAN:
+ if (value > 0)
+ g_string_append_printf(out, "TRUE");
+ else
+ g_string_append_printf(out, "FALSE");
+ break;
+ case SR_UNIT_SECOND:
+ si_printf(value, out, "s");
+ break;
+ case SR_UNIT_SIEMENS:
+ si_printf(value, out, "S");
+ break;
+ case SR_UNIT_DECIBEL_MW:
+ si_printf(value, out, "dBu");
+ break;
+ case SR_UNIT_DECIBEL_VOLT:
+ si_printf(value, out, "dBV");
+ break;