From 3a4f333781a481b70fcd598bcc5a93ed9c5a619b Mon Sep 17 00:00:00 2001 From: Justin Fichtner <justin.fichtner@lakeshore.com> Date: ćšć, 30 11æ 2017 22:26:30 +0800 Subject: [PATCH] Fix typos in tests --- libscpi/src/ieee488.c | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-) diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c index cd527e3..4e1be81 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; } @@ -142,11 +153,17 @@ case SCPI_REG_QUESE: regUpdate(context, SCPI_REG_QUES); break; + case SCPI_REG_QUESC: + regUpdateEvent(context, old_val, val, SCPI_REG_QUES); + break; case SCPI_REG_OPER: regUpdateSTB(context, val, SCPI_REG_OPERE, STB_OPS); 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 +230,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 +321,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