X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhantek-dso%2Fapi.c;h=f0cbb6158276048186c11a6e970f76adb6b683ce;hb=d810901a45e01b8e79f6b269dbb931b538071953;hp=abbeb21b207aef72c3795c0a5d162bfd069b4100;hpb=6c1a76d1263403f908ac31271a4fd01792488545;p=libsigrok.git diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index abbeb21b..f0cbb615 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -55,7 +55,7 @@ static const uint32_t drvopts[] = { static const uint32_t devopts[] = { SR_CONF_CONTINUOUS, SR_CONF_CONN | SR_CONF_GET, - SR_CONF_LIMIT_FRAMES | SR_CONF_SET, + SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET, SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_NUM_HDIV | SR_CONF_GET, SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET, @@ -199,10 +199,8 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof) */ for (i = 0; i < ARRAY_SIZE(channel_names); i++) { ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]); - cg = g_malloc0(sizeof(struct sr_channel_group)); - cg->name = g_strdup(channel_names[i]); + cg = sr_channel_group_new(sdi, channel_names[i], NULL); cg->channels = g_slist_append(cg->channels, ch); - sdi->channel_groups = g_slist_append(sdi->channel_groups, cg); } devc = g_malloc0(sizeof(struct dev_context)); @@ -330,11 +328,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); @@ -476,6 +475,9 @@ static int config_get(uint32_t key, GVariant **data, case SR_CONF_CAPTURE_RATIO: *data = g_variant_new_uint64(devc->capture_ratio); break; + case SR_CONF_LIMIT_FRAMES: + *data = g_variant_new_uint64(devc->limit_frames); + break; default: return SR_ERR_NA; } @@ -703,7 +705,6 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf, */ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) { - struct sr_datafeed_packet packet; struct sr_dev_inst *sdi; struct dev_context *devc; int num_samples, pre; @@ -781,8 +782,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) devc->framebuf = NULL; /* Mark the end of this frame. */ - packet.type = SR_DF_FRAME_END; - sr_session_send(sdi, &packet); + std_session_send_df_frame_end(sdi); if (devc->limit_frames && ++devc->num_frames >= devc->limit_frames) { /* Terminate session */ @@ -796,7 +796,6 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) static int handle_event(int fd, int revents, void *cb_data) { const struct sr_dev_inst *sdi; - struct sr_datafeed_packet packet; struct timeval tv; struct sr_dev_driver *di; struct dev_context *devc; @@ -888,8 +887,7 @@ static int handle_event(int fd, int revents, void *cb_data) devc->dev_state = FETCH_DATA; /* Tell the frontend a new frame is on the way. */ - packet.type = SR_DF_FRAME_BEGIN; - sr_session_send(sdi, &packet); + std_session_send_df_frame_begin(sdi); break; case CAPTURE_READY_9BIT: /* TODO */