https://github.com/j123b567/scpi-parser
Dependents: scpi_sx127x scpi_sx127x_firstTest MLX90418_I2C_master
minimal.c
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_minimal.c 00030 * @date Thu Nov 15 10:58:45 UTC 2012 00031 * 00032 * @brief SCPI minimal implementation 00033 * 00034 * 00035 */ 00036 00037 00038 #include "scpi/parser.h" 00039 #include "scpi/minimal.h" 00040 #include "scpi/constants.h" 00041 #include "scpi/error.h" 00042 #include "scpi/ieee488.h" 00043 00044 /** 00045 * Command stub function 00046 * @param context 00047 * @return 00048 */ 00049 scpi_result_t SCPI_Stub(scpi_t * context) { 00050 (void) context; 00051 return SCPI_RES_OK; 00052 } 00053 00054 /** 00055 * Query command stub function 00056 * @param context 00057 * @return 00058 */ 00059 scpi_result_t SCPI_StubQ(scpi_t * context) { 00060 SCPI_ResultInt(context, 0); 00061 return SCPI_RES_OK; 00062 } 00063 00064 /** 00065 * SYSTem:VERSion? 00066 * @param context 00067 * @return 00068 */ 00069 scpi_result_t SCPI_SystemVersionQ(scpi_t * context) { 00070 SCPI_ResultMnemonic(context, SCPI_STD_VERSION_REVISION); 00071 return SCPI_RES_OK; 00072 } 00073 00074 /** 00075 * SYSTem:ERRor[:NEXT]? 00076 * @param context 00077 * @return 00078 */ 00079 scpi_result_t SCPI_SystemErrorNextQ(scpi_t * context) { 00080 int16_t err = SCPI_ErrorPop(context); 00081 00082 SCPI_ResultInt(context, err); 00083 SCPI_ResultText(context, SCPI_ErrorTranslate(err)); 00084 00085 return SCPI_RES_OK; 00086 } 00087 00088 /** 00089 * SYSTem:ERRor:COUNt? 00090 * @param context 00091 * @return 00092 */ 00093 scpi_result_t SCPI_SystemErrorCountQ(scpi_t * context) { 00094 SCPI_ResultInt(context, SCPI_ErrorCount(context)); 00095 00096 return SCPI_RES_OK; 00097 } 00098 00099 /** 00100 * STATus:QUEStionable[:EVENt]? 00101 * @param context 00102 * @return 00103 */ 00104 scpi_result_t SCPI_StatusQuestionableEventQ(scpi_t * context) { 00105 /* return value */ 00106 SCPI_ResultInt(context, SCPI_RegGet(context, SCPI_REG_QUES)); 00107 00108 /* clear register */ 00109 SCPI_RegSet(context, SCPI_REG_QUES, 0); 00110 00111 return SCPI_RES_OK; 00112 } 00113 00114 /** 00115 * STATus:QUEStionable:ENABle? 00116 * @param context 00117 * @return 00118 */ 00119 scpi_result_t SCPI_StatusQuestionableEnableQ(scpi_t * context) { 00120 /* return value */ 00121 SCPI_ResultInt(context, SCPI_RegGet(context, SCPI_REG_QUESE)); 00122 00123 return SCPI_RES_OK; 00124 } 00125 00126 /** 00127 * STATus:QUEStionable:ENABle 00128 * @param context 00129 * @return 00130 */ 00131 scpi_result_t SCPI_StatusQuestionableEnable(scpi_t * context) { 00132 int32_t new_QUESE; 00133 if (SCPI_ParamInt(context, &new_QUESE, TRUE)) { 00134 SCPI_RegSet(context, SCPI_REG_QUESE, (scpi_reg_val_t)new_QUESE); 00135 } 00136 return SCPI_RES_OK; 00137 } 00138 00139 /** 00140 * STATus:PRESet 00141 * @param context 00142 * @return 00143 */ 00144 scpi_result_t SCPI_StatusPreset(scpi_t * context) { 00145 /* clear STATUS:... */ 00146 SCPI_RegSet(context, SCPI_REG_QUES, 0); 00147 return SCPI_RES_OK; 00148 }
Generated on Tue Jul 12 2022 19:30:15 by 1.7.2