#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_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;
+
+ sr_scpi_close(sdi->conn);
+
+ sdi->status = SR_ST_INACTIVE;
+
+ 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;
{
int ret, pg_type;
unsigned int i, j;
- char command[MAX_COMMAND_SIZE];
+ char command[MAX_COMMAND_SIZE], float_str[30];
struct dev_context *devc;
struct scope_config *model;
struct scope_state *state;
for (j = 1; j <= model->analog_channels; ++j) {
if (probe_group != &devc->analog_groups[j - 1])
continue;
- state->analog_channels[j - 1].vdiv = (float) p / q;
+ state->analog_channels[j - 1].vdiv = i;
+ g_ascii_formatd(float_str, sizeof(float_str), "%E", (float) p / q);
g_snprintf(command, sizeof(command),
(*model->scpi_dialect)[SCPI_CMD_SET_VERTICAL_DIV],
- j, state->analog_channels[j-1].vdiv);
+ j, float_str);
if (sr_scpi_send(sdi->conn, command) != SR_OK ||
sr_scpi_get_opc(sdi->conn) != SR_OK)
if (p != (*model->timebases)[i][0] ||
q != (*model->timebases)[i][1])
continue;
- state->timebase = (float) p / q;
+ state->timebase = i;
+ g_ascii_formatd(float_str, sizeof(float_str), "%E", (float) p / q);
g_snprintf(command, sizeof(command),
(*model->scpi_dialect)[SCPI_CMD_SET_TIMEBASE],
- state->timebase);
+ float_str);
ret = sr_scpi_send(sdi->conn, command);
break;
{
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi;
+ struct sr_datafeed_packet packet;
(void)cb_data;
+ packet.type = SR_DF_END;
+ packet.payload = NULL;
+ sr_session_send(sdi, &packet);
+
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;