X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Ftesto%2Fapi.c;h=933b86bae7b4b02fd2f50e45895634f7f4f90e31;hb=7e463623382e1f574fde150b3fc88a65eaebb578;hp=4d9a7a42a6469294db89e1130c1cdfd30c42ac51;hpb=15a5bfe4815f9991a9bb532c05d6244a1818a0e4;p=libsigrok.git diff --git a/src/hardware/testo/api.c b/src/hardware/testo/api.c index 4d9a7a42..933b86ba 100644 --- a/src/hardware/testo/api.c +++ b/src/hardware/testo/api.c @@ -22,7 +22,6 @@ #include "protocol.h" #define SERIALCOMM "115200/8n1" -static int dev_acquisition_stop(struct sr_dev_inst *sdi); static const uint32_t scanopts[] = { SR_CONF_CONN, @@ -163,7 +162,6 @@ static int dev_open(struct sr_dev_inst *sdi) sr_err("Failed to claim interface: %s.", libusb_error_name(ret)); return SR_ERR; } - sdi->status = SR_ST_ACTIVE; return SR_OK; } @@ -174,7 +172,7 @@ static int dev_close(struct sr_dev_inst *sdi) usb = sdi->conn; if (!usb->devhdl) - /* Nothing to do. */ + /* Nothing to do. */ return SR_OK; libusb_release_interface(usb->devhdl, 0); @@ -219,9 +217,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd (void)cg; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - return sr_sw_limits_config_set(&devc->sw_limits, key, data); } @@ -285,7 +280,7 @@ static void receive_data(struct sr_dev_inst *sdi, unsigned char *data, int len) devc->reply_size = 0; if (sr_sw_limits_check(&devc->sw_limits)) - dev_acquisition_stop(sdi); + sr_dev_acquisition_stop(sdi); else testo_request_packet(sdi); @@ -305,7 +300,7 @@ SR_PRIV void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) { /* USB device was unplugged. */ - dev_acquisition_stop(sdi); + sr_dev_acquisition_stop(sdi); } else if (transfer->status == LIBUSB_TRANSFER_COMPLETED) { /* First two bytes in any transfer are FTDI status bytes. */ if (transfer->actual_length > 2) @@ -320,7 +315,7 @@ SR_PRIV void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) libusb_error_name(ret)); g_free(transfer->buffer); libusb_free_transfer(transfer); - dev_acquisition_stop(sdi); + sr_dev_acquisition_stop(sdi); } } else { /* This was the last transfer we're going to receive, so @@ -347,12 +342,12 @@ static int handle_events(int fd, int revents, void *cb_data) drvc = di->context; if (sr_sw_limits_check(&devc->sw_limits)) - dev_acquisition_stop(sdi); + sr_dev_acquisition_stop(sdi); if (sdi->status == SR_ST_STOPPING) { usb_source_remove(sdi->session, drvc->sr_ctx); dev_close(sdi); - std_session_send_df_end(sdi, LOG_PREFIX); + std_session_send_df_end(sdi); } memset(&tv, 0, sizeof(struct timeval)); @@ -373,15 +368,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) unsigned char *buf; drvc = di->context; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - - devc = sdi->priv; usb = sdi->conn; devc->reply_size = 0; - std_session_send_df_header(sdi, LOG_PREFIX); + std_session_send_df_header(sdi); usb_source_add(sdi->session, drvc->sr_ctx, 100, handle_events, (void *)sdi); @@ -412,9 +403,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - sdi->status = SR_ST_STOPPING; return SR_OK;