};
/* TODO: all of these should go in a device-specific struct */
-static uint64_t cur_sample_rate = 0;
+static uint64_t cur_samplerate = 0;
static uint64_t limit_samples = 0;
static uint8_t probe_mask = 0, \
trigger_mask[NUM_TRIGGER_STAGES] = {0}, \
trigger_value[stage] |= probe_bit;
stage++;
if(stage > NUM_TRIGGER_STAGES)
- return SIGROK_NOK;
+ return SIGROK_ERR;
}
}
}
if( !(sdi = sl_open_device(device_index)) ) {
g_warning("unable to open device");
- return SIGROK_NOK;
+ return SIGROK_ERR;
}
err = libusb_claim_interface(sdi->usb->devhdl, USB_INTERFACE);
if(err != 0) {
g_warning("Unable to claim interface: %d", err);
- return SIGROK_NOK;
+ return SIGROK_ERR;
}
- if(cur_sample_rate == 0) {
+ if(cur_samplerate == 0) {
/* sample rate hasn't been set; default to the slowest it has */
- if(hw_set_configuration(device_index, HWCAP_SAMPLERATE, &supported_samplerates[0]) == SIGROK_NOK)
- return SIGROK_NOK;
+ if(hw_set_configuration(device_index, HWCAP_SAMPLERATE, &supported_samplerates[0]) == SIGROK_ERR)
+ return SIGROK_ERR;
}
return SIGROK_OK;
case DI_TRIGGER_TYPES:
info = TRIGGER_TYPES;
break;
- case DI_CUR_SAMPLE_RATE:
- info = &cur_sample_rate;
+ case DI_CUR_SAMPLERATE:
+ info = &cur_samplerate;
break;
}
break;
}
if(supported_samplerates[i] == 0)
- return SIGROK_ERR_BADVALUE;
+ return SIGROK_ERR_SAMPLERATE;
divider = (uint8_t) (48 / (float) (samplerate/1000000)) - 1;
- g_message("setting sample rate to %"PRIu64" Hz (divider %d)", samplerate, divider);
+ g_message("setting samplerate to %"PRIu64" Hz (divider %d)", samplerate, divider);
buf[0] = 0x01;
buf[1] = divider;
ret = libusb_bulk_transfer(sdi->usb->devhdl, 1 | LIBUSB_ENDPOINT_OUT, buf, 2, &result, 500);
if(ret != 0) {
g_warning("failed to set samplerate: %d", ret);
- return SIGROK_NOK;
+ return SIGROK_ERR;
}
- cur_sample_rate = samplerate;
+ cur_samplerate = samplerate;
return SIGROK_OK;
}
uint64_t *tmp_u64;
if( !(sdi = get_sigrok_device_instance(device_instances, device_index)) )
- return SIGROK_NOK;
+ return SIGROK_ERR;
if(capability == HWCAP_SAMPLERATE) {
tmp_u64 = value;
ret = SIGROK_OK;
}
else
- ret = SIGROK_NOK;
+ ret = SIGROK_ERR;
return ret;
}
unsigned char *buf;
if( !(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_NOK;
+ return SIGROK_ERR;
packet = g_malloc(sizeof(struct datafeed_packet));
header = g_malloc(sizeof(struct datafeed_header));
if(!packet || !header)
- return SIGROK_NOK;
+ return SIGROK_ERR;
/* start with 2K transfer, subsequently increased to 4K */
size = 2048;
/* TODO: free them all */
libusb_free_transfer(transfer);
g_free(buf);
- return SIGROK_NOK;
+ return SIGROK_ERR;
}
size = 4096;
}
packet->payload = (unsigned char *) header;
header->feed_version = 1;
gettimeofday(&header->starttime, NULL);
- header->rate = cur_sample_rate;
+ header->samplerate = cur_samplerate;
header->protocol_id = PROTO_RAW;
header->num_probes = NUM_PROBES;
session_bus(session_device_id, packet);