From 7dca581454fb426dd8233a39475877dab9b3e1a6 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周日, 04 10月 2015 19:57:28 +0800 Subject: [PATCH] Add Channel list support to readme --- libscpi/src/parser.c | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) diff --git a/libscpi/src/parser.c b/libscpi/src/parser.c index c307a37..ca711eb 100644 --- a/libscpi/src/parser.c +++ b/libscpi/src/parser.c @@ -553,8 +553,9 @@ } else { return strToULong(parameter->ptr, (uint32_t *)value, 10) > 0 ? TRUE : FALSE; } + default: + return FALSE; } - return FALSE; } @@ -589,7 +590,7 @@ */ #include "stdio.h" scpi_bool_t SCPI_ParamToDouble(scpi_t * context, scpi_parameter_t * parameter, double * value) { - scpi_bool_t result = FALSE; + scpi_bool_t result; uint32_t valint; if (!value) { @@ -608,6 +609,8 @@ case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX: result = strToDouble(parameter->ptr, value) > 0 ? TRUE : FALSE; break; + default: + result = FALSE; } return result; } @@ -1093,3 +1096,24 @@ scpi_bool_t SCPI_CommandNumbers(scpi_t * context, int32_t * numbers, size_t len) { return matchCommand (context->param_list.cmd->pattern, context->param_list.cmd_raw.data, context->param_list.cmd_raw.length, numbers, len); } + +/** + * If SCPI_Parameter() returns FALSE, this function can detect, if the parameter + * is just missing (TRUE) or if there was an error during processing of the command (FALSE) + * @param parameter + * @return + */ +scpi_bool_t SCPI_ParamIsValid(scpi_parameter_t * parameter) +{ + return parameter->type == SCPI_TOKEN_UNKNOWN ? FALSE : TRUE; +} + +/** + * Returns TRUE if there was an error during parameter handling + * @param context + * @return + */ +scpi_bool_t SCPI_ParamErrorOccurred(scpi_t * context) +{ + return context->cmd_error; +} -- Gitblit v1.9.1