SR_CONF_CONTINUOUS,
SR_CONF_DATALOG,
SR_CONF_SPL_WEIGHT_FREQ,
+ SR_CONF_SPL_WEIGHT_TIME,
};
static const char *weight_freq[] = {
"C",
};
+static const char *weight_time[] = {
+ "F",
+ "S",
+};
+
SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info;
static struct sr_dev_driver *di = &cem_dt_885x_driver_info;
else
return SR_ERR;
break;
+ case SR_CONF_SPL_WEIGHT_TIME:
+ tmp = cem_dt_885x_weight_time_get(sdi);
+ if (tmp == SR_MQFLAG_SPL_TIME_WEIGHT_F)
+ *data = g_variant_new_string("F");
+ else if (tmp == SR_MQFLAG_SPL_TIME_WEIGHT_S)
+ *data = g_variant_new_string("S");
+ else
+ return SR_ERR;
+ break;
default:
return SR_ERR_NA;
}
else
return SR_ERR_ARG;
break;
+ case SR_CONF_SPL_WEIGHT_TIME:
+ tmp_str = g_variant_get_string(data, NULL);
+ if (!strcmp(tmp_str, "F"))
+ ret = cem_dt_885x_weight_time_set(sdi,
+ SR_MQFLAG_SPL_TIME_WEIGHT_F);
+ else if (!strcmp(tmp_str, "S"))
+ ret = cem_dt_885x_weight_time_set(sdi,
+ SR_MQFLAG_SPL_TIME_WEIGHT_S);
+ else
+ return SR_ERR_ARG;
+ break;
default:
ret = SR_ERR_NA;
}
case SR_CONF_SPL_WEIGHT_FREQ:
*data = g_variant_new_strv(weight_freq, ARRAY_SIZE(weight_freq));
break;
+ case SR_CONF_SPL_WEIGHT_TIME:
+ *data = g_variant_new_strv(weight_time, ARRAY_SIZE(weight_time));
+ break;
default:
return SR_ERR_NA;
}
return ret;
}
+
+SR_PRIV int cem_dt_885x_weight_time_get(const struct sr_dev_inst *sdi)
+{
+ struct dev_context *devc;
+ int cur_setting;
+ char tokens[5];
+
+ devc = sdi->priv;
+
+ cur_setting = devc->cur_mqflags & (SR_MQFLAG_SPL_TIME_WEIGHT_F | SR_MQFLAG_SPL_TIME_WEIGHT_S);
+ if (cur_setting == 0) {
+ /* Didn't pick up device state yet. */
+ tokens[0] = TOKEN_WEIGHT_TIME_FAST;
+ tokens[1] = TOKEN_WEIGHT_TIME_SLOW;
+ tokens[2] = -1;
+ if (wait_for_token(sdi, tokens, 0) != SR_OK)
+ return SR_ERR;
+ if (devc->token == TOKEN_WEIGHT_TIME_FAST)
+ return SR_MQFLAG_SPL_TIME_WEIGHT_F;
+ else
+ return SR_MQFLAG_SPL_TIME_WEIGHT_S;
+ } else
+ return cur_setting;
+
+}
+
+SR_PRIV int cem_dt_885x_weight_time_set(const struct sr_dev_inst *sdi, int timew)
+{
+ struct dev_context *devc;
+ int cur_setting, ret;
+ char tokens[5];
+
+ devc = sdi->priv;
+
+ cur_setting = devc->cur_mqflags & (SR_MQFLAG_SPL_TIME_WEIGHT_F | SR_MQFLAG_SPL_TIME_WEIGHT_S);
+ if (cur_setting == timew)
+ /* Already set to this time weighting. */
+ return SR_OK;
+
+ /* The toggle below needs the desired state in first position. */
+ if (timew == SR_MQFLAG_SPL_TIME_WEIGHT_F) {
+ tokens[0] = TOKEN_WEIGHT_TIME_FAST;
+ tokens[1] = TOKEN_WEIGHT_TIME_SLOW;
+ } else {
+ tokens[0] = TOKEN_WEIGHT_TIME_SLOW;
+ tokens[1] = TOKEN_WEIGHT_TIME_FAST;
+ }
+ tokens[2] = -1;
+
+ if (cur_setting == 0) {
+ /* Didn't pick up device state yet. */
+ if (wait_for_token(sdi, tokens, 0) != SR_OK)
+ return SR_ERR;
+ if (devc->token == tokens[0])
+ /* Nothing to do. */
+ return SR_OK;
+ }
+
+ /* 51ms timeout seems to work best for this. */
+ ret = cem_dt_885x_toggle(sdi, CMD_TOGGLE_WEIGHT_TIME, tokens, 51);
+
+ return ret;
+}
enum {
CMD_TOGGLE_RECORDING = 0x55,
CMD_TOGGLE_WEIGHT_FREQ = 0x99,
+ CMD_TOGGLE_WEIGHT_TIME = 0x77,
};
/** Private, per-device-instance driver context. */
SR_PRIV gboolean cem_dt_885x_recording_get(const struct sr_dev_inst *sdi);
SR_PRIV int cem_dt_885x_weight_freq_get(const struct sr_dev_inst *sdi);
SR_PRIV int cem_dt_885x_weight_freq_set(const struct sr_dev_inst *sdi, int freqw);
+SR_PRIV int cem_dt_885x_weight_time_get(const struct sr_dev_inst *sdi);
+SR_PRIV int cem_dt_885x_weight_time_set(const struct sr_dev_inst *sdi, int timew);
#endif