Skip to content

Commit

Permalink
scpi: Add a function to read and wait on a *OPC? reply.
Browse files Browse the repository at this point in the history
  • Loading branch information
poljar (Damir Jelić) committed Nov 9, 2013
1 parent 686bd68 commit e264e87
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hardware/common/scpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,23 @@ SR_PRIV int sr_scpi_get_floatv(struct sr_serial_dev_inst *serial,
return ret;
}

SR_PRIV int sr_scpi_get_opc(struct sr_serial_dev_inst *serial)
{
unsigned int i;
gboolean opc;

for (i = 0; i < SCPI_READ_RETRIES; ++i) {
sr_scpi_get_bool(serial, SCPI_CMD_OPC, &opc);

if (opc)
return SR_OK;

g_usleep(SCPI_READ_RETRY_TIMEOUT);
}

return SR_ERR;
}

/**
* Send the *IDN? SCPI command, receive the reply, parse it and return the
* reply as a sr_scpi_hw_info structure.
Expand Down
1 change: 1 addition & 0 deletions libsigrok-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ SR_PRIV int sr_scpi_get_float(struct sr_serial_dev_inst *serial,
const char *command, float *scpi_response);
SR_PRIV int sr_scpi_get_floatv(struct sr_serial_dev_inst *serial,
const char *command, GArray **scpi_response);
SR_PRIV int sr_scpi_get_opc(struct sr_serial_dev_inst *serial);
SR_PRIV int sr_scpi_get_hw_id(struct sr_serial_dev_inst *serial,
struct sr_scpi_hw_info **scpi_reponse);
SR_PRIV void sr_scpi_hw_info_free(struct sr_scpi_hw_info *hw_info);
Expand Down

0 comments on commit e264e87

Please sign in to comment.