Address minor style issues: Need not assign NULL after g_malloc0(), need
not check for NULL before g_free(). Rephrase diagnostics messages which
are user visible by default, remove internal development details. Reword
a few comments, and adjust their grammar for consistency across the code
base. The sr_analog_init() routine executed immediately before getting
measurements, need not (re-)assign endianess or floating point details,
except those which do change after initialization (double vs float).
Rephrase model dependent checks for easier adjustment during maintenance.
Unobfuscate string comparisons.
devc->num_channels = model->num_channels;
devc->cmdset = model->cmdset;
devc->model = model;
devc->num_channels = model->num_channels;
devc->cmdset = model->cmdset;
devc->model = model;
- devc->precision = NULL;
for (i = 0; i < devc->num_channels; i++) {
channel_name = g_strdup_printf("P%zu", i + 1);
for (i = 0; i < devc->num_channels; i++) {
channel_name = g_strdup_printf("P%zu", i + 1);
ret = sr_scpi_get_string(scpi, command, &response);
if (ret == SR_OK) {
g_strstrip(response);
ret = sr_scpi_get_string(scpi, command, &response);
if (ret == SR_OK) {
g_strstrip(response);
- if (devc->precision)
- g_free(devc->precision);
- devc->precision=g_strdup(response);
+ g_free(devc->precision);
+ devc->precision = g_strdup(response);
g_free(response);
sr_dbg("%s: Precision: '%s'", __func__, devc->precision);
} else {
g_free(response);
sr_dbg("%s: Precision: '%s'", __func__, devc->precision);
} else {
- sr_info("%s: Precision query ('%s') failed: %d",
- __func__, command, ret);
+ sr_info("Precision query ('%s') failed: %d",
+ command, ret);
std_session_send_df_end(sdi);
std_session_send_df_end(sdi);
- if (devc->precision) {
- g_free(devc->precision);
- devc->precision = NULL;
- }
+ g_free(devc->precision);
+ devc->precision = NULL;
analog->data = &info->f_value;
analog->encoding->unitsize = sizeof(info->f_value);
}
analog->data = &info->f_value;
analog->encoding->unitsize = sizeof(info->f_value);
}
- analog->encoding->is_float = TRUE;
-#ifdef WORDS_BIGENDIAN
- analog->encoding->is_bigendian = TRUE;
-#else
- analog->encoding->is_bigendian = FALSE;
-#endif
analog->encoding->digits = digits;
analog->meaning->mq = mq;
analog->meaning->mqflags = mqflag;
analog->encoding->digits = digits;
analog->meaning->mq = mq;
analog->meaning->mqflags = mqflag;
const char *command;
char *response;
gboolean use_double;
const char *command;
char *response;
gboolean use_double;
int sig_digits, val_exp;
int digits;
enum sr_unit unit;
int sig_digits, val_exp;
int digits;
enum sr_unit unit;
- * Make sure we report "INFINITY" when meter displays "0L"
+ * Make sure we report "INFINITY" when meter displays "0L".
*/
switch (mmode) {
case 7:
case 16:
*/
switch (mmode) {
case 7:
case 16:
- /* in resitance modes 0L reads as 1.20000E8 or 1.99999E8 */
- if (!strncmp(devc->model->model,"GDM8255A",8)) {
- if (info->d_value >= 1.99999e8)
- info->d_value = +INFINITY;
- } else {
- if (info->d_value >= 1.2e8)
- info->d_value = +INFINITY;
- }
+ /* In resitance modes 0L reads as 1.20000E8 or 1.99999E8. */
+ if (strcmp(devc->model->model, "GDM8255A") == 0)
+ limit = 1.99999e8;
+ else
+ limit = 1.2e8;
+ if (info->d_value >= limit)
+ info->d_value = +INFINITY;
- /* In continuity mode 0L reads as 1.20000E3 */
+ /* In continuity mode 0L reads as 1.20000E3. */
if (info->d_value >= 1.2e3)
info->d_value = +INFINITY;
break;
case 17:
if (info->d_value >= 1.2e3)
info->d_value = +INFINITY;
break;
case 17:
- /* in diode mode 0L reads as 1.00000E0 */
+ /* In diode mode 0L reads as 1.00000E0. */
if (info->d_value == 1.0e0)
info->d_value = +INFINITY;
break;
}
/*
if (info->d_value == 1.0e0)
info->d_value = +INFINITY;
break;
}
/*
- * Calculate 'digits' based on the precision reading result
- * done during start of acquisition.
- *
- * GW-Instek manual gives following info regarding resolution:
- *
- * Type Digit
- * -------------------- ------------
- * Slow 5 1/2
- * Medium 4 1/2
- * Fast 3 1/2
+ * Calculate 'digits' based on the result of the optional
+ * precision reading which was done at acquisition start.
+ * The GW-Instek manual gives the following information
+ * regarding the resolution:
+ * Type Digit
+ * -------- ------
+ * Slow 5 1/2
+ * Medium 4 1/2
+ * Fast 3 1/2
digits = devc->model->digits;
if (devc->precision && *devc->precision) {
digits = devc->model->digits;
if (devc->precision && *devc->precision) {
- if (!strncmp(devc->precision, "Slow", 4))
+ if (g_str_has_prefix(devc->precision, "Slow"))
- else if (!strncmp(devc->precision, "Mid", 3))
+ else if (g_str_has_prefix(devc->precision, "Mid"))
- else if (!strncmp(devc->precision, "Fast", 4))
+ else if (g_str_has_prefix(devc->precision, "Fast"))
- sr_info("%s: Unknown precision: '%s'",
- __func__, devc->precision);
+ sr_info("Unknown precision: '%s'", devc->precision);
analog->data = &info->f_value;
analog->encoding->unitsize = sizeof(info->f_value);
}
analog->data = &info->f_value;
analog->encoding->unitsize = sizeof(info->f_value);
}
- analog->encoding->is_float = TRUE;
-#ifdef WORDS_BIGENDIAN
- analog->encoding->is_bigendian = TRUE;
-#else
- analog->encoding->is_bigendian = FALSE;
-#endif
analog->encoding->digits = digits;
analog->meaning->mq = mq;
analog->meaning->mqflags = mqflag;
analog->encoding->digits = digits;
analog->meaning->mq = mq;
analog->meaning->mqflags = mqflag;