X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fscpi%2Fscpi_libgpib.c;h=2f3256be948e2eae404d02cda0e38b4391bab465;hb=928560e6f52f1287155ae8deb9e97e5607ec98db;hp=6b156b2cb5dfaddb88aedc75a67752ba95e208e8;hpb=5a1afc0907abfee5848484f944789213d6be9752;p=libsigrok.git
diff --git a/src/scpi/scpi_libgpib.c b/src/scpi/scpi_libgpib.c
index 6b156b2c..2f3256be 100644
--- a/src/scpi/scpi_libgpib.c
+++ b/src/scpi/scpi_libgpib.c
@@ -17,6 +17,7 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
@@ -48,9 +49,9 @@ static int scpi_gpib_dev_inst_new(void *priv, struct drv_context *drvc,
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;
@@ -83,15 +84,15 @@ static int scpi_gpib_send(void *priv, const char *command)
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 (ibcnt < len)
{
sr_err("Failed to send all of SCPI command: '%s': "
- "len = %d, ibcnt = .", command, len, ibcnt);
+ "len = %d, ibcnt = %d.", command, len, ibcnt);
return SR_ERR;
}
@@ -117,7 +118,9 @@ static int scpi_gpib_read_data(void *priv, char *buf, int maxlen)
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;
}
@@ -133,10 +136,13 @@ static int scpi_gpib_read_complete(void *priv)
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;