static int hw_dev_close(struct sr_dev_inst *sdi)
{
- printf("dev close\n");
struct dev_context *devc;
devc = sdi->priv;
ret = SR_OK;
break;
case SR_HWCAP_LIMIT_SAMPLES:
- ret = SR_OK;
+ {
+ const uint64_t num_samples = *(const uint64_t *)value;
+ if (num_samples < 1024)
+ {
+ sr_err("minimum of 1024 samples required");
+ ret = SR_ERR_ARG;
+
+ } else {
+ devc->limit_samples = num_samples;
+ sr_dbg("setting limit_samples to %i\n", num_samples);
+ ret = SR_OK;
+ }
+ }
break;
case SR_HWCAP_CAPTURE_RATIO:
ret = SR_OK;
break;
case SR_HWCAP_TRIGGER_SLOPE:
{
- uint64_t slope = *(const uint64_t *)value;
+ const uint64_t slope = *(const uint64_t *)value;
if (slope != SLOPE_NEGATIVE && slope != SLOPE_POSITIVE)
{
sr_err("Invalid trigger slope");
break;
case SR_HWCAP_HORIZ_TRIGGERPOS:
{
- float pos = *(const float *)value;
+ const float pos = *(const float *)value;
if (pos < 0 || pos > 255) {
sr_err("Trigger position (%f) should be between 0 and 255.", pos);
ret = SR_ERR_ARG;
} else {
int trigger_pos = (int)pos;
- printf("Set trigger posion to %X\n", trigger_pos&0xff);
devc->trigger_holdoff[0] = trigger_pos&0xff;
ret = SR_OK;
}
int ret = SR_ERR;
- printf("Accquistion start\n");
devc = sdi->priv;
if (sdi->status != SR_ST_ACTIVE)
devc->ctlbase1 &= 0x7f;
// devc->ctlbase1 |= devc->acdcmode;
- printf("Configure rate\n");
ret = mso_configure_rate(sdi, devc->cur_rate);
if (ret != SR_OK)
return ret;
/* set dac offset */
- printf("Configure dac\n");
ret = mso_dac_out(sdi, devc->dac_offset);
if (ret != SR_OK)
return ret;
- printf("Configure threshold level\n");
ret = mso_configure_threshold_level(sdi);
if (ret != SR_OK)
return ret;
- printf("Configure trigger\n");
ret = mso_configure_trigger(sdi);
if (ret != SR_OK)
return ret;
return ret;
/* Start acquisition on the device. */
- printf("Check trigger\n");
mso_check_trigger(devc->serial, &devc->trigger_state);
ret = mso_check_trigger(devc->serial, NULL);
if (ret != SR_OK)
return ret;
- printf("Source add\n");
sr_source_add(devc->serial->fd, G_IO_IN, -1, mso_receive_data, cb_data);
- printf("Create packet\n");
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
sr_err("Datafeed packet malloc failed.");
return SR_ERR_MALLOC;
return SR_ERR_MALLOC;
}
+
packet->type = SR_DF_HEADER;
packet->payload = (unsigned char *)header;
header->feed_version = 1;
* to read the data */
if (devc->trigger_state != MSO_TRIGGER_DATAREADY) {
devc->trigger_state = in[0];
- //printf("Got %c for trigger \n", in[0]);
if (devc->trigger_state == MSO_TRIGGER_DATAREADY) {
- //printf("Trigger is ready %c\n", MSO_TRIGGER_DATAREADY);
mso_read_buffer(sdi);
devc->buffer_n = 0;
} else {
if (devc->buffer_n < 3072)
return TRUE;
- printf("Got samples, write out the data\n");
/* do the conversion */
uint8_t logic_out[1024];
double analog_out[1024];
logic.length = 1024;
logic.unitsize = 1;
logic.data = logic_out;
- printf("Send Data\n");
sr_session_send(cb_data, &packet);
+ devc->num_samples += 1024;
+
// Dont bother fixing this yet, keep it "old style"
/*
packet.type = SR_DF_ANALOG;
sr_session_send(ctx->session_dev_id, &packet);
*/
- //printf("Send END\n");
- //packet.type = SR_DF_END;
- //sr_session_send(devc->session_dev_id, &packet);
-
- // serial_flush(devc->serial);
- // abort_acquisition(sdi);
- // serial_close(devc->serial);
+ if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
+ sr_info("Requested number of samples reached.");
+ sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ }
- return FALSE;
- printf("REturn \n");
return TRUE;
}