2012-10-27 20:41:50 +00:00
|
|
|
/*
|
2013-04-23 20:24:30 +00:00
|
|
|
* This file is part of the libsigrok project.
|
2012-10-27 20:41:50 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fortune Semiconductor FS9922-DMM3/FS9922-DMM4 protocol parser.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include "libsigrok.h"
|
|
|
|
#include "libsigrok-internal.h"
|
|
|
|
|
2013-12-23 03:38:35 +00:00
|
|
|
#define LOG_PREFIX "fs9922"
|
2012-10-27 20:41:50 +00:00
|
|
|
|
2012-12-19 21:47:26 +00:00
|
|
|
static gboolean flags_valid(const struct fs9922_info *info)
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
|
|
|
|
/* Does the packet have more than one multiplier? */
|
|
|
|
count = 0;
|
|
|
|
count += (info->is_nano) ? 1 : 0;
|
|
|
|
count += (info->is_micro) ? 1 : 0;
|
|
|
|
count += (info->is_milli) ? 1 : 0;
|
|
|
|
count += (info->is_kilo) ? 1 : 0;
|
|
|
|
count += (info->is_mega) ? 1 : 0;
|
|
|
|
if (count > 1) {
|
2014-01-06 19:44:44 +00:00
|
|
|
sr_dbg("More than one multiplier detected in packet.");
|
2012-12-19 21:47:26 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-04-30 23:00:54 +00:00
|
|
|
/*
|
|
|
|
* Does the packet "measure" more than one type of value?
|
|
|
|
*
|
|
|
|
* Note: In "diode mode", both is_diode and is_volt will be set.
|
|
|
|
* That is a valid use-case, so we don't want to error out below
|
|
|
|
* if it happens. Thus, we don't check for is_diode here.
|
|
|
|
*/
|
2012-12-19 21:47:26 +00:00
|
|
|
count = 0;
|
2013-04-30 23:00:54 +00:00
|
|
|
// count += (info->is_diode) ? 1 : 0;
|
2012-12-19 21:47:26 +00:00
|
|
|
count += (info->is_percent) ? 1 : 0;
|
|
|
|
count += (info->is_volt) ? 1 : 0;
|
|
|
|
count += (info->is_ampere) ? 1 : 0;
|
|
|
|
count += (info->is_ohm) ? 1 : 0;
|
|
|
|
count += (info->is_hfe) ? 1 : 0;
|
|
|
|
count += (info->is_hertz) ? 1 : 0;
|
|
|
|
count += (info->is_farad) ? 1 : 0;
|
|
|
|
count += (info->is_celsius) ? 1 : 0;
|
|
|
|
count += (info->is_fahrenheit) ? 1 : 0;
|
|
|
|
if (count > 1) {
|
2014-01-06 19:44:44 +00:00
|
|
|
sr_dbg("More than one measurement type detected in packet.");
|
2012-12-19 21:47:26 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Both AC and DC set? */
|
|
|
|
if (info->is_ac && info->is_dc) {
|
2014-01-06 19:44:44 +00:00
|
|
|
sr_dbg("Both AC and DC flags detected in packet.");
|
2012-12-19 21:47:26 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Both Celsius and Fahrenheit set? */
|
|
|
|
if (info->is_celsius && info->is_fahrenheit) {
|
2014-01-06 19:44:44 +00:00
|
|
|
sr_dbg("Both Celsius and Fahrenheit flags detected in packet.");
|
2012-12-19 21:47:26 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-10-27 20:41:50 +00:00
|
|
|
static int parse_value(const uint8_t *buf, float *result)
|
|
|
|
{
|
|
|
|
int sign, intval;
|
|
|
|
float floatval;
|
|
|
|
|
|
|
|
/* Byte 0: Sign ('+' or '-') */
|
|
|
|
if (buf[0] == '+') {
|
|
|
|
sign = 1;
|
|
|
|
} else if (buf[0] == '-') {
|
|
|
|
sign = -1;
|
|
|
|
} else {
|
2014-01-06 19:44:44 +00:00
|
|
|
sr_dbg("Invalid sign byte: 0x%02x.", buf[0]);
|
2012-10-27 20:41:50 +00:00
|
|
|
return SR_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bytes 1-4: Value (4 decimal digits)
|
|
|
|
*
|
|
|
|
* Over limit: "0.L" on the display, "?0:?" as protocol "digits".
|
|
|
|
*/
|
|
|
|
if (buf[1] == '?' && buf[2] == '0' && buf[3] == ':' && buf[4] == '?') {
|
|
|
|
sr_spew("Over limit.");
|
|
|
|
*result = INFINITY;
|
|
|
|
return SR_OK;
|
|
|
|
} else if (!isdigit(buf[1]) || !isdigit(buf[2]) ||
|
|
|
|
!isdigit(buf[3]) || !isdigit(buf[4])) {
|
2014-01-06 19:44:44 +00:00
|
|
|
sr_dbg("Value contained invalid digits: %02x %02x %02x %02x ("
|
2012-10-27 20:41:50 +00:00
|
|
|
"%c %c %c %c).", buf[1], buf[2], buf[3], buf[4]);
|
|
|
|
return SR_ERR;
|
|
|
|
}
|
|
|
|
intval = 0;
|
|
|
|
intval += (buf[1] - '0') * 1000;
|
|
|
|
intval += (buf[2] - '0') * 100;
|
|
|
|
intval += (buf[3] - '0') * 10;
|
|
|
|
intval += (buf[4] - '0') * 1;
|
|
|
|
|
|
|
|
floatval = (float)intval;
|
|
|
|
|
|
|
|
/* Byte 5: Always ' ' (space, 0x20) */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Byte 6: Decimal point position ('0', '1', '2', or '4')
|
|
|
|
*
|
|
|
|
* Note: The Fortune Semiconductor FS9922-DMM3/4 datasheets both have
|
|
|
|
* an error/typo here. They claim that the values '0'/'1'/'2'/'3' are
|
|
|
|
* used, but '0'/'1'/'2'/'4' is actually correct.
|
|
|
|
*/
|
|
|
|
if (buf[6] != '0' && buf[6] != '1' && buf[6] != '2' && buf[6] != '4') {
|
2014-01-06 19:44:44 +00:00
|
|
|
sr_dbg("Invalid decimal point value: 0x%02x.", buf[6]);
|
2012-10-27 20:41:50 +00:00
|
|
|
return SR_ERR;
|
|
|
|
}
|
|
|
|
if (buf[6] == '0')
|
|
|
|
floatval /= 1;
|
|
|
|
else if (buf[6] == '1')
|
|
|
|
floatval /= 1000;
|
|
|
|
else if (buf[6] == '2')
|
|
|
|
floatval /= 100;
|
|
|
|
else if (buf[6] == '4')
|
|
|
|
floatval /= 10;
|
|
|
|
|
|
|
|
/* Apply sign. */
|
|
|
|
floatval *= sign;
|
|
|
|
|
|
|
|
sr_spew("The display value is %f.", floatval);
|
|
|
|
|
|
|
|
*result = floatval;
|
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-19 21:47:26 +00:00
|
|
|
static void parse_flags(const uint8_t *buf, struct fs9922_info *info)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
|
|
|
/* Z1/Z2/Z3/Z4 are bits for user-defined LCD symbols (on/off). */
|
|
|
|
|
|
|
|
/* Byte 7 */
|
|
|
|
/* Bit 7: Always 0 */
|
|
|
|
/* Bit 6: Always 0 */
|
2012-12-19 21:47:26 +00:00
|
|
|
info->is_auto = (buf[7] & (1 << 5)) != 0;
|
|
|
|
info->is_dc = (buf[7] & (1 << 4)) != 0;
|
|
|
|
info->is_ac = (buf[7] & (1 << 3)) != 0;
|
|
|
|
info->is_rel = (buf[7] & (1 << 2)) != 0;
|
|
|
|
info->is_hold = (buf[7] & (1 << 1)) != 0;
|
|
|
|
info->is_bpn = (buf[7] & (1 << 0)) != 0; /* Bargraph shown */
|
2012-10-27 20:41:50 +00:00
|
|
|
|
|
|
|
/* Byte 8 */
|
2012-12-19 21:47:26 +00:00
|
|
|
info->is_z1 = (buf[8] & (1 << 7)) != 0; /* User symbol 1 */
|
|
|
|
info->is_z2 = (buf[8] & (1 << 6)) != 0; /* User symbol 2 */
|
|
|
|
info->is_max = (buf[8] & (1 << 5)) != 0;
|
|
|
|
info->is_min = (buf[8] & (1 << 4)) != 0;
|
|
|
|
info->is_apo = (buf[8] & (1 << 3)) != 0; /* Auto-poweroff on */
|
|
|
|
info->is_bat = (buf[8] & (1 << 2)) != 0; /* Battery low */
|
|
|
|
info->is_nano = (buf[8] & (1 << 1)) != 0;
|
|
|
|
info->is_z3 = (buf[8] & (1 << 0)) != 0; /* User symbol 3 */
|
2012-10-27 20:41:50 +00:00
|
|
|
|
|
|
|
/* Byte 9 */
|
2012-12-19 21:47:26 +00:00
|
|
|
info->is_micro = (buf[9] & (1 << 7)) != 0;
|
|
|
|
info->is_milli = (buf[9] & (1 << 6)) != 0;
|
|
|
|
info->is_kilo = (buf[9] & (1 << 5)) != 0;
|
|
|
|
info->is_mega = (buf[9] & (1 << 4)) != 0;
|
|
|
|
info->is_beep = (buf[9] & (1 << 3)) != 0;
|
|
|
|
info->is_diode = (buf[9] & (1 << 2)) != 0;
|
|
|
|
info->is_percent = (buf[9] & (1 << 1)) != 0;
|
2013-09-01 11:41:02 +00:00
|
|
|
info->is_z4 = (buf[9] & (1 << 0)) != 0; /* User symbol 4 */
|
2012-10-27 20:41:50 +00:00
|
|
|
|
|
|
|
/* Byte 10 */
|
2012-12-19 21:47:26 +00:00
|
|
|
info->is_volt = (buf[10] & (1 << 7)) != 0;
|
|
|
|
info->is_ampere = (buf[10] & (1 << 6)) != 0;
|
|
|
|
info->is_ohm = (buf[10] & (1 << 5)) != 0;
|
|
|
|
info->is_hfe = (buf[10] & (1 << 4)) != 0;
|
|
|
|
info->is_hertz = (buf[10] & (1 << 3)) != 0;
|
|
|
|
info->is_farad = (buf[10] & (1 << 2)) != 0;
|
|
|
|
info->is_celsius = (buf[10] & (1 << 1)) != 0; /* Only FS9922-DMM4 */
|
|
|
|
info->is_fahrenheit = (buf[10] & (1 << 0)) != 0; /* Only FS9922-DMM4 */
|
2012-10-27 20:41:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Byte 11: Bar graph
|
|
|
|
*
|
|
|
|
* Bit 7 contains the sign of the bargraph number (if the bit is set,
|
|
|
|
* the number is negative), bits 6..0 contain the actual number.
|
|
|
|
* Valid range: 0-40 (FS9922-DMM3), 0-60 (FS9922-DMM4).
|
|
|
|
*
|
|
|
|
* Upon "over limit" the bargraph value is 1 count above the highest
|
|
|
|
* valid number (i.e. 41 or 61, depending on chip).
|
|
|
|
*/
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_bpn) {
|
|
|
|
info->bargraph_sign = ((buf[11] & (1 << 7)) != 0) ? -1 : 1;
|
|
|
|
info->bargraph_value = (buf[11] & 0x7f);
|
|
|
|
info->bargraph_value *= info->bargraph_sign;
|
2012-10-27 20:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Byte 12: Always '\r' (carriage return, 0x0d, 13) */
|
|
|
|
|
|
|
|
/* Byte 13: Always '\n' (newline, 0x0a, 10) */
|
2012-12-19 21:47:26 +00:00
|
|
|
}
|
2012-10-27 20:41:50 +00:00
|
|
|
|
2012-12-19 21:47:26 +00:00
|
|
|
static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
|
|
|
|
const struct fs9922_info *info)
|
|
|
|
{
|
2012-10-27 20:41:50 +00:00
|
|
|
/* Factors */
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_nano)
|
2012-10-27 20:41:50 +00:00
|
|
|
*floatval /= 1000000000;
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_micro)
|
2012-10-27 20:41:50 +00:00
|
|
|
*floatval /= 1000000;
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_milli)
|
2012-10-27 20:41:50 +00:00
|
|
|
*floatval /= 1000;
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_kilo)
|
2012-10-27 20:41:50 +00:00
|
|
|
*floatval *= 1000;
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_mega)
|
2012-10-27 20:41:50 +00:00
|
|
|
*floatval *= 1000000;
|
|
|
|
|
|
|
|
/* Measurement modes */
|
2013-04-30 23:00:54 +00:00
|
|
|
if (info->is_volt || info->is_diode) {
|
|
|
|
/* Note: In "diode mode" both is_diode and is_volt are set. */
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mq = SR_MQ_VOLTAGE;
|
|
|
|
analog->unit = SR_UNIT_VOLT;
|
|
|
|
}
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_ampere) {
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mq = SR_MQ_CURRENT;
|
|
|
|
analog->unit = SR_UNIT_AMPERE;
|
|
|
|
}
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_ohm) {
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mq = SR_MQ_RESISTANCE;
|
|
|
|
analog->unit = SR_UNIT_OHM;
|
|
|
|
}
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_hfe) {
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mq = SR_MQ_GAIN;
|
|
|
|
analog->unit = SR_UNIT_UNITLESS;
|
|
|
|
}
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_hertz) {
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mq = SR_MQ_FREQUENCY;
|
|
|
|
analog->unit = SR_UNIT_HERTZ;
|
|
|
|
}
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_farad) {
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mq = SR_MQ_CAPACITANCE;
|
|
|
|
analog->unit = SR_UNIT_FARAD;
|
|
|
|
}
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_celsius) {
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mq = SR_MQ_TEMPERATURE;
|
|
|
|
analog->unit = SR_UNIT_CELSIUS;
|
|
|
|
}
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_fahrenheit) {
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mq = SR_MQ_TEMPERATURE;
|
|
|
|
analog->unit = SR_UNIT_FAHRENHEIT;
|
|
|
|
}
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_beep) {
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mq = SR_MQ_CONTINUITY;
|
|
|
|
analog->unit = SR_UNIT_BOOLEAN;
|
2013-04-30 23:02:46 +00:00
|
|
|
*floatval = (*floatval == INFINITY) ? 0.0 : 1.0;
|
2012-10-27 20:41:50 +00:00
|
|
|
}
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_percent) {
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mq = SR_MQ_DUTY_CYCLE;
|
|
|
|
analog->unit = SR_UNIT_PERCENTAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Measurement related flags */
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_ac)
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mqflags |= SR_MQFLAG_AC;
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_dc)
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mqflags |= SR_MQFLAG_DC;
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_auto)
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mqflags |= SR_MQFLAG_AUTORANGE;
|
2013-09-01 11:40:17 +00:00
|
|
|
if (info->is_diode)
|
|
|
|
analog->mqflags |= SR_MQFLAG_DIODE;
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_hold)
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mqflags |= SR_MQFLAG_HOLD;
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_max)
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mqflags |= SR_MQFLAG_MAX;
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_min)
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mqflags |= SR_MQFLAG_MIN;
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_rel)
|
2012-10-27 20:41:50 +00:00
|
|
|
analog->mqflags |= SR_MQFLAG_RELATIVE;
|
|
|
|
|
|
|
|
/* Other flags */
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_apo)
|
2012-10-27 20:41:50 +00:00
|
|
|
sr_spew("Automatic power-off function is active.");
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_bat)
|
2012-10-27 20:41:50 +00:00
|
|
|
sr_spew("Battery is low.");
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_z1)
|
2012-10-27 20:41:50 +00:00
|
|
|
sr_spew("User-defined LCD symbol 1 is active.");
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_z2)
|
2012-10-27 20:41:50 +00:00
|
|
|
sr_spew("User-defined LCD symbol 2 is active.");
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_z3)
|
2012-10-27 20:41:50 +00:00
|
|
|
sr_spew("User-defined LCD symbol 3 is active.");
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_z4)
|
2012-10-27 20:41:50 +00:00
|
|
|
sr_spew("User-defined LCD symbol 4 is active.");
|
2012-12-19 21:47:26 +00:00
|
|
|
if (info->is_bpn)
|
|
|
|
sr_spew("The bargraph value is %d.", info->bargraph_value);
|
|
|
|
else
|
|
|
|
sr_spew("The bargraph is not active.");
|
2012-10-27 20:41:50 +00:00
|
|
|
|
2012-12-19 21:47:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SR_PRIV gboolean sr_fs9922_packet_valid(const uint8_t *buf)
|
|
|
|
{
|
|
|
|
struct fs9922_info info;
|
|
|
|
|
|
|
|
/* Byte 0: Sign (must be '+' or '-') */
|
|
|
|
if (buf[0] != '+' && buf[0] != '-')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Byte 12: Always '\r' (carriage return, 0x0d, 13) */
|
|
|
|
/* Byte 13: Always '\n' (newline, 0x0a, 10) */
|
|
|
|
if (buf[12] != '\r' || buf[13] != '\n')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
parse_flags(buf, &info);
|
|
|
|
|
|
|
|
return flags_valid(&info);
|
2012-10-27 20:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-12-19 21:47:26 +00:00
|
|
|
* Parse a protocol packet.
|
2012-10-27 20:41:50 +00:00
|
|
|
*
|
2012-12-19 21:47:26 +00:00
|
|
|
* @param buf Buffer containing the protocol packet. Must not be NULL.
|
|
|
|
* @param floatval Pointer to a float variable. That variable will contain the
|
|
|
|
* result value upon parsing success. Must not be NULL.
|
2012-10-27 20:41:50 +00:00
|
|
|
* @param analog Pointer to a struct sr_datafeed_analog. The struct will be
|
|
|
|
* filled with data according to the protocol packet.
|
2012-12-19 21:47:26 +00:00
|
|
|
* Must not be NULL.
|
|
|
|
* @param info Pointer to a struct fs9922_info. The struct will be filled
|
|
|
|
* with data according to the protocol packet. Must not be NULL.
|
2012-10-27 20:41:50 +00:00
|
|
|
*
|
|
|
|
* @return SR_OK upon success, SR_ERR upon failure. Upon errors, the
|
|
|
|
* 'analog' variable contents are undefined and should not be used.
|
|
|
|
*/
|
2012-12-19 21:47:26 +00:00
|
|
|
SR_PRIV int sr_fs9922_parse(const uint8_t *buf, float *floatval,
|
|
|
|
struct sr_datafeed_analog *analog, void *info)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
|
|
|
int ret;
|
2012-12-19 21:47:26 +00:00
|
|
|
struct fs9922_info *info_local;
|
|
|
|
|
|
|
|
info_local = (struct fs9922_info *)info;
|
2012-10-27 20:41:50 +00:00
|
|
|
|
|
|
|
if ((ret = parse_value(buf, floatval)) != SR_OK) {
|
2014-01-06 19:44:44 +00:00
|
|
|
sr_dbg("Error parsing value: %d.", ret);
|
2012-10-27 20:41:50 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-12-19 21:47:26 +00:00
|
|
|
parse_flags(buf, info_local);
|
|
|
|
handle_flags(analog, floatval, info_local);
|
2012-10-27 20:41:50 +00:00
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
2013-09-01 11:10:54 +00:00
|
|
|
|
|
|
|
SR_PRIV void sr_fs9922_z1_diode(struct sr_datafeed_analog *analog, void *info)
|
|
|
|
{
|
|
|
|
struct fs9922_info *info_local;
|
|
|
|
|
|
|
|
info_local = (struct fs9922_info *)info;
|
|
|
|
|
|
|
|
/* User-defined z1 flag means "diode mode". */
|
|
|
|
if (info_local->is_z1) {
|
|
|
|
analog->mq = SR_MQ_VOLTAGE;
|
|
|
|
analog->unit = SR_UNIT_VOLT;
|
|
|
|
analog->mqflags |= SR_MQFLAG_DIODE;
|
|
|
|
}
|
|
|
|
}
|