X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Flcr%2Fes51919.c;h=7c084f7f19287bd5192ba0d953f94634bba63947;hb=15f96409dc54fd2ef784c59156daedd9acfa78ed;hp=cbce7dcd849d15332200850962bc69d23f829ecf;hpb=83478149b1d5a0476c15241dfce1fb2cf014e0c5;p=libsigrok.git
diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c
index cbce7dcd..7c084f7f 100644
--- a/src/lcr/es51919.c
+++ b/src/lcr/es51919.c
@@ -17,6 +17,7 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
@@ -414,9 +415,6 @@ static const char *const models[] = {
/** Private, per-device-instance driver context. */
struct dev_context {
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The number of frames. */
struct dev_limit_counter frame_count;
@@ -484,7 +482,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 {
@@ -594,11 +592,7 @@ static gboolean packet_valid(const uint8_t *pkt)
static int do_config_update(struct sr_dev_inst *sdi, uint32_t key,
GVariant *var)
{
- struct dev_context *devc;
-
- devc = sdi->priv;
-
- return send_config_update_key(devc->cb_data, key, var);
+ return send_config_update_key(sdi, key, var);
}
static int send_freq_update(struct sr_dev_inst *sdi, unsigned int freq)
@@ -616,7 +610,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;
@@ -653,14 +647,14 @@ static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt)
if (analog.mq >= 0) {
if (!frame) {
packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
frame = TRUE;
}
- packet.type = SR_DF_ANALOG;
+ packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
g_slist_free(analog.channels);
@@ -670,21 +664,21 @@ static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt)
if (analog.mq >= 0) {
if (!frame) {
packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
frame = TRUE;
}
- packet.type = SR_DF_ANALOG;
+ packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
g_slist_free(analog.channels);
if (frame) {
packet.type = SR_DF_FRAME_END;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
dev_limit_counter_inc(&devc->frame_count);
}
}
@@ -728,7 +722,7 @@ static int receive_data(int fd, int revents, void *cb_data)
if (dev_limit_counter_limit_reached(&devc->frame_count) ||
dev_time_limit_reached(&devc->time_count))
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
@@ -815,8 +809,7 @@ SR_PRIV int es51919_serial_config_get(uint32_t key, GVariant **data,
(void)cg;
- if (!(devc = sdi->priv))
- return SR_ERR_BUG;
+ devc = sdi->priv;
switch (key) {
case SR_CONF_OUTPUT_FREQUENCY:
@@ -826,7 +819,6 @@ SR_PRIV int es51919_serial_config_get(uint32_t key, GVariant **data,
*data = g_variant_new_string(models[devc->model]);
break;
default:
- sr_spew("%s: Unsupported key %u", __func__, key);
return SR_ERR_NA;
}
@@ -902,15 +894,13 @@ SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data,
*data = g_variant_new_strv(models, ARRAY_SIZE(models));
break;
default:
- sr_spew("%s: Unsupported key %u", __func__, key);
return SR_ERR_NA;
}
return SR_OK;
}
-SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi,
- void *cb_data)
+SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
@@ -921,13 +911,10 @@ SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi,
if (!(devc = sdi->priv))
return SR_ERR_BUG;
- devc->cb_data = cb_data;
-
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);
+ std_session_send_df_header(sdi);
/* Poll every 50ms, or whenever some data comes in. */
serial = sdi->conn;
@@ -937,9 +924,8 @@ SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi,
return SR_OK;
}
-SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi,
- void *cb_data)
+SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data,
- std_serial_dev_close, sdi->conn, LOG_PREFIX);
+ return std_serial_dev_acquisition_stop(sdi,
+ std_serial_dev_close);
}