X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fscpi%2Fscpi.c;h=48e6a48495c9bfaba591147a12f715b67fe0b493;hb=94927260421eb8c5548294bbe5000b04bd1f0aa7;hp=9ea68b57316db06ad8d324cef67c41016f867227;hpb=7b365c47198890da8541a6daf04697c7c7ac88d4;p=libsigrok.git diff --git a/src/scpi/scpi.c b/src/scpi/scpi.c index 9ea68b57..48e6a484 100644 --- a/src/scpi/scpi.c +++ b/src/scpi/scpi.c @@ -337,6 +337,21 @@ SR_PRIV int sr_scpi_read_data(struct sr_scpi_dev_inst *scpi, return scpi->read_data(scpi->priv, buf, maxlen); } +/** + * Send data to SCPI device. + * + * @param scpi Previously initialised SCPI device structure. + * @param buf Buffer with data to send. + * @param len Number of bytes to send. + * + * @return Number of bytes read, or SR_ERR upon failure. + */ +SR_PRIV int sr_scpi_write_data(struct sr_scpi_dev_inst *scpi, + char *buf, int maxlen) +{ + return scpi->write_data(scpi->priv, buf, maxlen); +} + /** * Check whether a complete SCPI response has been received. * @@ -364,12 +379,14 @@ SR_PRIV int sr_scpi_close(struct sr_scpi_dev_inst *scpi) /** * Free SCPI device. * - * @param scpi Previously initialized SCPI device structure. - * - * @return SR_OK on success, SR_ERR on failure. + * @param scpi Previously initialized SCPI device structure. If NULL, + * this function does nothing. */ SR_PRIV void sr_scpi_free(struct sr_scpi_dev_inst *scpi) { + if (!scpi) + return; + scpi->free(scpi->priv); g_free(scpi->priv); g_free(scpi);