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)
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)
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 */,