X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Fhantek-dso%2Fapi.c;h=c1b18ea9ca660a52ec8b2e4113d637b3b8a1e88c;hb=755793e991c4d429f99254f23008bfddb89d8e00;hp=663cd55dfcd668e732313b2a613be21015219469;hpb=12f62ce62094500250062c4d0d0b78deeb303ec9;p=libsigrok.git diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index 663cd55d..c1b18ea9 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -148,7 +148,7 @@ static const uint64_t samplerates[] = { SR_MHZ(50), SR_MHZ(100), SR_MHZ(125), - /* fast mode not supported yet + /* Fast mode not supported yet. SR_MHZ(200), SR_MHZ(250), */ }; @@ -315,7 +315,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) libusb_get_device_descriptor(devlist[i], &des); - usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)); + if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0) + continue; prof = NULL; for (j = 0; dev_profiles[j].orig_vid; j++) { @@ -329,11 +330,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) devices = g_slist_append(devices, sdi); devc = sdi->priv; if (ezusb_upload_firmware(drvc->sr_ctx, devlist[i], - USB_CONFIGURATION, prof->firmware) == SR_OK) + USB_CONFIGURATION, prof->firmware) == SR_OK) { /* Remember when the firmware on this device was updated */ devc->fw_updated = g_get_monotonic_time(); - else - sr_err("Firmware upload failed"); + } else { + sr_err("Firmware upload failed, name %s", prof->firmware); + } /* Dummy USB address of 0xff will get overwritten later. */ sdi->conn = sr_usb_dev_inst_new( libusb_get_bus_number(devlist[i]), 0xff, NULL); @@ -506,7 +508,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; - int rat; int ch_idx, idx; float flt; @@ -522,11 +523,9 @@ static int config_set(uint32_t key, GVariant *data, sr_err("Trigger level must be in [0.0,1.0]."); return SR_ERR_ARG; } - devc->voffset_trigger = flt; - if (dso_set_voffsets(sdi) != SR_OK) { - return SR_ERR; - } + if (dso_set_voffsets(sdi) != SR_OK) + return SR_ERR; break; case SR_CONF_TRIGGER_SLOPE: if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_slopes))) < 0) @@ -534,12 +533,7 @@ static int config_set(uint32_t key, GVariant *data, devc->triggerslope = idx; break; case SR_CONF_CAPTURE_RATIO: - rat = g_variant_get_uint64(data); - if (rat < 0 || rat > 100) { - sr_err("Capture ratio must be in [0,100]."); - return SR_ERR_ARG; - } else - devc->capture_ratio = rat; + devc->capture_ratio = g_variant_get_uint64(data); break; case SR_CONF_BUFFERSIZE: if ((idx = std_u64_idx(data, devc->profile->buffersizes, NUM_BUFFER_SIZES)) < 0) @@ -557,7 +551,6 @@ static int config_set(uint32_t key, GVariant *data, devc->samplerate = samplerates[idx]; if (dso_set_trigger_samplerate(sdi) != SR_OK) return SR_ERR; - sr_dbg("got new sample rate %d, idx %d", devc->samplerate, idx); break; case SR_CONF_TRIGGER_SOURCE: if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_sources))) < 0) @@ -792,7 +785,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) packet.type = SR_DF_FRAME_END; sr_session_send(sdi, &packet); - if (devc->limit_frames && ++devc->num_frames == devc->limit_frames) { + if (devc->limit_frames && ++devc->num_frames >= devc->limit_frames) { /* Terminate session */ devc->dev_state = STOPPING; } else { @@ -877,7 +870,7 @@ static int handle_event(int fd, int revents, void *cb_data) /* No data yet. */ break; case CAPTURE_READY_8BIT: - case CAPTURE_READY2250: + case CAPTURE_READY_2250: /* Remember where in the captured frame the trigger is. */ devc->trigger_offset = trigger_offset; @@ -947,6 +940,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) devc = sdi->priv; devc->dev_state = STOPPING; + devc->num_frames = 0; return SR_OK; }