metex14: Use case-insensitive string compares.

This allows some other DMMs to be supported that use e.g. "kOhm" vs.
"KOhm", and so on.
This commit is contained in:
Uwe Hermann 2013-10-23 18:07:54 +02:00
parent 1a807c13fc
commit ee6cb5a417
1 changed files with 18 additions and 18 deletions

View File

@ -57,10 +57,10 @@ static int parse_value(const uint8_t *buf, float *result)
/* Bytes 5-7: Over limit (various forms) */ /* Bytes 5-7: Over limit (various forms) */
is_ol = 0; is_ol = 0;
is_ol += (!strcmp((const char *)&valstr, ".OL")) ? 1 : 0; is_ol += (!strcasecmp((const char *)&valstr, ".OL")) ? 1 : 0;
is_ol += (!strcmp((const char *)&valstr, "O.L")) ? 1 : 0; is_ol += (!strcasecmp((const char *)&valstr, "O.L")) ? 1 : 0;
is_ol += (!strcmp((const char *)&valstr, "OL.")) ? 1 : 0; is_ol += (!strcasecmp((const char *)&valstr, "OL.")) ? 1 : 0;
is_ol += (!strcmp((const char *)&valstr, "OL")) ? 1 : 0; is_ol += (!strcasecmp((const char *)&valstr, "OL")) ? 1 : 0;
if (is_ol != 0) { if (is_ol != 0) {
sr_spew("Over limit."); sr_spew("Over limit.");
*result = INFINITY; *result = INFINITY;
@ -112,33 +112,33 @@ static void parse_flags(const char *buf, struct metex14_info *info)
/* Bytes 9-12: Unit */ /* Bytes 9-12: Unit */
u = (const char *)&unit; u = (const char *)&unit;
if (!strcmp(u, "A")) if (!strcasecmp(u, "A"))
info->is_ampere = TRUE; info->is_ampere = TRUE;
else if (!strcmp(u, "mA")) else if (!strcasecmp(u, "mA"))
info->is_milli = info->is_ampere = TRUE; info->is_milli = info->is_ampere = TRUE;
else if (!strcmp(u, "uA")) else if (!strcasecmp(u, "uA"))
info->is_micro = info->is_ampere = TRUE; info->is_micro = info->is_ampere = TRUE;
else if (!strcmp(u, "V")) else if (!strcasecmp(u, "V"))
info->is_volt = TRUE; info->is_volt = TRUE;
else if (!strcmp(u, "mV")) else if (!strcasecmp(u, "mV"))
info->is_milli = info->is_volt = TRUE; info->is_milli = info->is_volt = TRUE;
else if (!strcmp(u, "Ohm")) else if (!strcasecmp(u, "Ohm"))
info->is_ohm = TRUE; info->is_ohm = TRUE;
else if (!strcmp(u, "KOhm")) else if (!strcasecmp(u, "KOhm"))
info->is_kilo = info->is_ohm = TRUE; info->is_kilo = info->is_ohm = TRUE;
else if (!strcmp(u, "MOhm")) else if (!strcasecmp(u, "MOhm"))
info->is_mega = info->is_ohm = TRUE; info->is_mega = info->is_ohm = TRUE;
else if (!strcmp(u, "nF")) else if (!strcasecmp(u, "nF"))
info->is_nano = info->is_farad = TRUE; info->is_nano = info->is_farad = TRUE;
else if (!strcmp(u, "uF")) else if (!strcasecmp(u, "uF"))
info->is_micro = info->is_farad = TRUE; info->is_micro = info->is_farad = TRUE;
else if (!strcmp(u, "KHz")) else if (!strcasecmp(u, "KHz"))
info->is_kilo = info->is_hertz = TRUE; info->is_kilo = info->is_hertz = TRUE;
else if (!strcmp(u, "C")) else if (!strcasecmp(u, "C"))
info->is_celsius = TRUE; info->is_celsius = TRUE;
else if (!strcmp(u, "DB")) else if (!strcasecmp(u, "DB"))
info->is_decibel = TRUE; info->is_decibel = TRUE;
else if (!strcmp(u, "")) else if (!strcasecmp(u, ""))
info->is_unitless = TRUE; info->is_unitless = TRUE;
/* Byte 13: Always '\r' (carriage return, 0x0d, 13) */ /* Byte 13: Always '\r' (carriage return, 0x0d, 13) */