#define SERIALCOMM "115200/8n1/flow=1"
+SR_PRIV struct sr_dev_driver hameg_hmo_driver_info;
+static struct sr_dev_driver *di = &hameg_hmo_driver_info;
+
+static const char *manufacturers[] = {
+ "HAMEG",
+};
+
static const int32_t hwopts[] = {
SR_CONF_CONN,
SR_CONF_SERIALCOMM,
#endif
}
+static int check_manufacturer(const char *manufacturer)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(manufacturers); ++i)
+ if (!strcmp(manufacturer, manufacturers[i]))
+ return SR_OK;
+
+ return SR_ERR;
+}
+
+static struct sr_dev_inst *hmo_probe_serial_device(const char *serial_device,
+ const char *serial_options)
+{
+ struct sr_dev_inst *sdi;
+ struct dev_context *devc;
+ struct sr_scpi_hw_info *hw_info;
+ struct sr_scpi_dev_inst *scpi;
+
+ sdi = NULL;
+ devc = NULL;
+ scpi = NULL;
+ hw_info = NULL;
+
+ if (!(scpi = scpi_serial_dev_inst_new(serial_device, serial_options)))
+ goto fail;
+
+ sr_info("Probing %s.", serial_device);
+ if (sr_scpi_open(scpi) != SR_OK)
+ goto fail;
+
+ if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) {
+ sr_info("Couldn't get IDN response.");
+ goto fail;
+ }
+
+ if (check_manufacturer(hw_info->manufacturer) != SR_OK)
+ goto fail;
+
+ if (!(sdi = sr_dev_inst_new(0, SR_ST_ACTIVE,
+ hw_info->manufacturer, hw_info->model,
+ hw_info->firmware_version))) {
+ goto fail;
+ }
+ sr_scpi_hw_info_free(hw_info);
+ hw_info = NULL;
+
+ if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
+ goto fail;
+
+ sdi->driver = di;
+ sdi->priv = devc;
+ sdi->inst_type = SR_INST_SCPI;
+ sdi->conn = scpi;
+
+ if (hmo_init_device(sdi) != SR_OK)
+ goto fail;
+
+ return sdi;
+
+fail:
+ if (hw_info)
+ sr_scpi_hw_info_free(hw_info);
+ if (scpi)
+ sr_scpi_free(scpi);
+ if (sdi)
+ sr_dev_inst_free(sdi);
+ if (devc)
+ g_free(devc);
+
+ return NULL;
+}
+
static GSList *scan(GSList *options)
{
GSList *devices;
static int dev_open(struct sr_dev_inst *sdi)
{
- if (sdi->status != SR_ST_ACTIVE &&
- serial_open(sdi->conn, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
+ if (sdi->status != SR_ST_ACTIVE && sr_scpi_open(sdi->conn) != SR_OK)
return SR_ERR;
if (hmo_scope_state_get(sdi) != SR_OK)
if (sdi->status == SR_ST_INACTIVE)
return SR_OK;
- serial_close(sdi->conn);
+ sr_scpi_close(sdi->conn);
sdi->status = SR_ST_INACTIVE;
struct scope_config *model;
struct sr_probe *probe;
struct dev_context *devc;
- struct sr_serial_dev_inst *serial;
+ struct sr_scpi_dev_inst *scpi;
devc = sdi->priv;
- serial = sdi->conn;
+ scpi = sdi->conn;
state = devc->model_state;
model = devc->model_config;
(*model->scpi_dialect)[SCPI_CMD_SET_ANALOG_CHAN_STATE],
probe->index + 1, probe->enabled);
- if (sr_scpi_send(serial, command) != SR_OK)
+ if (sr_scpi_send(scpi, command) != SR_OK)
return SR_ERR;
state->analog_channels[probe->index].state = probe->enabled;
break;
(*model->scpi_dialect)[SCPI_CMD_SET_DIG_CHAN_STATE],
probe->index, probe->enabled);
- if (sr_scpi_send(serial, command) != SR_OK)
+ if (sr_scpi_send(scpi, command) != SR_OK)
return SR_ERR;
state->digital_channels[probe->index] = probe->enabled;
g_snprintf(command, sizeof(command),
(*model->scpi_dialect)[SCPI_CMD_SET_DIG_POD_STATE],
i, pod_enabled[i - 1]);
- if (sr_scpi_send(serial, command) != SR_OK)
+ if (sr_scpi_send(scpi, command) != SR_OK)
return SR_ERR;
state->digital_pods[i - 1] = pod_enabled[i - 1];
}
gboolean digital_added;
struct sr_probe *probe;
struct dev_context *devc;
- struct sr_serial_dev_inst *serial;
+ struct sr_scpi_dev_inst *scpi;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- serial = sdi->conn;
+ scpi = sdi->conn;
devc = sdi->priv;
digital_added = FALSE;
return SR_ERR;
}
- sr_source_add(serial->fd, G_IO_IN, 50, hmo_receive_data, (void *)sdi);
+ sr_scpi_source_add(scpi, G_IO_IN, 50, hmo_receive_data, (void *)sdi);
/* Send header packet to the session bus. */
std_session_send_df_header(cb_data, LOG_PREFIX);
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct dev_context *devc;
- struct sr_serial_dev_inst *serial;
+ struct sr_scpi_dev_inst *scpi;
(void)cb_data;
g_slist_free(devc->enabled_probes);
devc->enabled_probes = NULL;
- serial = sdi->conn;
- sr_source_remove(serial->fd);
+ scpi = sdi->conn;
+ sr_scpi_source_remove(scpi);
return SR_OK;
}