From b75a3a17c2bb7ce46af4815ae588e263dbab944e Mon Sep 17 00:00:00 2001 From: Justin Fichtner <Justin.Fichtner@lakeshore.com> Date: 周二, 15 8月 2017 00:20:06 +0800 Subject: [PATCH] Fix another bug in tests --- libscpi/src/ieee488.c | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c index cd527e3..f2579a0 100644 --- a/libscpi/src/ieee488.c +++ b/libscpi/src/ieee488.c @@ -51,6 +51,17 @@ } /** +* Update latching event register value based on bit transitions from 0 -> 1 +* in the condition register +* @param context +* @param condReg - condition register name +* @param eventReg - event register name +*/ +static void regUpdateEvent(scpi_t * context, scpi_reg_val_t oldCondVal, scpi_reg_val_t newCondVal, scpi_reg_name_t eventReg) { + SCPI_RegSet(context, eventReg, ((oldCondVal ^ newCondVal) & newCondVal) | SCPI_RegGet(context, eventReg)); +} + +/** * Update STB register according to value and its mask register * @param context * @param val value of register @@ -71,7 +82,7 @@ * @return register value */ scpi_reg_val_t SCPI_RegGet(scpi_t * context, scpi_reg_name_t name) { - if ((name < SCPI_REG_COUNT) && (context->registers != NULL)) { + if ((name < SCPI_REG_COUNT) && context) { return context->registers[name]; } else { return 0; @@ -102,7 +113,7 @@ scpi_reg_val_t mask; scpi_reg_val_t old_val; - if ((name >= SCPI_REG_COUNT) || (context->registers == NULL)) { + if ((name >= SCPI_REG_COUNT) || (context == NULL)) { return; } @@ -147,6 +158,9 @@ break; case SCPI_REG_OPERE: regUpdate(context, SCPI_REG_OPER); + break; + case SCPI_REG_OPERC: + regUpdateEvent(context, old_val, val, SCPI_REG_OPER); break; @@ -213,8 +227,9 @@ int32_t new_ESE; if (SCPI_ParamInt32(context, &new_ESE, TRUE)) { SCPI_RegSet(context, SCPI_REG_ESE, (scpi_reg_val_t) new_ESE); + return SCPI_RES_OK; } - return SCPI_RES_OK; + return SCPI_RES_ERR; } /** @@ -303,8 +318,9 @@ int32_t new_SRE; if (SCPI_ParamInt32(context, &new_SRE, TRUE)) { SCPI_RegSet(context, SCPI_REG_SRE, (scpi_reg_val_t) new_SRE); + return SCPI_RES_OK; } - return SCPI_RES_OK; + return SCPI_RES_ERR; } /** -- Gitblit v1.9.1