]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/maynuo-m97/api.c
Factor out std_session_send_df_end() helper.
[libsigrok.git] / src / hardware / maynuo-m97 / api.c
index f1afdfe6cb886158bb92a8d0b7b58f52c0ff185f..090bae3e1fcd91433b92ad8a56250277366675ad 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include "protocol.h"
 
 static const uint32_t scanopts[] = {
@@ -128,13 +129,13 @@ static struct sr_dev_inst *probe_device(struct sr_modbus_dev_inst *modbus)
        int ret = maynuo_m97_get_model_version(modbus, &id, &version);
        if (ret != SR_OK)
                return NULL;
-       for (i=0; i<ARRAY_SIZE(supported_models); i++)
+       for (i = 0; i < ARRAY_SIZE(supported_models); i++)
                if (id == supported_models[i].id) {
                        model = &supported_models[i];
                        break;
                }
        if (model == NULL) {
-               sr_err("Unkown model: %d.", id);
+               sr_err("Unknown model: %d.", id);
                return NULL;
        }
 
@@ -188,7 +189,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        if (!g_slist_find_custom(options, &default_modbusaddr, config_compare))
                opts = g_slist_prepend(opts, &default_modbusaddr);
 
-       devices = sr_modbus_scan(di->priv, opts, probe_device);
+       devices = sr_modbus_scan(di->context, opts, probe_device);
 
        while (opts != options)
                opts = g_slist_delete_link(opts, opts);
@@ -200,7 +201,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
 static GSList *dev_list(const struct sr_dev_driver *di)
 {
-       return ((struct drv_context *)(di->priv))->instances;
+       return ((struct drv_context *)(di->context))->instances;
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
@@ -483,16 +484,13 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
        struct sr_modbus_dev_inst *modbus;
-       struct sr_datafeed_packet packet;
 
        (void)cb_data;
 
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;
 
-       /* End of last frame. */
-       packet.type = SR_DF_END;
-       sr_session_send(sdi, &packet);
+       std_session_send_df_end(sdi, LOG_PREFIX);
 
        modbus = sdi->conn;
        sr_modbus_source_remove(sdi->session, modbus);
@@ -516,5 +514,5 @@ SR_PRIV struct sr_dev_driver maynuo_m97_driver_info = {
        .dev_close = dev_close,
        .dev_acquisition_start = dev_acquisition_start,
        .dev_acquisition_stop = dev_acquisition_stop,
-       .priv = NULL,
+       .context = NULL,
 };