]> sigrok.org Git - libsigrok.git/blobdiff - hardware/common/dmm/rs9lcd.c
build: Portability fixes.
[libsigrok.git] / hardware / common / dmm / rs9lcd.c
index d184aca712736d434d661c60ecab508aca535a86..539c2335e265931e328dae71d6fc8c452848a85a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * This file is part of the sigrok project.
+ * This file is part of the libsigrok project.
  *
  * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
  *
 #include "libsigrok.h"
 #include "libsigrok-internal.h"
 
-/* Message logging helpers with driver-specific prefix string. */
-#define DRIVER_LOG_DOMAIN "rs9lcd: "
-#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
-#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
+#define LOG_PREFIX "rs9lcd"
 
 /* Byte 1 of the packet, and the modes it represents */
 #define IND1_HZ                (1 << 7)
@@ -174,7 +167,7 @@ static gboolean selection_good(const struct rs9lcd_packet *rs_packet)
        count += (rs_packet->indicatrix2 & IND2_MICRO) ? 1 : 0;
        count += (rs_packet->indicatrix2 & IND2_NANO)  ? 1 : 0;
        if (count > 1) {
-               sr_err("More than one multiplier detected in packet.");
+               sr_dbg("More than one multiplier detected in packet.");
                return FALSE;
        }
 
@@ -190,7 +183,7 @@ static gboolean selection_good(const struct rs9lcd_packet *rs_packet)
        count += (rs_packet->indicatrix2 & IND2_DUTY)  ? 1 : 0;
        count += (rs_packet->indicatrix2 & IND2_HFE)   ? 1 : 0;
        if (count > 1) {
-               sr_err("More than one measurement type detected in packet.");
+               sr_dbg("More than one measurement type detected in packet.");
                return FALSE;
        }
 
@@ -255,14 +248,14 @@ static uint8_t decode_digit(uint8_t raw_digit)
        case LCD_9:
                return 9;
        default:
-               sr_err("Invalid digit byte: 0x%02x.", raw_digit);
+               sr_dbg("Invalid digit byte: 0x%02x.", raw_digit);
                return 0xff;
        }
 }
 
 static double lcd_to_double(const struct rs9lcd_packet *rs_packet, int type)
 {
-       double rawval, multiplier = 1;
+       double rawval = 0, multiplier = 1;
        uint8_t digit, raw_digit;
        gboolean dp_reached = FALSE;
        int i, end;
@@ -369,7 +362,7 @@ SR_PRIV int sr_rs9lcd_parse(const uint8_t *buf, float *floatval,
        case MODE_CONT:
                analog->mq = SR_MQ_CONTINUITY;
                analog->unit = SR_UNIT_BOOLEAN;
-               *analog->data = is_shortcirc(rs_packet);
+               rawval = is_shortcirc(rs_packet);
                break;
        case MODE_DIODE:
                analog->mq = SR_MQ_VOLTAGE;
@@ -394,7 +387,7 @@ SR_PRIV int sr_rs9lcd_parse(const uint8_t *buf, float *floatval,
                } else {
                        /* We have either HI or LOW. */
                        analog->unit = SR_UNIT_BOOLEAN;
-                       *analog->data = is_logic_high(rs_packet);
+                       rawval = is_logic_high(rs_packet);
                }
                break;
        case MODE_HFE:
@@ -412,10 +405,11 @@ SR_PRIV int sr_rs9lcd_parse(const uint8_t *buf, float *floatval,
        case MODE_AMP_WIDTH:
                analog->mq = SR_MQ_PULSE_WIDTH;
                analog->unit = SR_UNIT_SECOND;
+               break;
        case MODE_TEMP:
                analog->mq = SR_MQ_TEMPERATURE;
                /* We need to reparse. */
-               *analog->data = lcd_to_double(rs_packet, READ_TEMP);
+               rawval = lcd_to_double(rs_packet, READ_TEMP);
                analog->unit = is_celsius(rs_packet) ?
                                SR_UNIT_CELSIUS : SR_UNIT_FAHRENHEIT;
                break;
@@ -425,7 +419,7 @@ SR_PRIV int sr_rs9lcd_parse(const uint8_t *buf, float *floatval,
                analog->mqflags |= SR_MQFLAG_AC;
                break;
        default:
-               sr_err("Unknown mode: %d.", rs_packet->mode);
+               sr_dbg("Unknown mode: %d.", rs_packet->mode);
                break;
        }