#include "protocol.h"
-static const char *manufacturers[] = {
- "HAMEG",
-};
-
static const char *hameg_scpi_dialect[] = {
[SCPI_CMD_GET_DIG_DATA] = ":POD%d:DATA?",
[SCPI_CMD_GET_TIMEBASE] = ":TIM:SCAL?",
},
};
-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 void scope_state_dump(struct scope_config *config,
struct scope_state *state)
{
state->horiz_triggerpos);
}
-static int scope_state_get_array_option(struct sr_serial_dev_inst *serial,
+static int scope_state_get_array_option(struct sr_scpi_dev_inst *scpi,
const char *command, const char *(*array)[], int *result)
{
char *tmp;
unsigned int i;
- if (sr_scpi_get_string(serial, command, &tmp) != SR_OK) {
+ if (sr_scpi_get_string(scpi, command, &tmp) != SR_OK) {
g_free(tmp);
return SR_ERR;
}
return SR_OK;
}
-static int analog_channel_state_get(struct sr_serial_dev_inst *serial,
+static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi,
struct scope_config *config,
struct scope_state *state)
{
(*config->scpi_dialect)[SCPI_CMD_GET_ANALOG_CHAN_STATE],
i + 1);
- if (sr_scpi_get_bool(serial, command,
+ if (sr_scpi_get_bool(scpi, command,
&state->analog_channels[i].state) != SR_OK)
return SR_ERR;
(*config->scpi_dialect)[SCPI_CMD_GET_VERTICAL_DIV],
i + 1);
- if (sr_scpi_get_float(serial, command,
+ if (sr_scpi_get_float(scpi, command,
&state->analog_channels[i].vdiv) != SR_OK)
return SR_ERR;
(*config->scpi_dialect)[SCPI_CMD_GET_VERTICAL_OFFSET],
i + 1);
- if (sr_scpi_get_float(serial, command,
+ if (sr_scpi_get_float(scpi, command,
&state->analog_channels[i].vertical_offset) != SR_OK)
return SR_ERR;
(*config->scpi_dialect)[SCPI_CMD_GET_COUPLING],
i + 1);
- if (scope_state_get_array_option(serial, command, config->coupling_options,
+ if (scope_state_get_array_option(scpi, command, config->coupling_options,
&state->analog_channels[i].coupling) != SR_OK)
return SR_ERR;
}
return SR_OK;
}
-static int digital_channel_state_get(struct sr_serial_dev_inst *serial,
+static int digital_channel_state_get(struct sr_scpi_dev_inst *scpi,
struct scope_config *config,
struct scope_state *state)
{
(*config->scpi_dialect)[SCPI_CMD_GET_DIG_CHAN_STATE],
i);
- if (sr_scpi_get_bool(serial, command,
+ if (sr_scpi_get_bool(scpi, command,
&state->digital_channels[i]) != SR_OK)
return SR_ERR;
}
(*config->scpi_dialect)[SCPI_CMD_GET_DIG_POD_STATE],
i + 1);
- if (sr_scpi_get_bool(serial, command,
+ if (sr_scpi_get_bool(scpi, command,
&state->digital_pods[i]) != SR_OK)
return SR_ERR;
}
return SR_OK;
}
-SR_PRIV 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_serial_dev_inst *serial;
-
- sdi = NULL;
- devc = NULL;
- serial = NULL;
- hw_info = NULL;
-
- if (!(serial = sr_serial_dev_inst_new(serial_device, serial_options)))
- goto fail;
-
- sr_info("Probing %s.", serial_device);
- if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
- goto fail;
-
- if (sr_scpi_get_hw_id(serial, &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_SERIAL;
- sdi->conn = serial;
-
- if (hmo_init_device(sdi) != SR_OK)
- goto fail;
-
- return sdi;
-
-fail:
- if (hw_info)
- sr_scpi_hw_info_free(hw_info);
- if (serial)
- sr_serial_dev_inst_free(serial);
- if (sdi)
- sr_dev_inst_free(sdi);
- if (devc)
- g_free(devc);
-
- return NULL;
-}
-
SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
{
struct sr_probe *probe;