return SR_OK;
}
-static int scpi_gpib_open(void *priv)
+static int scpi_gpib_open(struct sr_scpi_dev_inst *scpi)
{
- struct scpi_gpib *gscpi = priv;
+ struct scpi_gpib *gscpi = scpi->priv;
if ((gscpi->descriptor = ibfind(gscpi->name)) < 0)
return SR_ERR;
if (ibsta & ERR)
{
- sr_err("Error while sending SCPI command: '%s': iberr = %d.",
- command, iberr);
+ sr_err("Error while sending SCPI command: '%s': iberr = %s.",
+ command, gpib_error_string(iberr));
return SR_ERR;
}
if (ibsta & ERR)
{
- sr_err("Error while reading SCPI response: iberr = %d.", iberr);
+ sr_err("Error while reading SCPI response: "
+ "iberr = %s, ibsta = %d.",
+ gpib_error_string(iberr), ibsta);
return SR_ERR;
}
return gscpi->read_started && (ibsta & END);
}
-static int scpi_gpib_close(void *priv)
+static int scpi_gpib_close(struct sr_scpi_dev_inst *scpi)
{
- struct scpi_gpib *gscpi = priv;
+ struct scpi_gpib *gscpi = scpi->priv;
+ /* Put device in back local mode to prevent lock-out of front panel. */
+ ibloc(gscpi->descriptor);
+ /* Now it's safe to close the handle. */
ibonl(gscpi->descriptor, 0);
return SR_OK;