* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/** @file
+ * Norma DM9x0/Siemens B102x DMMs driver.
+ * @internal
+ */
+
#include "protocol.h"
static const int32_t hwopts[] = {
snprintf(req, sizeof(req), "%s\r\n",
nmadmm_requests[NMADMM_REQ_IDN].req_str);
+ g_usleep(150 * 1000); /* Wait a little to allow serial port to settle. */
for (cnt = 0; cnt < 7; cnt++) {
if (serial_write(serial, req, strlen(req)) == -1) {
sr_err("Unable to send identification request: %d %s.",
return NULL;
}
len = BUF_MAX;
- serial_readline(serial, &buf, &len, 1500);
+ serial_readline(serial, &buf, &len, NMADMM_TIMEOUT_MS);
if (!len)
continue;
buf[BUF_MAX - 1] = '\0';
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/** @file
+ * Norma DM9x0/Siemens B102x DMMs driver.
+ * @internal
+ */
+
#include "protocol.h"
SR_PRIV const struct nmadmm_req nmadmm_requests[] = {
return SR_ERR;
}
+ devc->req_sent_at = g_get_monotonic_time();
+
return SR_OK;
}
}
/* Request next package. */
- if (!terminating && !devc->last_req_pending) {
- if (nma_send_req(sdi, NMADMM_REQ_STATUS, NULL) != SR_OK)
- return FALSE;
+ if (!terminating) {
+ if (devc->last_req_pending) {
+ gint64 elapsed_us = g_get_monotonic_time() - devc->req_sent_at;
+ if (elapsed_us > NMADMM_TIMEOUT_MS * 1000) {/* Timeout! */
+ sr_spew("Request timeout!");
+ devc->last_req_pending = FALSE;
+ }
+ }
+ if (!devc->last_req_pending) {
+ if (nma_send_req(sdi, NMADMM_REQ_STATUS, NULL) != SR_OK)
+ return FALSE;
+ }
}
return TRUE;
#include "libsigrok.h"
#include "libsigrok-internal.h"
+/** @file
+ * Norma DM9x0/Siemens B102x DMMs driver.
+ * @internal
+ */
+
#define LOG_PREFIX "norma-dmm"
#define NMADMM_BUFSIZE 256
+#define NMADMM_TIMEOUT_MS 2000 /**< Request timeout. */
+
/** Norma DMM request types (used ones only, the DMMs support about 50). */
enum {
NMADMM_REQ_IDN = 0, /**< Request identity */
/* Operational state */
int last_req; /**< Last request. */
+ int64_t req_sent_at; /**< Request sent. */
gboolean last_req_pending; /**< Last request not answered yet. */
int lowbatt; /**< Low battery. 1=low, 2=critical. */