-SR_PRIV struct sr_dev_inst *hameg_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 hameg_hmo_receive_data(int fd, int revents, void *cb_data)