From be3350c620036306fb5f2db3535cb110f187d5e8 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周三, 24 9月 2014 23:46:36 +0800 Subject: [PATCH] Refactor token_t and token_type_t to have scpi_ prefix --- libscpi/src/ieee488.c | 47 ++++++++++++++++++++++++++++++----------------- 1 files changed, 30 insertions(+), 17 deletions(-) diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c index 855c9f1..c3aaf33 100644 --- a/libscpi/src/ieee488.c +++ b/libscpi/src/ieee488.c @@ -98,13 +98,16 @@ * @param val - new value */ void SCPI_RegSet(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t val) { - bool_t srq = FALSE; + scpi_bool_t srq = FALSE; scpi_reg_val_t mask; + scpi_reg_val_t old_val; if ((name >= SCPI_REG_COUNT) || (context->registers == NULL)) { return; } + /* store old register value */ + old_val = context->registers[name]; /* set register value */ context->registers[name] = val; @@ -116,7 +119,10 @@ mask &= ~STB_SRQ; if (val & mask) { val |= STB_SRQ; - srq = TRUE; + /* avoid sending SRQ if nothing has changed */ + if (old_val != val) { + srq = TRUE; + } } else { val &= ~STB_SRQ; } @@ -145,11 +151,11 @@ case SCPI_REG_COUNT: - // nothing to do + /* nothing to do */ break; } - // set updated register value + /* set updated register value */ context->registers[name] = val; if (srq) { @@ -180,7 +186,7 @@ * @param context */ void SCPI_EventClear(scpi_t * context) { - // TODO + /* TODO */ SCPI_RegSet(context, SCPI_REG_ESR, 0); } @@ -204,9 +210,9 @@ * @return */ scpi_result_t SCPI_CoreEse(scpi_t * context) { - int32_t new_ESE; - if (SCPI_ParamInt(context, &new_ESE, TRUE)) { - SCPI_RegSet(context, SCPI_REG_ESE, new_ESE); + scpi_parameter_t parameter; + if (SCPI_Parameter(context, ¶meter, TRUE)) { + SCPI_RegSet(context, SCPI_REG_ESE, SCPI_ParamGetIntVal(context, ¶meter)); } return SCPI_RES_OK; } @@ -234,13 +240,20 @@ /** * *IDN? + * + * field1: MANUFACTURE + * field2: MODEL + * field4: SUBSYSTEMS REVISIONS + * + * example: MANUFACTURE,MODEL,0,01-02-01 * @param context * @return */ scpi_result_t SCPI_CoreIdnQ(scpi_t * context) { - SCPI_ResultString(context, SCPI_MANUFACTURE); - SCPI_ResultString(context, SCPI_DEV_NAME); - SCPI_ResultString(context, SCPI_DEV_VERSION); + SCPI_ResultMnemonic(context, context->idn[0]); + SCPI_ResultMnemonic(context, context->idn[1]); + SCPI_ResultMnemonic(context, context->idn[2]); + SCPI_ResultMnemonic(context, context->idn[3]); return SCPI_RES_OK; } @@ -260,7 +273,7 @@ * @return */ scpi_result_t SCPI_CoreOpcQ(scpi_t * context) { - // Operation is always completed + /* Operation is always completed */ SCPI_ResultInt(context, 1); return SCPI_RES_OK; } @@ -283,9 +296,9 @@ * @return */ scpi_result_t SCPI_CoreSre(scpi_t * context) { - int32_t new_SRE; - if (SCPI_ParamInt(context, &new_SRE, TRUE)) { - SCPI_RegSet(context, SCPI_REG_SRE, new_SRE); + scpi_parameter_t parameter; + if (SCPI_Parameter(context, ¶meter, TRUE)) { + SCPI_RegSet(context, SCPI_REG_SRE, SCPI_ParamGetIntVal(context, ¶meter)); } return SCPI_RES_OK; } @@ -319,7 +332,7 @@ int result = 0; if (context && context->interface && context->interface->test) { result = context->interface->test(context); - } + } SCPI_ResultInt(context, result); return SCPI_RES_OK; } @@ -331,7 +344,7 @@ */ scpi_result_t SCPI_CoreWai(scpi_t * context) { (void) context; - // NOP + /* NOP */ return SCPI_RES_OK; } -- Gitblit v1.9.1