]> sigrok.org Git - libsigrok.git/blobdiff - src/dmm/asycii.c
Doxygen: Properly mark a few symbols as private.
[libsigrok.git] / src / dmm / asycii.c
index 329f37e9e2964357704aeafa394e68ea671dfb88..96a462c5e6d2b4a666a220e319be58f1bf024d9e 100644 (file)
@@ -60,7 +60,8 @@ static int parse_value(const char *buf, struct asycii_info *info,
 {
        char valstr[7 + 1];
        const char *valp;
-       int i, cnt, is_ol, dot_pos;
+       int i, cnt, is_ol;
+       const char *dot_pos;
 
        /*
         * Strip all spaces from bytes 0-6. By copying all
@@ -102,12 +103,13 @@ static int parse_value(const char *buf, struct asycii_info *info,
                sr_spew("%s(), cannot convert number", __func__);
                return SR_ERR_DATA;
        }
-       dot_pos = strcspn(valstr, ".");
-       if (dot_pos < cnt)
-               *exponent = -(cnt - dot_pos - 1);
+       dot_pos = g_strstr_len(valstr, -1, ".");
+       if (dot_pos)
+               *exponent = -(valstr + strlen(valstr) - dot_pos - 1);
        else
                *exponent = 0;
-       sr_spew("%s(), display value is %f", __func__, *result);
+       sr_spew("%s(), display value is %f, exponent %d",
+               __func__, *result, *exponent);
        return SR_OK;
 }
 
@@ -377,7 +379,7 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
        if (info->is_dc)
                analog->meaning->mqflags |= SR_MQFLAG_DC;
        if (info->is_diode)
-               analog->meaning->mqflags |= SR_MQFLAG_DIODE;
+               analog->meaning->mqflags |= SR_MQFLAG_DIODE | SR_MQFLAG_DC;
        if (info->is_peak_max)
                analog->meaning->mqflags |= SR_MQFLAG_MAX;
        if (info->is_peak_min)
@@ -444,7 +446,7 @@ static gboolean flags_valid(const struct asycii_info *info)
        return TRUE;
 }
 
-#ifdef HAVE_LIBSERIALPORT
+#ifdef HAVE_SERIAL_COMM
 /**
  * Arrange for the reception of another measurement from the DMM.
  *
@@ -453,8 +455,6 @@ static gboolean flags_valid(const struct asycii_info *info)
  * without the PC's intervention.
  *
  * @param[in]  serial The serial connection.
- *
- * @private
  */
 SR_PRIV int sr_asycii_packet_request(struct sr_serial_dev_inst *serial)
 {
@@ -517,7 +517,7 @@ SR_PRIV int sr_asycii_parse(const uint8_t *buf, float *floatval,
        int ret, exponent;
        struct asycii_info *info_local;
 
-       info_local = (struct asycii_info *)info;
+       info_local = info;
 
        /* Don't print byte 15. That one contains the carriage return. */
        sr_dbg("DMM packet: \"%.15s\"", buf);