X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fscpi%2Fscpi_libgpib.c;h=cab72df720f426bfcfc9f7f19909bb9862da7e03;hb=8256ed15c605db4f472f928dc67e9734947e0ab9;hp=31522eb19bcff871fba915ecfc13e1bd2111e2a3;hpb=27cd728f8a52026be5d83890c3d911fa29ee62f9;p=libsigrok.git diff --git a/src/scpi/scpi_libgpib.c b/src/scpi/scpi_libgpib.c index 31522eb1..cab72df7 100644 --- a/src/scpi/scpi_libgpib.c +++ b/src/scpi/scpi_libgpib.c @@ -49,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; @@ -84,8 +84,8 @@ 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; } @@ -118,7 +118,8 @@ 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.", + gpib_error_string(iberr)); return SR_ERR; } @@ -134,10 +135,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;