- 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 = g_try_malloc0(outsize + 1))) {
- sr_err("analog out: %s: outbuf malloc failed", __func__);
- return SR_ERR_MALLOC;
- }
+ 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;
+ }
+ if (mqflags & SR_MQFLAG_AC)
+ g_string_append_printf(out, " AC");
+ else if (mqflags & SR_MQFLAG_DC)
+ g_string_append_printf(out, " DC");
+ g_string_append_c(out, '\n');