https://github.com/j123b567/scpi-parser
Dependents: scpi_sx127x scpi_sx127x_firstTest MLX90418_I2C_master
parser.h
00001 /*- 00002 * Copyright (c) 2012-2013 Jan Breuer, 00003 * 00004 * All Rights Reserved 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are 00008 * met: 00009 * 1. Redistributions of source code must retain the above copyright notice, 00010 * this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 00015 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00016 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00017 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00018 * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 00019 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00020 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00021 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 00022 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00023 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00024 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 00025 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 */ 00027 00028 /** 00029 * @file scpi_parser.h 00030 * @date Thu Nov 15 10:58:45 UTC 2012 00031 * 00032 * @brief SCPI parser implementation 00033 * 00034 * 00035 */ 00036 00037 #ifndef SCPI_PARSER_H 00038 #define SCPI_PARSER_H 00039 00040 #include <string.h> 00041 #include "scpi/types.h" 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 void SCPI_Init(scpi_t * context); 00047 00048 int SCPI_Input(scpi_t * context, const char * data, int len); 00049 int SCPI_Parse(scpi_t * context, char * data, int len); 00050 00051 00052 size_t SCPI_ResultCharacters(scpi_t * context, const char * data, size_t len); 00053 #define SCPI_ResultMnemonic(context, data) SCPI_ResultCharacters((context), (data), strlen(data)) 00054 size_t SCPI_ResultInt(scpi_t * context, int32_t val); 00055 size_t SCPI_ResultIntBase(scpi_t * context, int32_t val, int8_t base); 00056 size_t SCPI_ResultDouble(scpi_t * context, double val); 00057 size_t SCPI_ResultText(scpi_t * context, const char * data); 00058 size_t SCPI_ResultArbitraryBlock(scpi_t * context, const char * data, size_t len); 00059 size_t SCPI_ResultBool(scpi_t * context, scpi_bool_t val); 00060 00061 scpi_bool_t SCPI_Parameter(scpi_t * context, scpi_parameter_t * parameter, scpi_bool_t mandatory); 00062 scpi_bool_t SCPI_ParamIsNumber(scpi_parameter_t * parameter, scpi_bool_t suffixAllowed); 00063 scpi_bool_t SCPI_ParamToInt(scpi_t * context, scpi_parameter_t * parameter, int32_t * value); 00064 scpi_bool_t SCPI_ParamToDouble(scpi_t * context, scpi_parameter_t * parameter, double * value); 00065 scpi_bool_t SCPI_ParamToChoice(scpi_t * context, scpi_parameter_t * parameter, const scpi_choice_def_t * options, int32_t * value); 00066 scpi_bool_t SCPI_ChoiceToName(const scpi_choice_def_t * options, int32_t tag, const char ** text); 00067 00068 00069 scpi_bool_t SCPI_ParamInt(scpi_t * context, int32_t * value, scpi_bool_t mandatory); 00070 scpi_bool_t SCPI_ParamDouble(scpi_t * context, double * value, scpi_bool_t mandatory); 00071 scpi_bool_t SCPI_ParamCharacters(scpi_t * context, const char ** value, size_t * len, scpi_bool_t mandatory); 00072 scpi_bool_t SCPI_ParamArbitraryBlock(scpi_t * context, const char ** value, size_t * len, scpi_bool_t mandatory); 00073 scpi_bool_t SCPI_ParamCopyText(scpi_t * context, char * buffer, size_t buffer_len, size_t * copy_len, scpi_bool_t mandatory); 00074 00075 scpi_bool_t SCPI_ParamBool(scpi_t * context, scpi_bool_t * value, scpi_bool_t mandatory); 00076 scpi_bool_t SCPI_ParamChoice(scpi_t * context, const scpi_choice_def_t * options, int32_t * value, scpi_bool_t mandatory); 00077 00078 scpi_bool_t SCPI_IsCmd(scpi_t * context, const char * cmd); 00079 int32_t SCPI_CmdTag(scpi_t * context); 00080 scpi_bool_t SCPI_Match(const char * pattern, const char * value, size_t len); 00081 scpi_bool_t SCPI_CommandNumbers(scpi_t * context, int32_t * numbers, size_t len); 00082 00083 #ifdef __cplusplus 00084 } 00085 #endif 00086 00087 #endif /* SCPI_PARSER_H */
Generated on Tue Jul 12 2022 19:30:15 by 1.7.2