+ if (devc->acquisition_running) {
+ end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
+ if (!g_cond_wait_until(&devc->current_limit_cond,
+ &devc->acquisition_mutex, end_time)) {
+ /* Timeout has passed. */
+ g_mutex_unlock(&devc->acquisition_mutex);
+ return SR_ERR;
+ }
+ } else {
+ /* Hardware sends current limit in mA, integer (0..6000). */
+ devc->current_limit = g_ascii_strtod(buf + 4, NULL) / 1000;
+ }
+ g_mutex_unlock(&devc->acquisition_mutex);
+
+ if (current_limit)
+ *current_limit = devc->current_limit;
+
+ return SR_OK;
+}
+
+SR_PRIV int reloadpro_get_under_voltage_threshold(const struct sr_dev_inst *sdi,
+ float *uvc_threshold)
+{
+ struct dev_context *devc;
+ int ret;
+ char buf[100];
+ gint64 end_time;
+
+ devc = sdi->priv;
+
+ g_mutex_lock(&devc->acquisition_mutex);
+ if ((ret = send_cmd(sdi, "uvlo\n", (char *)&buf, sizeof(buf))) < 0) {
+ sr_err("Error sending under voltage threshold query: %d.", ret);
+ return SR_ERR;
+ }
+
+ if (devc->acquisition_running) {
+ end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
+ if (!g_cond_wait_until(&devc->uvc_threshold_cond,
+ &devc->acquisition_mutex, end_time)) {
+ /* Timeout has passed. */
+ g_mutex_unlock(&devc->acquisition_mutex);
+ return SR_ERR;
+ }
+ } else {
+ /* Hardware sends voltage in mV, integer (0..60000). */
+ devc->uvc_threshold = g_ascii_strtod(buf + 5, NULL) / 1000;
+ }
+ g_mutex_unlock(&devc->acquisition_mutex);
+
+ if (uvc_threshold)
+ *uvc_threshold = devc->uvc_threshold;