From: Daniel Trnka Date: Thu, 12 Mar 2020 11:08:35 +0000 (+0100) Subject: asix-sigma: check for successful register access in sample download X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f73b00b647ccca65e1aaba21a1b826f3f4b965ab;p=libsigrok.git asix-sigma: check for successful register access in sample download The previous implementation got stuck in an infinite loop when data acquisition started, but the device got disconnected before the data acquisition terminates. An implementation detail ignored communication errors, and never saw the expected condition that was required to continue in the sample download sequence. Unbreak that code path. --- diff --git a/src/hardware/asix-sigma/protocol.c b/src/hardware/asix-sigma/protocol.c index 93d26239..a9c16956 100644 --- a/src/hardware/asix-sigma/protocol.c +++ b/src/hardware/asix-sigma/protocol.c @@ -134,18 +134,6 @@ static int sigma_read_register(uint8_t reg, uint8_t *data, size_t len, return sigma_read(data, len, devc); } -static uint8_t sigma_get_register(uint8_t reg, struct dev_context *devc) -{ - uint8_t value; - - if (1 != sigma_read_register(reg, &value, 1, devc)) { - sr_err("sigma_get_register: 1 byte expected"); - return 0; - } - - return value; -} - static int sigma_read_pos(uint32_t *stoppos, uint32_t *triggerpos, struct dev_context *devc) { @@ -1031,7 +1019,10 @@ static int download_capture(struct sr_dev_inst *sdi) */ sigma_set_register(WRITE_MODE, WMR_FORCESTOP | WMR_SDRAMWRITEEN, devc); do { - modestatus = sigma_get_register(READ_MODE, devc); + if (sigma_read_register(READ_MODE, &modestatus, 1, devc) != 1) { + sr_err("sigma: failed while waiting for RMR_POSTTRIGGERED bit"); + return FALSE; + } } while (!(modestatus & RMR_POSTTRIGGERED)); /* Set SDRAM Read Enable. */ @@ -1041,7 +1032,10 @@ static int download_capture(struct sr_dev_inst *sdi) sigma_read_pos(&stoppos, &triggerpos, devc); /* Check if trigger has fired. */ - modestatus = sigma_get_register(READ_MODE, devc); + if (sigma_read_register(READ_MODE, &modestatus, 1, devc) != 1) { + sr_err("sigma: failed to read READ_MODE register"); + return FALSE; + } trg_line = ~0; trg_event = ~0; if (modestatus & RMR_TRIGGERED) {