give_device_time_to_process(devc);
msg[20] = 0;
- switch(devc->target){
+ switch (devc->target) {
case KAXXXXP_CURRENT:
case KAXXXXP_VOLTAGE:
case KAXXXXP_STATUS:
give_device_time_to_process(devc);
- switch(devc->target){
+ switch (devc->target) {
case KAXXXXP_CURRENT:
/* Read current from device. */
ret = korad_kaxxxxp_send_cmd(serial, "IOUT1?");
struct dev_context *devc)
{
double value;
- int count, ret, i;
+ int count, ret;
float *target;
char status_byte;
devc->reply[count] = 0;
if (target) {
- /* Handle the strange 'M'. */
- if (devc->reply[0] == 'M') {
- for (i = 1; i < count; i++)
- devc->reply[i - 1] = devc->reply[i];
- /* Get the last character. */
- if ((i = korad_kaxxxxp_read_chars(serial, 1,
- &(devc->reply[count]))) < 0)
- return i;
- }
value = g_ascii_strtod(devc->reply, NULL);
*target = (float)value;
sr_dbg("value: %f",value);
(status_byte & (1 << 6)) ? "enabled" : "disabled",
(status_byte & (1 << 7)) ? "true" : "false");
}
-
+ /* Read the sixth byte from ISET? BUG workaround. */
+ if (devc->target == KAXXXXP_CURRENT_MAX)
+ serial_read_blocking(serial, &status_byte, 1, 10);
devc->reply_pending = FALSE;
return ret;
struct sr_serial_dev_inst *serial;
struct sr_datafeed_packet packet;
struct sr_datafeed_analog_old analog;
- int64_t t, elapsed_us;
+ uint64_t elapsed_us;
(void)fd;
analog.mqflags = SR_MQFLAG_DC;
analog.data = &devc->voltage;
sr_session_send(sdi, &packet);
- devc->num_samples++;
+ sr_sw_limits_update_samples_read(&devc->limits, 1);
}
next_measurement(devc);
} else {
}
}
- 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);
+ if (sr_sw_limits_check(&devc->limits)) {
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
- if (devc->limit_msec) {
- t = (g_get_monotonic_time() - devc->starttime) / 1000;
- if (t > (int64_t)devc->limit_msec) {
- sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
- return TRUE;
- }
- }
-
/* Request next packet, if required. */
if (sdi->status == SR_ST_ACTIVE) {
if (devc->reply_pending) {