]> sigrok.org Git - libsigrok.git/blobdiff - hardware/uni-t-dmm/api.c
Add and use std_session_send_df_header().
[libsigrok.git] / hardware / uni-t-dmm / api.c
index 26b3e16e7a8fe6327cd8dd2f43f62fb32747de66..7662fb072fde63a85318b22f127f4c2478ecf733 100644 (file)
@@ -57,23 +57,13 @@ static int clear_instances(void)
 
 static int hw_init(struct sr_context *sr_ctx, int dmm)
 {
-       struct drv_context *drvc;
-
-       if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
-               sr_err("Driver context malloc failed.");
-               return SR_ERR_MALLOC;
-       }
-
        if (dmm == UNI_T_UT61D)
                di = di_ut61d;
        else if (dmm == VOLTCRAFT_VC820)
                di = di_vc820;
        sr_dbg("Selected '%s' subdriver.", di->name);
 
-       drvc->sr_ctx = sr_ctx;
-       di->priv = drvc;
-
-       return SR_OK;
+       return std_hw_init(sr_ctx, di, DRIVER_LOG_DOMAIN);
 }
 
 static int hw_init_ut61d(struct sr_context *sr_ctx)
@@ -152,11 +142,7 @@ static GSList *hw_scan(GSList *options)
 
 static GSList *hw_dev_list(void)
 {
-       struct drv_context *drvc;
-
-       drvc = di->priv;
-
-       return drvc->instances;
+       return ((struct drv_context *)(di->priv))->instances;
 }
 
 static int hw_dev_open(struct sr_dev_inst *sdi)
@@ -243,23 +229,14 @@ static int config_list(int key, const void **data, const struct sr_dev_inst *sdi
 static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
                                    void *cb_data)
 {
-       struct sr_datafeed_packet packet;
-       struct sr_datafeed_header header;
        struct dev_context *devc;
 
        devc = sdi->priv;
 
-       sr_dbg("Starting acquisition.");
-
        devc->cb_data = cb_data;
 
        /* Send header packet to the session bus. */
-       sr_dbg("Sending SR_DF_HEADER.");
-       packet.type = SR_DF_HEADER;
-       packet.payload = (uint8_t *)&header;
-       header.feed_version = 1;
-       gettimeofday(&header.starttime, NULL);
-       sr_session_send(devc->cb_data, &packet);
+       std_session_send_df_header(cb_data, DRIVER_LOG_DOMAIN);
 
        if (!strcmp(di->name, "uni-t-ut61d")) {
                sr_source_add(0, 0, 10 /* poll_timeout */,