Format and trailing space cleanup
| | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | |
| | | static scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) { |
| | | scpi_number_t param1, param2; |
| | | char bf[15]; |
| | |
| | | {"EXTernal", 7}, |
| | | SCPI_CHOICE_LIST_END /* termination of option list */ |
| | | }; |
| | | |
| | | |
| | | static scpi_result_t TEST_ChoiceQ(scpi_t * context) { |
| | | |
| | |
| | | |
| | | scpi_t scpi_context = { |
| | | .cmdlist = scpi_commands, |
| | | .buffer = { |
| | | .buffer = |
| | | { |
| | | .length = SCPI_INPUT_BUFFER_LENGTH, |
| | | .data = scpi_input_buffer, |
| | | }, |
| | | .interface = &scpi_interface, |
| | | .registers = scpi_regs, |
| | | .units = scpi_units_def, |
| | | .idn = {"MANUFACTURE", "INSTR2013", NULL, "01-02"}, |
| | | .idn = |
| | | {"MANUFACTURE", "INSTR2013", NULL, "01-02"}, |
| | | }; |
| | | |
| | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | |
| | | scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) { |
| | | scpi_number_t param1, param2; |
| | | char bf[15]; |
| | |
| | | {"EXTernal", 7}, |
| | | SCPI_CHOICE_LIST_END /* termination of option list */ |
| | | }; |
| | | |
| | | |
| | | scpi_result_t TEST_ChoiceQ(scpi_t * context) { |
| | | |
| | |
| | | |
| | | scpi_t scpi_context = { |
| | | /* cmdlist */ scpi_commands, |
| | | /* buffer */ { /* length */ SCPI_INPUT_BUFFER_LENGTH, /* position */ 0, /* data */ scpi_input_buffer}, |
| | | /* param_list */ { /* cmd */ NULL, /* lex_state */ {NULL, NULL, 0}, /* cmd_raw */ {0, 0, NULL}}, |
| | | /* buffer */ |
| | | { /* length */ SCPI_INPUT_BUFFER_LENGTH, /* position */ 0, /* data */ scpi_input_buffer}, |
| | | /* param_list */ |
| | | { /* cmd */ NULL, /* lex_state */ |
| | | {NULL, NULL, 0}, /* cmd_raw */ |
| | | {0, 0, NULL}}, |
| | | /* interface */ &scpi_interface, |
| | | /* output_count */ 0, |
| | | /* input_count */ 0, |
| | |
| | | /* registers */ scpi_regs, |
| | | /* units */ scpi_units_def, |
| | | /* user_context */ NULL, |
| | | /* parser_state */ { /* programHeader */ {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* programData */ {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* numberOfParameters */ 0, /* termination */ SCPI_MESSAGE_TERMINATION_NONE}, |
| | | /* idn */ {"MANUFACTURE", "INSTR2013", NULL, "01-02"}, |
| | | /* parser_state */ |
| | | { /* programHeader */ |
| | | {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* programData */ |
| | | {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* numberOfParameters */ 0, /* termination */ SCPI_MESSAGE_TERMINATION_NONE |
| | | }, |
| | | /* idn */ |
| | | {"MANUFACTURE", "INSTR2013", NULL, "01-02"}, |
| | | }; |
| | | |
| | |
| | | |
| | | /* helper function to remove <LF> and <CR> from the end of a string */ |
| | | /* this is needed only here for the GUI, there is a 'insert line to a text box' function */ |
| | | |
| | | /* that automatically adds a new line, so this prohibits double line feeds for the GUI */ |
| | | void removeTrailingEndcodes(char *buf) |
| | | { |
| | | void removeTrailingEndcodes(char *buf) { |
| | | int len; |
| | | len = strlen(buf); |
| | | |
| | | while(len > 0) |
| | | { |
| | | while (len > 0) { |
| | | len--; |
| | | switch(buf[len]) |
| | | { |
| | | switch (buf[len]) { |
| | | case '\n' : |
| | | case '\r' : |
| | | buf[len] = '\0'; |
| | |
| | | } |
| | | |
| | | /* wrapper for debugging output, collects debug output until a <LF> */ |
| | | |
| | | /* is received, then removes the <LF> and outputs the line on the GUI */ |
| | | void debug_output(char *buf) |
| | | { |
| | | void debug_output(char *buf) { |
| | | static char pbuf[512]; |
| | | static int pos = 0; |
| | | int len; |
| | | |
| | | len = strlen(buf); |
| | | if(buf[len-1] == '\n') |
| | | { |
| | | if (buf[len - 1] == '\n') { |
| | | buf[len-1] == '\0'; |
| | | len--; |
| | | memcpy(&pbuf[pos], buf, len); |
| | | pos = 0; |
| | | InsertTextBoxLine (panelHandle, PANEL_OUTPUTDEBUG, -1, pbuf); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | memcpy(&pbuf[pos], buf, len); |
| | | pos += len; |
| | | } |
| | | |
| | | } |
| | | |
| | | size_t SCPI_Write(scpi_t * context, const char * data, size_t len) |
| | | { |
| | | if((SCPI_outputBuffer_idx + len) > (SCPI_OUPUT_BUFFER_SIZE-1)) |
| | | { |
| | | size_t SCPI_Write(scpi_t * context, const char * data, size_t len) { |
| | | if ((SCPI_outputBuffer_idx + len) > (SCPI_OUPUT_BUFFER_SIZE - 1)) { |
| | | len = (SCPI_OUPUT_BUFFER_SIZE-1) - SCPI_outputBuffer_idx; // limit length to left over space |
| | | // apparently there is no mechanism to cope with buffers that are too small |
| | | } |
| | |
| | | return len; |
| | | } |
| | | |
| | | scpi_result_t SCPI_Flush(scpi_t * context) |
| | | { |
| | | scpi_result_t SCPI_Flush(scpi_t * context) { |
| | | // fwrite(SCPI_outputBuffer, 1, SCPI_outputBuffer_idx, stdout); |
| | | removeTrailingEndcodes(SCPI_outputBuffer); |
| | | InsertTextBoxLine (panelHandle, PANEL_OUTPUT, -1, SCPI_outputBuffer); |
| | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | int SCPI_Error(scpi_t * context, int_fast16_t err) |
| | | { |
| | | int SCPI_Error(scpi_t * context, int_fast16_t err) { |
| | | char buf[512]; |
| | | |
| | | // fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int16_t) err, SCPI_ErrorTranslate(err)); |
| | |
| | | return SCPI_RES_ERR; |
| | | } |
| | | |
| | | |
| | | /* |
| | | * |
| | | */ |
| | | int main(int argc, char** argv) |
| | | { |
| | | int main(int argc, char** argv) { |
| | | int result; |
| | | |
| | | SCPI_Init(&scpi_context); |
| | |
| | | return (EXIT_SUCCESS); |
| | | } |
| | | |
| | | |
| | | void updateSSCPIRegister(void) |
| | | { |
| | | void updateSSCPIRegister(void) { |
| | | updateSTB(); |
| | | updateSRE(); |
| | | updateESR(); |
| | | updateESE(); |
| | | } |
| | | |
| | | void updateSTB(void) |
| | | { |
| | | void updateSTB(void) { |
| | | scpi_reg_val_t regVal; |
| | | |
| | | regVal = SCPI_RegGet(&scpi_context, SCPI_REG_STB); |
| | |
| | | gui_updateSTB((uint8_t)(0x00FF & regVal)); |
| | | } |
| | | |
| | | void updateESR(void) |
| | | { |
| | | void updateESR(void) { |
| | | scpi_reg_val_t regVal; |
| | | |
| | | regVal = SCPI_RegGet(&scpi_context, SCPI_REG_ESR); |
| | |
| | | gui_updateESR((uint8_t)(0x00FF & regVal)); |
| | | } |
| | | |
| | | void updateESE(void) |
| | | { |
| | | void updateESE(void) { |
| | | scpi_reg_val_t regVal; |
| | | |
| | | regVal = SCPI_RegGet(&scpi_context, SCPI_REG_ESE); |
| | |
| | | gui_updateESE((uint8_t)(0x00FF & regVal)); |
| | | } |
| | | |
| | | void updateSRE(void) |
| | | { |
| | | void updateSRE(void) { |
| | | scpi_reg_val_t regVal; |
| | | |
| | | regVal = SCPI_RegGet(&scpi_context, SCPI_REG_SRE); |
| | |
| | | gui_updateSRE((uint8_t)(0x00FF & regVal)); |
| | | } |
| | | |
| | | |
| | | /* |
| | | * The CALLBACK functions below are called from the CVI runtime engine when |
| | | * user clicks on buttons, inputs data on the GUI etc. |
| | | */ |
| | | int CVICALLBACK cb_scpi_input (int panel, int control, int event, |
| | | void *callbackData, int eventData1, int eventData2) |
| | | { |
| | | void *callbackData, int eventData1, int eventData2) { |
| | | char buf[256]; |
| | | int len; |
| | | |
| | | switch (event) |
| | | { |
| | | switch (event) { |
| | | case EVENT_COMMIT: |
| | | GetCtrlVal(panel, control, buf); |
| | | /* we have to add a endcode to make SCPI accept the string, here a <LF> is added */ |
| | |
| | | } |
| | | |
| | | int CVICALLBACK cb_quit (int panel, int control, int event, |
| | | void *callbackData, int eventData1, int eventData2) |
| | | { |
| | | switch (event) |
| | | { |
| | | void *callbackData, int eventData1, int eventData2) { |
| | | switch (event) { |
| | | case EVENT_COMMIT: |
| | | QuitUserInterface (0); |
| | | break; |
| | |
| | | /* |
| | | * Helper functions for GUI |
| | | */ |
| | | void gui_updateSTB(uint8_t newSTB) |
| | | { |
| | | void gui_updateSTB(uint8_t newSTB) { |
| | | char buf[5]; |
| | | |
| | | sprintf(buf, "0x%02X", newSTB); |
| | |
| | | |
| | | } |
| | | |
| | | void gui_updateESR(uint8_t newESR) |
| | | { |
| | | void gui_updateESR(uint8_t newESR) { |
| | | char buf[5]; |
| | | |
| | | sprintf(buf, "0x%02X", newESR); |
| | |
| | | SetCtrlVal(panelHandle, PANEL_ESR7, (newESR & 0x80)); |
| | | } |
| | | |
| | | void gui_updateESE(uint8_t newESE) |
| | | { |
| | | void gui_updateESE(uint8_t newESE) { |
| | | char buf[5]; |
| | | |
| | | sprintf(buf, "0x%02X", newESE); |
| | |
| | | SetCtrlVal(panelHandle, PANEL_ESE7, (newESE & 0x80)); |
| | | } |
| | | |
| | | void gui_updateSRE(uint8_t newSRE) |
| | | { |
| | | void gui_updateSRE(uint8_t newSRE) { |
| | | char buf[5]; |
| | | |
| | | sprintf(buf, "0x%02X", newSRE); |
| | |
| | | //fd_set fds; |
| | | } user_data_t; |
| | | |
| | | struct _queue_event_t |
| | | { |
| | | struct _queue_event_t { |
| | | uint8_t cmd; |
| | | uint8_t param1; |
| | | int16_t param2; |
| | |
| | | SCPI_ResultInt(context, CONTROL_PORT); |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | |
| | | static void setEseReq(void) { |
| | | SCPI_RegSetBits(&scpi_context, SCPI_REG_ESR, ESR_REQ); |
| | |
| | | scpi_result_t SCPI_SystemCommTcpipControlQ(scpi_t * context) { |
| | | return SCPI_RES_ERR; |
| | | } |
| | | |
| | | /* |
| | | * |
| | | */ |
| | |
| | | |
| | | #define CONTROL_PORT 5026 |
| | | |
| | | |
| | | |
| | | typedef struct { |
| | | int io; |
| | | int io_listen; |
| | |
| | | fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int16_t) err, SCPI_ErrorTranslate(err)); |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | scpi_result_t SCPI_Control(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) { |
| | | char b[16]; |
| | |
| | | |
| | | /* Create socket */ |
| | | fd = socket(AF_INET,SOCK_STREAM, 0); |
| | | if (fd < 0) |
| | | { |
| | | if (fd < 0) { |
| | | perror("socket() failed"); |
| | | exit(-1); |
| | | } |
| | | |
| | | /* Set address reuse enable */ |
| | | rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)); |
| | | if (rc < 0) |
| | | { |
| | | if (rc < 0) { |
| | | perror("setsockopt() failed"); |
| | | close(fd); |
| | | exit(-1); |
| | |
| | | |
| | | /* Set non blocking */ |
| | | rc = ioctl(fd, FIONBIO, (char *)&on); |
| | | if (rc < 0) |
| | | { |
| | | if (rc < 0) { |
| | | perror("ioctl() failed"); |
| | | close(fd); |
| | | exit(-1); |
| | |
| | | |
| | | /* Bind to socket */ |
| | | rc = bind(fd, (struct sockaddr *)&servaddr, sizeof(servaddr)); |
| | | if (rc < 0) |
| | | { |
| | | if (rc < 0) { |
| | | perror("bind() failed"); |
| | | close(fd); |
| | | exit(-1); |
| | |
| | | |
| | | /* Listen on socket */ |
| | | listen(fd, 1); |
| | | if (rc < 0) |
| | | { |
| | | if (rc < 0) { |
| | | perror("listen() failed"); |
| | | close(fd); |
| | | exit(-1); |
| | |
| | | |
| | | return rc; |
| | | } |
| | | |
| | | |
| | | static int processIoListen(user_data_t * user_data) { |
| | | struct sockaddr_in cliaddr; |
| | |
| | | |
| | | /* Create socket */ |
| | | fd = socket(AF_INET,SOCK_STREAM, 0); |
| | | if (fd < 0) |
| | | { |
| | | if (fd < 0) { |
| | | perror("socket() failed"); |
| | | exit(-1); |
| | | } |
| | | |
| | | /* Set address reuse enable */ |
| | | rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)); |
| | | if (rc < 0) |
| | | { |
| | | if (rc < 0) { |
| | | perror("setsockopt() failed"); |
| | | close(fd); |
| | | exit(-1); |
| | |
| | | |
| | | /* Set non blocking */ |
| | | rc = ioctl(fd, FIONBIO, (char *)&on); |
| | | if (rc < 0) |
| | | { |
| | | if (rc < 0) { |
| | | perror("ioctl() failed"); |
| | | close(fd); |
| | | exit(-1); |
| | |
| | | |
| | | /* Bind to socket */ |
| | | rc = bind(fd, (struct sockaddr *)&servaddr, sizeof(servaddr)); |
| | | if (rc < 0) |
| | | { |
| | | if (rc < 0) { |
| | | perror("bind() failed"); |
| | | close(fd); |
| | | exit(-1); |
| | |
| | | |
| | | /* Listen on socket */ |
| | | listen(fd, 1); |
| | | if (rc < 0) |
| | | { |
| | | if (rc < 0) { |
| | | perror("listen() failed"); |
| | | close(fd); |
| | | exit(-1); |
| | |
| | | XE(SCPI_ERROR_REQUEST_CONTROL, -700, "Request control") \ |
| | | XE(SCPI_ERROR_OPERATION_COMPLETE, -800, "Operation complete") \ |
| | | |
| | | |
| | | enum { |
| | | #define X(def, val, str) def = val, |
| | | #if USE_FULL_ERROR_LIST |
| | |
| | | int SCPI_Input(scpi_t * context, const char * data, int len); |
| | | int SCPI_Parse(scpi_t * context, char * data, int len); |
| | | |
| | | |
| | | size_t SCPI_ResultCharacters(scpi_t * context, const char * data, size_t len); |
| | | #define SCPI_ResultMnemonic(context, data) SCPI_ResultCharacters((context), (data), strlen(data)) |
| | | size_t SCPI_ResultUInt32Base(scpi_t * context, uint32_t val, int8_t base); |
| | |
| | | size_t SCPI_ResultText(scpi_t * context, const char * data); |
| | | size_t SCPI_ResultArbitraryBlock(scpi_t * context, const char * data, size_t len); |
| | | size_t SCPI_ResultBool(scpi_t * context, scpi_bool_t val); |
| | | |
| | | |
| | | scpi_bool_t SCPI_Parameter(scpi_t * context, scpi_parameter_t * parameter, scpi_bool_t mandatory); |
| | | scpi_bool_t SCPI_ParamIsValid(scpi_parameter_t * parameter); |
| | |
| | | scpi_bool_t SCPI_ParamToDouble(scpi_t * context, scpi_parameter_t * parameter, double * value); |
| | | scpi_bool_t SCPI_ParamToChoice(scpi_t * context, scpi_parameter_t * parameter, const scpi_choice_def_t * options, int32_t * value); |
| | | scpi_bool_t SCPI_ChoiceToName(const scpi_choice_def_t * options, int32_t tag, const char ** text); |
| | | |
| | | |
| | | scpi_bool_t SCPI_ParamInt32(scpi_t * context, int32_t * value, scpi_bool_t mandatory); |
| | | scpi_bool_t SCPI_ParamUInt32(scpi_t * context, uint32_t * value, scpi_bool_t mandatory); |
| | |
| | | int32_t SCPI_CmdTag(scpi_t * context); |
| | | scpi_bool_t SCPI_Match(const char * pattern, const char * value, size_t len); |
| | | scpi_bool_t SCPI_CommandNumbers(scpi_t * context, int32_t * numbers, size_t len, int32_t default_value); |
| | | |
| | | |
| | | // deprecated finction, should be removed later |
| | | #define SCPI_ResultIntBase(context, val, base) SCPI_ResultInt32Base ((context), (val), (base), TRUE) |
| | |
| | | #include "scpi/utils.h" |
| | | #include "scpi/expression.h" |
| | | |
| | | |
| | | #endif /* SCPI_H */ |
| | | |
| | |
| | | |
| | | struct _scpi_number_parameter_t { |
| | | scpi_bool_t special; |
| | | |
| | | union { |
| | | double value; |
| | | int32_t tag; |
| | |
| | | /* basic FIFO */ |
| | | static scpi_fifo_t local_error_queue; |
| | | |
| | | |
| | | /** |
| | | * Initialize error queue |
| | | * @param context - scpi context |
| | |
| | | * SCPI_EXPR_ERROR - parser error |
| | | * SCPI_EXPR_NO_MORE - no more data |
| | | */ |
| | | static scpi_expr_result_t numericRange(lex_state_t * state, scpi_bool_t * isRange, scpi_token_t * valueFrom, scpi_token_t * valueTo) |
| | | { |
| | | static scpi_expr_result_t numericRange(lex_state_t * state, scpi_bool_t * isRange, scpi_token_t * valueFrom, scpi_token_t * valueTo) { |
| | | if (scpiLex_DecimalNumericProgramData(state, valueFrom)) { |
| | | if (scpiLex_Colon(state, valueTo)) { |
| | | *isRange = TRUE; |
| | |
| | | * SCPI_EXPR_NO_MORE - no more data |
| | | * @see SCPI_ExprNumericListEntryInt, SCPI_ExprNumericListEntryDouble |
| | | */ |
| | | scpi_expr_result_t SCPI_ExprNumericListEntry(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, scpi_parameter_t * valueFrom, scpi_parameter_t * valueTo) |
| | | { |
| | | scpi_expr_result_t SCPI_ExprNumericListEntry(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, scpi_parameter_t * valueFrom, scpi_parameter_t * valueTo) { |
| | | lex_state_t lex; |
| | | int i; |
| | | scpi_expr_result_t res = SCPI_EXPR_OK; |
| | |
| | | * SCPI_EXPR_NO_MORE - no more data |
| | | * @see SCPI_ExprNumericListEntry, SCPI_ExprNumericListEntryDouble |
| | | */ |
| | | scpi_expr_result_t SCPI_ExprNumericListEntryInt(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, int32_t * valueFrom, int32_t * valueTo) |
| | | { |
| | | scpi_expr_result_t SCPI_ExprNumericListEntryInt(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, int32_t * valueFrom, int32_t * valueTo) { |
| | | scpi_expr_result_t res; |
| | | scpi_bool_t range = FALSE; |
| | | scpi_parameter_t paramFrom; |
| | |
| | | * SCPI_EXPR_NO_MORE - no more data |
| | | * @see SCPI_ExprNumericListEntry, SCPI_ExprNumericListEntryInt |
| | | */ |
| | | scpi_expr_result_t SCPI_ExprNumericListEntryDouble(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, double * valueFrom, double * valueTo) |
| | | { |
| | | scpi_expr_result_t SCPI_ExprNumericListEntryDouble(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, double * valueFrom, double * valueTo) { |
| | | scpi_expr_result_t res; |
| | | scpi_bool_t range = FALSE; |
| | | scpi_parameter_t paramFrom; |
| | |
| | | * @param length length of values array |
| | | * @param dimensions real number of dimensions |
| | | */ |
| | | static scpi_expr_result_t channelSpec(scpi_t * context, lex_state_t * state, int32_t * values, size_t length, size_t * dimensions) |
| | | { |
| | | static scpi_expr_result_t channelSpec(scpi_t * context, lex_state_t * state, int32_t * values, size_t length, size_t * dimensions) { |
| | | scpi_parameter_t param; |
| | | size_t i = 0; |
| | | while(scpiLex_DecimalNumericProgramData(state, ¶m)) { |
| | |
| | | * @param length length of values arrays |
| | | * @param dimensions real number of dimensions |
| | | */ |
| | | static scpi_expr_result_t channelRange(scpi_t * context, lex_state_t * state, scpi_bool_t * isRange, int32_t * valuesFrom, int32_t * valuesTo, size_t length, size_t * dimensions) |
| | | { |
| | | static scpi_expr_result_t channelRange(scpi_t * context, lex_state_t * state, scpi_bool_t * isRange, int32_t * valuesFrom, int32_t * valuesTo, size_t length, size_t * dimensions) { |
| | | scpi_token_t token; |
| | | scpi_expr_result_t err; |
| | | size_t fromDimensions; |
| | |
| | | * @param length length of values arrays |
| | | * @param dimensions real number of dimensions |
| | | */ |
| | | scpi_expr_result_t SCPI_ExprChannelListEntry(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, int32_t * valuesFrom, int32_t * valuesTo, size_t length, size_t * dimensions) |
| | | { |
| | | scpi_expr_result_t SCPI_ExprChannelListEntry(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, int32_t * valuesFrom, int32_t * valuesTo, size_t length, size_t * dimensions) { |
| | | lex_state_t lex; |
| | | int i; |
| | | scpi_expr_result_t res = SCPI_EXPR_OK; |
| | |
| | | * @param parameter |
| | | * @return |
| | | */ |
| | | scpi_bool_t SCPI_ParamIsValid(scpi_parameter_t * parameter) |
| | | { |
| | | scpi_bool_t SCPI_ParamIsValid(scpi_parameter_t * parameter) { |
| | | return parameter->type == SCPI_TOKEN_UNKNOWN ? FALSE : TRUE; |
| | | } |
| | | |
| | |
| | | * @param context |
| | | * @return |
| | | */ |
| | | scpi_bool_t SCPI_ParamErrorOccurred(scpi_t * context) |
| | | { |
| | | scpi_bool_t SCPI_ParamErrorOccurred(scpi_t * context) { |
| | | return context->cmd_error; |
| | | } |
| | |
| | | * @param mandatory if the parameter is mandatory |
| | | * @return |
| | | */ |
| | | scpi_bool_t SCPI_ParamNumber(scpi_t * context, const scpi_choice_def_t * special, scpi_number_t * value, scpi_bool_t mandatory) |
| | | { |
| | | scpi_bool_t SCPI_ParamNumber(scpi_t * context, const scpi_choice_def_t * special, scpi_number_t * value, scpi_bool_t mandatory) { |
| | | scpi_token_t token; |
| | | lex_state_t state; |
| | | scpi_parameter_t param; |
| | |
| | | if (len != token.len) printToken(&token); \ |
| | | } while(0) |
| | | |
| | | |
| | | static void testWhiteSpace(void) { |
| | | TEST_TOKEN(" \t MEAS", scpiLex_WhiteSpace, 0, 4, SCPI_TOKEN_WS); |
| | | TEST_TOKEN("MEAS", scpiLex_WhiteSpace, 0, 0, SCPI_TOKEN_UNKNOWN); |
| | |
| | | else \ |
| | | if (len != token.len) printToken(&token); \ |
| | | } while(0) |
| | | |
| | | |
| | | static void testAllProgramData(void) { |
| | | TEST_ALL_TOKEN("1.5E12 V", scpiParser_parseAllProgramData, 0, 8, SCPI_TOKEN_ALL_PROGRAM_DATA, 1); |
| | |
| | | } |
| | | |
| | | scpi_t scpi_context; |
| | | |
| | | static void error_buffer_clear(void) { |
| | | err_buffer[0] = 0; |
| | | err_buffer_pos = 0; |
| | |
| | | err_buffer[err_buffer_pos] = err; |
| | | err_buffer_pos++; |
| | | } |
| | | |
| | | |
| | | static size_t SCPI_Write(scpi_t * context, const char * data, size_t len) { |
| | | (void) context; |
| | |
| | | } |
| | | |
| | | scpi_reg_val_t srq_val = 0; |
| | | |
| | | static scpi_result_t SCPI_Control(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) { |
| | | (void) context; |
| | | |
| | |
| | | |
| | | scpi_t scpi_context = { |
| | | .cmdlist = scpi_commands, |
| | | .buffer = { |
| | | .buffer = |
| | | { |
| | | .length = SCPI_INPUT_BUFFER_LENGTH, |
| | | .data = scpi_input_buffer, |
| | | }, |
| | | .interface = &scpi_interface, |
| | | .registers = scpi_regs, |
| | | .units = scpi_units_def, |
| | | .idn = {"MA", "IN", NULL, "VER"}, |
| | | .idn = |
| | | {"MA", "IN", NULL, "VER"}, |
| | | }; |
| | | |
| | | |
| | | static int init_suite(void) { |
| | | SCPI_Init(&scpi_context); |