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 | 35 ++++++++++++++++++++++++----------- 1 files changed, 24 insertions(+), 11 deletions(-) diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c index e3f4629..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; } @@ -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; } @@ -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; } -- Gitblit v1.9.1