]> sigrok.org Git - libsigrok.git/blobdiff - hardware/common/dmm/metex14.c
Centralise duplicated logging helper defines.
[libsigrok.git] / hardware / common / dmm / metex14.c
index e529727b87e17aa68e06137c53e9c8b136e5bafa..4e66c97c6ae77edb8820c5d0fd4b3e8ea94a200f 100644 (file)
 #include "libsigrok.h"
 #include "libsigrok-internal.h"
 
-/* Message logging helpers with subsystem-specific prefix string. */
-#define LOG_PREFIX "metex14: "
-#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args)
-#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args)
-#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args)
-#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args)
-#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
-#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
+#define LOG_PREFIX "metex14"
 
 static int parse_value(const uint8_t *buf, float *result)
 {
@@ -61,6 +54,10 @@ static int parse_value(const uint8_t *buf, float *result)
        is_ol += (!strcasecmp((const char *)&valstr, "O.L")) ? 1 : 0;
        is_ol += (!strcasecmp((const char *)&valstr, "OL.")) ? 1 : 0;
        is_ol += (!strcasecmp((const char *)&valstr, "OL")) ? 1 : 0;
+       is_ol += (!strcasecmp((const char *)&valstr, "-.OL")) ? 1 : 0;
+       is_ol += (!strcasecmp((const char *)&valstr, "-O.L")) ? 1 : 0;
+       is_ol += (!strcasecmp((const char *)&valstr, "-OL.")) ? 1 : 0;
+       is_ol += (!strcasecmp((const char *)&valstr, "-OL")) ? 1 : 0;
        if (is_ol != 0) {
                sr_spew("Over limit.");
                *result = INFINITY;
@@ -128,6 +125,8 @@ static void parse_flags(const char *buf, struct metex14_info *info)
                info->is_kilo = info->is_ohm = TRUE;
        else if (!strcasecmp(u, "MOhm"))
                info->is_mega = info->is_ohm = TRUE;
+       else if (!strcasecmp(u, "pF"))
+               info->is_pico = info->is_farad = TRUE;
        else if (!strcasecmp(u, "nF"))
                info->is_nano = info->is_farad = TRUE;
        else if (!strcasecmp(u, "uF"))
@@ -148,6 +147,8 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
                         const struct metex14_info *info)
 {
        /* Factors */
+       if (info->is_pico)
+               *floatval /= 1000000000000ULL;
        if (info->is_nano)
                *floatval /= 1000000000;
        if (info->is_micro)
@@ -212,6 +213,7 @@ static gboolean flags_valid(const struct metex14_info *info)
 
        /* Does the packet have more than one multiplier? */
        count = 0;
+       count += (info->is_pico) ? 1 : 0;
        count += (info->is_nano) ? 1 : 0;
        count += (info->is_micro) ? 1 : 0;
        count += (info->is_milli) ? 1 : 0;
@@ -245,6 +247,7 @@ static gboolean flags_valid(const struct metex14_info *info)
        return TRUE;
 }
 
+#ifdef HAVE_LIBSERIALPORT
 SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial)
 {
        const uint8_t wbuf = 'D';
@@ -253,6 +256,7 @@ SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial)
 
        return (serial_write(serial, &wbuf, 1) == 1) ? SR_OK : SR_ERR;
 }
+#endif
 
 SR_PRIV gboolean sr_metex14_packet_valid(const uint8_t *buf)
 {