-/**
- * Parse the numerical value from a protocol packet.
- *
- * @param buf Buffer containing the 14-byte protocol packet.
- * @param result Pointer to a float variable. That variable will contain the
- * result value upon parsing success.
- *
- * @return SR_OK upon success, SR_ERR upon failure. Upon errors, the result
- * variable contents are undefined and should not be used.
- */
+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) {
+ sr_err("More than one multiplier detected in packet.");
+ return FALSE;
+ }
+
+ /* Does the packet "measure" more than one type of value? */
+ count = 0;
+ count += (info->is_diode) ? 1 : 0;
+ 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) {
+ sr_err("More than one measurement type detected in packet.");
+ return FALSE;
+ }
+
+ /* Both AC and DC set? */
+ if (info->is_ac && info->is_dc) {
+ sr_err("Both AC and DC flags detected in packet.");
+ return FALSE;
+ }
+
+ /* Both Celsius and Fahrenheit set? */
+ if (info->is_celsius && info->is_fahrenheit) {
+ sr_err("Both Celsius and Fahrenheit flags detected in packet.");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+