enum model model;
gint64 timeout_us;
- model = SR_METRAHIT_NONE;
+ model = METRAHIT_NONE;
timeout_us = g_get_monotonic_time() + 1 * 1000 * 1000;
/*
if ((byte == -1) || (timeout_us < g_get_monotonic_time()))
break;
if ((byte & MSGID_MASK) == MSGID_INF) {
- if (!(model = sr_gmc_decode_model_sm(byte & MSGC_MASK)))
+ if (!(model = gmc_decode_model_sm(byte & MSGC_MASK)))
break;
/* Now expect (at least) 4 data bytes. */
for (cnt = 0; cnt < 4; cnt++) {
if ((byte == -1) ||
((byte & MSGID_MASK) != MSGID_DATA))
{
- model = SR_METRAHIT_NONE;
+ model = METRAHIT_NONE;
bytecnt = 100;
break;
}
drvc = di->priv;
drvc->instances = NULL;
conn = serialcomm = NULL;
- model = SR_METRAHIT_NONE;
+ model = METRAHIT_NONE;
serialcomm_given = FALSE;
sr_spew("scan_1x_2x_rs232() called!");
* If detection failed and no user-supplied parameters,
* try second baud rate.
*/
- if ((model == SR_METRAHIT_NONE) && !serialcomm_given) {
+ if ((model == METRAHIT_NONE) && !serialcomm_given) {
serialcomm = SERIALCOMM_1X_RS232;
g_free(serial->serialcomm);
serial->serialcomm = g_strdup(serialcomm);
}
}
- if (model != SR_METRAHIT_NONE) {
- sr_spew("%s %s detected!", VENDOR_GMC, sr_gmc_model_str(model));
+ if (model != METRAHIT_NONE) {
+ sr_spew("%s %s detected!", VENDOR_GMC, gmc_model_str(model));
if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, VENDOR_GMC,
- sr_gmc_model_str(model), "")))
+ gmc_model_str(model), "")))
return NULL;
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
if ((devc = sdi->priv) && devc->elapsed_msec) {
g_timer_destroy(devc->elapsed_msec);
devc->elapsed_msec = NULL;
- devc->model = SR_METRAHIT_NONE;
+ devc->model = METRAHIT_NONE;
}
return SR_OK;
devc->mqflags |= SR_MQFLAG_DC;
if (ctmv >= 0x03) {
devc->mqflags |= SR_MQFLAG_AC;
- if (devc->model >= SR_METRAHIT_16S)
+ if (devc->model >= METRAHIT_16S)
devc->mqflags |= SR_MQFLAG_RMS;
}
break;
case 0x0f: /* A */
devc->mq = SR_MQ_CURRENT;
devc->unit = SR_UNIT_AMPERE;
- if (devc->model == SR_METRAHIT_16S)
+ if (devc->model == METRAHIT_16S)
devc->mqflags |= SR_MQFLAG_RMS;
/* 16I A only with clamp, RMS questionable. */
break;
devc->mqflags |= SR_MQFLAG_DC;
if (ctmv >= 0x02) {
devc->mqflags |= SR_MQFLAG_AC;
- if (devc->model >= SR_METRAHIT_24S)
+ if (devc->model >= METRAHIT_24S)
devc->model |= SR_MQFLAG_RMS;
}
break;
devc->mqflags |= SR_MQFLAG_DC;
if ((ctmv == 0x05) || (ctmv == 0x07)) {
devc->mqflags |= SR_MQFLAG_AC;
- if (devc->model >= SR_METRAHIT_24S)
+ if (devc->model >= METRAHIT_24S)
devc->mqflags |= SR_MQFLAG_RMS;
}
break;
clean_rs_v(devc);
/* Byte 0, range and sign */
- if (devc->model <= SR_METRAHIT_16X)
+ if (devc->model <= METRAHIT_16X)
decode_rs_16(bc(devc->buf[0]), devc);
- else if (devc->model < SR_METRAHIT_2X)
+ else if (devc->model < METRAHIT_2X)
decode_rs_18(bc(devc->buf[0]), devc);
else
decode_rs_2x(bc(devc->buf[0]), devc);
clean_ctmv_rs_v(devc);
/* Process byte 0 */
- model = sr_gmc_decode_model_sm(bc(devc->buf[0]));
+ model = gmc_decode_model_sm(bc(devc->buf[0]));
if (model != devc->model) {
sr_warn("Model mismatch in data: Detected %s, now %s",
- sr_gmc_model_str(devc->model),
- sr_gmc_model_str(model));
+ gmc_model_str(devc->model), gmc_model_str(model));
}
/* Process bytes 1-4 */
- if (devc->model <= SR_METRAHIT_16X) {
+ if (devc->model <= METRAHIT_16X) {
decode_ctmv_16(bc(devc->buf[1]), devc);
decode_spc_16(bc(devc->buf[2]) | (bc(devc->buf[3]) << 4), devc);
decode_rs_16(bc(devc->buf[4]), devc);
- } else if (devc->model <= SR_METRAHIT_18S) {
+ } else if (devc->model <= METRAHIT_18S) {
decode_ctmv_18(bc(devc->buf[1]), devc);
decode_spc_18(bc(devc->buf[2]) | (bc(devc->buf[3]) << 4), devc);
decode_rs_18(bc(devc->buf[4]), devc);
clean_ctmv_rs_v(devc);
/* Byte 0, model. */
- model = sr_gmc_decode_model_sm(bc(devc->buf[0]));
+ model = gmc_decode_model_sm(bc(devc->buf[0]));
if (model != devc->model) {
sr_warn("Model mismatch in data: Detected %s, now %s",
- sr_gmc_model_str(devc->model),
- sr_gmc_model_str(model));
+ gmc_model_str(devc->model), gmc_model_str(model));
}
/* Bytes 1-4, 11. */
devc->buflen = 0;
continue;
} else if ((devc->buflen == 10) &&
- (devc->model <= SR_METRAHIT_18S)) {
+ (devc->model <= METRAHIT_18S)) {
process_msg_inf_10(sdi);
devc->buflen = 0;
continue;
}
/** Decode model in "send mode". */
-SR_PRIV int sr_gmc_decode_model_sm(uint8_t mcode)
+SR_PRIV int gmc_decode_model_sm(uint8_t mcode)
{
if (mcode > 0xf) {
sr_err("decode_model(%d): Model code 0..15 expected!", mcode);
- return SR_METRAHIT_NONE;
+ return METRAHIT_NONE;
}
switch(mcode) {
case 0x04: /* 0100b */
- return SR_METRAHIT_12S;
+ return METRAHIT_12S;
case 0x08: /* 1000b */
- return SR_METRAHIT_13S14A;
+ return METRAHIT_13S14A;
case 0x09: /* 1001b */
- return SR_METRAHIT_14S;
+ return METRAHIT_14S;
case 0x0A: /* 1010b */
- return SR_METRAHIT_15S;
+ return METRAHIT_15S;
case 0x0B: /* 1011b */
- return SR_METRAHIT_16S;
+ return METRAHIT_16S;
case 0x06: /* 0110b (undocumented by GMC!) */
- return SR_METRAHIT_16I;
+ return METRAHIT_16I;
case 0x0D: /* 1101b */
- return SR_METRAHIT_18S;
+ return METRAHIT_18S;
case 0x02: /* 0010b */
- return SR_METRAHIT_22SM;
+ return METRAHIT_22SM;
case 0x03: /* 0011b */
- return SR_METRAHIT_23S;
+ return METRAHIT_23S;
case 0x0f: /* 1111b */
- return SR_METRAHIT_24S;
+ return METRAHIT_24S;
case 0x05: /* 0101b */
- return SR_METRAHIT_25SM;
+ return METRAHIT_25SM;
case 0x01: /* 0001b */
- return SR_METRAHIT_26S;
+ return METRAHIT_26S;
case 0x0c: /* 1100b */
- return SR_METRAHIT_28S;
+ return METRAHIT_28S;
case 0x0e: /* 1110b */
- return SR_METRAHIT_29S;
+ return METRAHIT_29S;
default:
sr_err("Unknown model code %d!", mcode);
- return SR_METRAHIT_NONE;
+ return METRAHIT_NONE;
}
}
*
* @return Model code.
*/
-SR_PRIV int sr_gmc_decode_model_bidi(uint8_t mcode)
+SR_PRIV int gmc_decode_model_bidi(uint8_t mcode)
{
switch (mcode) {
case 2:
- return SR_METRAHIT_22SM;
+ return METRAHIT_22SM;
case 3:
- return SR_METRAHIT_23S;
+ return METRAHIT_23S;
case 4:
- return SR_METRAHIT_24S;
+ return METRAHIT_24S;
case 5:
- return SR_METRAHIT_25SM;
+ return METRAHIT_25SM;
case 1:
- return SR_METRAHIT_26S;
+ return METRAHIT_26S;
case 12:
- return SR_METRAHIT_28S;
+ return METRAHIT_28S;
case 14:
- return SR_METRAHIT_29S;
+ return METRAHIT_29S;
default:
sr_err("Unknown model code %d!", mcode);
- return SR_METRAHIT_NONE;
+ return METRAHIT_NONE;
}
}
-SR_PRIV const char *sr_gmc_model_str(enum model mcode)
+SR_PRIV const char *gmc_model_str(enum model mcode)
{
switch (mcode) {
- case SR_METRAHIT_NONE:
+ case METRAHIT_NONE:
return "-uninitialized model variable-";
- case SR_METRAHIT_12S:
+ case METRAHIT_12S:
return "METRAHit 12S";
- case SR_METRAHIT_13S14A:
+ case METRAHIT_13S14A:
return "METRAHit 13S/14A";
- case SR_METRAHIT_14S:
+ case METRAHIT_14S:
return "METRAHit 14S";
- case SR_METRAHIT_15S:
+ case METRAHIT_15S:
return "METRAHit 15S";
- case SR_METRAHIT_16S:
+ case METRAHIT_16S:
return "METRAHit 16S";
- case SR_METRAHIT_16I:
+ case METRAHIT_16I:
return "METRAHit 16I";
- case SR_METRAHIT_18S:
+ case METRAHIT_18S:
return "METRAHit 18S";
- case SR_METRAHIT_22SM:
+ case METRAHIT_22SM:
return "METRAHit 22S/M";
- case SR_METRAHIT_23S:
+ case METRAHIT_23S:
return "METRAHit 23S";
- case SR_METRAHIT_24S:
+ case METRAHIT_24S:
return "METRAHit 24S";
- case SR_METRAHIT_25SM:
+ case METRAHIT_25SM:
return "METRAHit 25S/M";
- case SR_METRAHIT_26S:
+ case METRAHIT_26S:
return "METRAHit 26S";
- case SR_METRAHIT_28S:
+ case METRAHIT_28S:
return "METRAHit 28S";
- case SR_METRAHIT_29S:
+ case METRAHIT_29S:
return "METRAHit 29S";
default:
return "Unknown model code";
* protocol (see decode_model()), these codes allow working with ranges.
*/
enum model {
- SR_METRAHIT_NONE = 0, /**< Value for uninitialized variable */
- SR_METRAHIT_12S = 12,
- SR_METRAHIT_13S14A = 13,
- SR_METRAHIT_14S = 14,
- SR_METRAHIT_15S = 15,
- SR_METRAHIT_16S = 16,
- SR_METRAHIT_16I = 17,
- SR_METRAHIT_16X = SR_METRAHIT_16I, /**< All Metrahit 16 */
+ METRAHIT_NONE = 0, /**< Value for uninitialized variable */
+ METRAHIT_12S = 12,
+ METRAHIT_13S14A = 13,
+ METRAHIT_14S = 14,
+ METRAHIT_15S = 15,
+ METRAHIT_16S = 16,
+ METRAHIT_16I = 17,
+ METRAHIT_16X = METRAHIT_16I, /**< All Metrahit 16 */
/* A Metrahit 17 exists, but seems not to have an IR interface. */
- SR_METRAHIT_18S = 18,
- SR_METRAHIT_2X = 20, /**< For model type comparisons */
- SR_METRAHIT_22SM = 22,
- SR_METRAHIT_23S = 23,
- SR_METRAHIT_24S = 24,
- SR_METRAHIT_25SM = 25,
- SR_METRAHIT_26S = 26,
- SR_METRAHIT_28S = 28,
- SR_METRAHIT_29S = 29,
+ METRAHIT_18S = 18,
+ METRAHIT_2X = 20, /**< For model type comparisons */
+ METRAHIT_22SM = 22,
+ METRAHIT_23S = 23,
+ METRAHIT_24S = 24,
+ METRAHIT_25SM = 25,
+ METRAHIT_26S = 26,
+ METRAHIT_28S = 28,
+ METRAHIT_29S = 29,
};
/** Convert GMC model code in send mode to sigrok-internal one. */
-SR_PRIV int sr_gmc_decode_model_sm(uint8_t mcode);
+SR_PRIV int gmc_decode_model_sm(uint8_t mcode);
/**
* Convert GMC model code in bidirectional mode to sigrok-internal one.
*
* @return Model code.
*/
-SR_PRIV int sr_gmc_decode_model_bidi(uint8_t mcode);
+SR_PRIV int gmc_decode_model_bidi(uint8_t mcode);
/** Get model string from sigrok-internal model code. */
-SR_PRIV const char *sr_gmc_model_str(enum model mcode);
+SR_PRIV const char *gmc_model_str(enum model mcode);
/** Private, per-device-instance driver context. */
struct dev_context {