]> sigrok.org Git - libsigrok.git/blobdiff - hardware/hameg-hmo/protocol.c
Use new libserialport event set API to make GPollFDs for serial sources.
[libsigrok.git] / hardware / hameg-hmo / protocol.c
index d76a6778e6d80dc7922f07b3a7caf53977a0b883..d014eafe9cec9ac2ae1ad6cf3e83232fdf7f3695 100644 (file)
 
 #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?",
@@ -256,17 +252,6 @@ static struct scope_config scope_models[] = {
        },
 };
 
-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)
 {
@@ -296,13 +281,13 @@ static void scope_state_dump(struct scope_config *config,
                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;
        }
@@ -324,7 +309,7 @@ static int scope_state_get_array_option(struct sr_serial_dev_inst *serial,
        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)
 {
@@ -336,7 +321,7 @@ static int analog_channel_state_get(struct sr_serial_dev_inst *serial,
                           (*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;
 
@@ -344,7 +329,7 @@ static int analog_channel_state_get(struct sr_serial_dev_inst *serial,
                           (*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;
 
@@ -352,7 +337,7 @@ static int analog_channel_state_get(struct sr_serial_dev_inst *serial,
                           (*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;
 
@@ -360,7 +345,7 @@ static int analog_channel_state_get(struct sr_serial_dev_inst *serial,
                           (*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;
        }
@@ -368,7 +353,7 @@ static int analog_channel_state_get(struct sr_serial_dev_inst *serial,
        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)
 {
@@ -380,7 +365,7 @@ static int digital_channel_state_get(struct sr_serial_dev_inst *serial,
                           (*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;
        }
@@ -390,7 +375,7 @@ static int digital_channel_state_get(struct sr_serial_dev_inst *serial,
                           (*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;
        }
@@ -560,68 +545,6 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
        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;