X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Flcr%2Fes51919.c;h=cbe51179b7bfb403c1fa43e778f6edbf8feba00c;hb=1c47e0da8f2571bc34dbdc368c3c1f55318c3aa0;hp=c6fddc11c87a882e18f562fbf97058fbe99cc69c;hpb=5e23fcab889c62864b92aa3ad6902ce3e9f5be49;p=libsigrok.git
diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c
index c6fddc11..cbe51179 100644
--- a/src/lcr/es51919.c
+++ b/src/lcr/es51919.c
@@ -17,11 +17,12 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
#include
-#include "libsigrok.h"
+#include
#include "libsigrok-internal.h"
#define LOG_PREFIX "es51919"
@@ -305,7 +306,6 @@ static int send_config_update_key(struct sr_dev_inst *sdi, uint32_t key,
sr_config_free(cfg);
return ret;
-
}
/*
@@ -403,24 +403,10 @@ static int send_config_update_key(struct sr_dev_inst *sdi, uint32_t key,
#define PACKET_SIZE 17
-static const uint64_t frequencies[] = {
+static const double frequencies[] = {
100, 120, 1000, 10000, 100000, 0,
};
-enum { QUANT_AUTO = 5, };
-
-static const char *const quantities1[] = {
- "NONE", "INDUCTANCE", "CAPACITANCE", "RESISTANCE", "RESISTANCE", "AUTO",
-};
-
-static const char *const list_quantities1[] = {
- "NONE", "INDUCTANCE", "CAPACITANCE", "RESISTANCE", "AUTO",
-};
-
-static const char *const quantities2[] = {
- "NONE", "DISSIPATION", "QUALITY", "RESISTANCE", "ANGLE", "AUTO",
-};
-
enum { MODEL_NONE, MODEL_PAR, MODEL_SER, MODEL_AUTO, };
static const char *const models[] = {
@@ -444,12 +430,6 @@ struct dev_context {
/** The frequency of the test signal (index to frequencies[]). */
unsigned int freq;
- /** Measured primary quantity (index to quantities1[]). */
- unsigned int quant1;
-
- /** Measured secondary quantity (index to quantities2[]). */
- unsigned int quant2;
-
/** Equivalent circuit model (index to models[]). */
unsigned int model;
};
@@ -467,7 +447,7 @@ static int parse_mq(const uint8_t *pkt, int is_secondary, int is_parallel)
switch (is_secondary << 8 | buf[0]) {
case 0x001:
- return is_parallel ?
+ return is_parallel ?
SR_MQ_PARALLEL_INDUCTANCE : SR_MQ_SERIES_INDUCTANCE;
case 0x002:
return is_parallel ?
@@ -505,7 +485,7 @@ static float parse_value(const uint8_t *buf)
}
static void parse_measurement(const uint8_t *pkt, float *floatval,
- struct sr_datafeed_analog *analog,
+ struct sr_datafeed_analog_old *analog,
int is_secondary)
{
static const struct {
@@ -585,18 +565,6 @@ static unsigned int parse_freq(const uint8_t *pkt)
return freq;
}
-static unsigned int parse_quant(const uint8_t *pkt, int is_secondary)
-{
- const uint8_t *buf;
-
- if (pkt[2] & 0x20)
- return QUANT_AUTO;
-
- buf = pkt_to_buf(pkt, is_secondary);
-
- return buf[0];
-}
-
static unsigned int parse_model(const uint8_t *pkt)
{
if (pkt[2] & 0x40)
@@ -607,7 +575,6 @@ static unsigned int parse_model(const uint8_t *pkt)
return MODEL_PAR;
else
return MODEL_SER;
-
}
static gboolean packet_valid(const uint8_t *pkt)
@@ -638,19 +605,7 @@ static int do_config_update(struct sr_dev_inst *sdi, uint32_t key,
static int send_freq_update(struct sr_dev_inst *sdi, unsigned int freq)
{
return do_config_update(sdi, SR_CONF_OUTPUT_FREQUENCY,
- g_variant_new_uint64(frequencies[freq]));
-}
-
-static int send_quant1_update(struct sr_dev_inst *sdi, unsigned int quant)
-{
- return do_config_update(sdi, SR_CONF_MEASURED_QUANTITY,
- g_variant_new_string(quantities1[quant]));
-}
-
-static int send_quant2_update(struct sr_dev_inst *sdi, unsigned int quant)
-{
- return do_config_update(sdi, SR_CONF_MEASURED_2ND_QUANTITY,
- g_variant_new_string(quantities2[quant]));
+ g_variant_new_double(frequencies[freq]));
}
static int send_model_update(struct sr_dev_inst *sdi, unsigned int model)
@@ -662,7 +617,7 @@ static int send_model_update(struct sr_dev_inst *sdi, unsigned int model)
static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt)
{
struct sr_datafeed_packet packet;
- struct sr_datafeed_analog analog;
+ struct sr_datafeed_analog_old analog;
struct dev_context *devc;
unsigned int val;
float floatval;
@@ -678,22 +633,6 @@ static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt)
return;
}
- val = parse_quant(pkt, 0);
- if (val != devc->quant1) {
- if (send_quant1_update(sdi, val) == SR_OK)
- devc->quant1 = val;
- else
- return;
- }
-
- val = parse_quant(pkt, 1);
- if (val != devc->quant2) {
- if (send_quant2_update(sdi, val) == SR_OK)
- devc->quant2 = val;
- else
- return;
- }
-
val = parse_model(pkt);
if (val != devc->model) {
if (send_model_update(sdi, val) == SR_OK)
@@ -719,12 +658,13 @@ static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt)
frame = TRUE;
}
- packet.type = SR_DF_ANALOG;
+ packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
sr_session_send(devc->cb_data, &packet);
}
+ g_slist_free(analog.channels);
analog.channels = g_slist_append(NULL, sdi->channels->next->data);
parse_measurement(pkt, &floatval, &analog, 1);
@@ -735,12 +675,14 @@ static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt)
frame = TRUE;
}
- packet.type = SR_DF_ANALOG;
+ packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
sr_session_send(devc->cb_data, &packet);
}
+ g_slist_free(analog.channels);
+
if (frame) {
packet.type = SR_DF_FRAME_END;
sr_session_send(devc->cb_data, &packet);
@@ -879,13 +821,7 @@ SR_PRIV int es51919_serial_config_get(uint32_t key, GVariant **data,
switch (key) {
case SR_CONF_OUTPUT_FREQUENCY:
- *data = g_variant_new_uint64(frequencies[devc->freq]);
- break;
- case SR_CONF_MEASURED_QUANTITY:
- *data = g_variant_new_string(quantities1[devc->quant1]);
- break;
- case SR_CONF_MEASURED_2ND_QUANTITY:
- *data = g_variant_new_string(quantities2[devc->quant2]);
+ *data = g_variant_new_double(frequencies[devc->freq]);
break;
case SR_CONF_EQUIV_CIRCUIT_MODEL:
*data = g_variant_new_string(models[devc->model]);
@@ -940,8 +876,6 @@ static const uint32_t devopts[] = {
SR_CONF_LIMIT_FRAMES | SR_CONF_SET,
SR_CONF_LIMIT_MSEC | SR_CONF_SET,
SR_CONF_OUTPUT_FREQUENCY | SR_CONF_GET | SR_CONF_LIST,
- SR_CONF_MEASURED_QUANTITY | SR_CONF_GET | SR_CONF_LIST,
- SR_CONF_MEASURED_2ND_QUANTITY | SR_CONF_GET | SR_CONF_LIST,
SR_CONF_EQUIV_CIRCUIT_MODEL | SR_CONF_GET | SR_CONF_LIST,
};
@@ -962,16 +896,8 @@ SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data,
switch (key) {
case SR_CONF_OUTPUT_FREQUENCY:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
- frequencies, ARRAY_SIZE(frequencies), sizeof(uint64_t));
- break;
- case SR_CONF_MEASURED_QUANTITY:
- *data = g_variant_new_strv(list_quantities1,
- ARRAY_SIZE(list_quantities1));
- break;
- case SR_CONF_MEASURED_2ND_QUANTITY:
- *data = g_variant_new_strv(quantities2,
- ARRAY_SIZE(quantities2));
+ *data = g_variant_new_fixed_array(G_VARIANT_TYPE_DOUBLE,
+ frequencies, ARRAY_SIZE(frequencies), sizeof(double));
break;
case SR_CONF_EQUIV_CIRCUIT_MODEL:
*data = g_variant_new_strv(models, ARRAY_SIZE(models));
@@ -1001,7 +927,6 @@ SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi,
dev_limit_counter_start(&devc->frame_count);
dev_time_counter_start(&devc->time_count);
- /* Send header packet to the session bus. */
std_session_send_df_header(cb_data, LOG_PREFIX);
/* Poll every 50ms, or whenever some data comes in. */