예제 #1
0
static void testErrorHandling(void) {
    output_buffer_clear();
    error_buffer_clear();

#define TEST_ERROR(data, output, err_num) {                     \
    output_buffer_clear();                                      \
    error_buffer_clear();                                       \
    SCPI_Input(&scpi_context, data, strlen(data));              \
    CU_ASSERT_STRING_EQUAL(output, output_buffer);              \
    CU_ASSERT_EQUAL(err_buffer[0], err_num)                     \
}

    TEST_ERROR("*IDN?\r\n", "MA,IN,0,VER\r\n", 0);
    TEST_ERROR("IDN?\r\n", "", SCPI_ERROR_UNDEFINED_HEADER);
    TEST_ERROR("*ESE\r\n", "", SCPI_ERROR_MISSING_PARAMETER);
    TEST_ERROR("*IDN? 12\r\n", "MA,IN,0,VER\r\n", SCPI_ERROR_PARAMETER_NOT_ALLOWED);
    TEST_ERROR("TEXT? \"PARAM1\", \"PARAM2\"\r\n", "\"PARAM2\"\r\n", 0);

    // TODO: SCPI_ERROR_INVALID_SEPARATOR
    // TODO: SCPI_ERROR_INVALID_SUFFIX
    // TODO: SCPI_ERROR_SUFFIX_NOT_ALLOWED
    // TODO: SCPI_ERROR_EXECUTION_ERROR
    // TODO: SCPI_ERROR_ILLEGAL_PARAMETER_VALUE

    output_buffer_clear();
    error_buffer_clear();
}
예제 #2
0
void TEST_COMMAND_MATCH(char *data, char* output)
{
    SCPI_Input(&scpi_context, data, strlen(data));
    SCPI_Input(&scpi_context, NULL, 0);
    printf("obuf=<%s>\n", obuf);
    CU_ASSERT_STRING_EQUAL(output, obuf);
    output_buffer_clear();
}
예제 #3
0
void test_applyq()
{
    output_buffer_clear();
    TEST_COMMAND_MATCH("sour1:appl?", "source_apply1Q\r\n");
    TEST_COMMAND_MATCH("sour:appl?", "source_apply1Q\r\n");
    TEST_COMMAND_MATCH("source:apply?", "source_apply1Q\r\n");
    TEST_COMMAND_MATCH("source2:apply?", "source_apply2Q\r\n");
    TEST_COMMAND_MATCH("SOUR2:APPL?", "source_apply2Q\r\n");
}
예제 #4
0
void test_output_load()
{
    output_buffer_clear();
    TEST_COMMAND_MATCH("outp1:load inf", "output1_load, infinite\r\n"); // test bjarni2
    TEST_COMMAND_MATCH("output2:load default", "output2_load, default\r\n");
    TEST_COMMAND_MATCH("output2:load 2.5 kohm", "output2_load, 2500 OHM\r\n");
    TEST_COMMAND_MATCH("output2:load 25 ohm", "output2_load, 25 OHM\r\n");
    TEST_COMMAND_MATCH("output2:load 25", "output2_load, 25 OHM\r\n");
}
예제 #5
0
void test_bjarni3()
{
    output_buffer_clear();
    //TEST_COMMAND_MATCH("sour1:appl:sin 50Hz,0.456Vrms,0", "1,sin,50 Hz, 0.456 VRMS, 0") // bjarni3
    TEST_COMMAND_MATCH("sour1:appl:sin 50Hz,456mV,0", "source_apply1_sin, 50 HZ, 0.456 V, 0 V\r\n");
    TEST_COMMAND_MATCH("sour1:appl:sin", "source_apply1_sin, 1000 HZ, 0.1 V, 0 V\r\n");
    TEST_COMMAND_MATCH("sour1:appl:sin 123", "source_apply1_sin, 123 HZ, 0.1 V, 0 V\r\n");
    TEST_COMMAND_MATCH("sour2:appl:sin 1.2 KHz", "source_apply2_sin, 1200 HZ, 0.1 V, 0 V\r\n");
    TEST_COMMAND_MATCH("sour1:appl:sin 1.2 KHz, 0.200", "source_apply1_sin, 1200 HZ, 0.2 V, 0 V\r\n");
    TEST_COMMAND_MATCH("source2:apply:sin 1.2 KHz, 0.200, 0.5", "source_apply2_sin, 1200 HZ, 0.2 V, 0.5 V\r\n");
}
예제 #6
0
static void extern_value(value v)
{
  /* Initializations */
  init_extern_trail();
  output_buffer_init();
  obj_counter = 0;
  /* Marshal the object */
  extern_rec(v);
  /* Undo the modifications done on externed blocks */
  extern_replay_trail();
  output_buffer_clear();
}
예제 #7
0
static void testCommandsHandling(void) {
#define TEST_INPUT(data, output) {                              \
    SCPI_Input(&scpi_context, data, strlen(data));              \
    CU_ASSERT_STRING_EQUAL(output, output_buffer);              \
}
    output_buffer_clear();
    error_buffer_clear();

    /* Test single command */
    TEST_INPUT("*IDN?\r\n", "MA,IN,0,VER\r\n");
    output_buffer_clear();

    /* Test multiple commands in input buffer */
    TEST_INPUT("*IDN?\r\n*IDN?\r\n*IDN?\r\n*IDN?\r\n", "MA,IN,0,VER\r\nMA,IN,0,VER\r\nMA,IN,0,VER\r\nMA,IN,0,VER\r\n");
    output_buffer_clear();

    TEST_INPUT("*IDN?;*IDN?;*IDN?;*IDN?\r\n", "MA,IN,0,VER;MA,IN,0,VER;MA,IN,0,VER;MA,IN,0,VER\r\n");
    output_buffer_clear();

    TEST_INPUT("*IDN?;*OPC;*IDN?\r\n", "MA,IN,0,VER;MA,IN,0,VER\r\n");
    output_buffer_clear();

    /* Test one command in multiple buffers */
    TEST_INPUT("*IDN?", "");
    TEST_INPUT("\r\n", "MA,IN,0,VER\r\n");
    output_buffer_clear();

    /* Test input "timeout" - input with length == 0 */
    TEST_INPUT("*IDN?", "");
    TEST_INPUT("", "MA,IN,0,VER\r\n");
    output_buffer_clear();
    
    /* Test ctree traversal */
    TEST_INPUT("TEST:TREEA?;TREEB?\r\n", "10;20\r\n");
    output_buffer_clear();

    TEST_INPUT("TEST:TREEA?;:TEXT? \"PARAM1\", \"PARAM2\"\r\n", "10;\"PARAM2\"\r\n");
    output_buffer_clear();

    CU_ASSERT_EQUAL(err_buffer_pos, 0);
    error_buffer_clear();
}
예제 #8
0
static void testIEEE4882(void) {
#define TEST_IEEE4882(data, output) {                           \
    SCPI_Input(&scpi_context, data, strlen(data));              \
    CU_ASSERT_STRING_EQUAL(output, output_buffer);              \
    output_buffer_clear();                                      \
}

    output_buffer_clear();
    error_buffer_clear();

    TEST_IEEE4882("*CLS\r\n", "");
    TEST_IEEE4882("*ESE #H20\r\n", "");
    TEST_IEEE4882("*ESE?\r\n", "32\r\n");
    TEST_IEEE4882("*ESR?\r\n", "0\r\n");
    TEST_IEEE4882("*IDN?\r\n", "MA,IN,0,VER\r\n");
    TEST_IEEE4882("*OPC\r\n", "");
    TEST_IEEE4882("*OPC?\r\n", "1\r\n");

    TEST_IEEE4882("*SRE #HFF\r\n", "");
    TEST_IEEE4882("*SRE?\r\n", "255\r\n");
    TEST_IEEE4882("*STB?\r\n", "0\r\n");
    TEST_IEEE4882("*ESR?\r\n", "1\r\n");
    
    srq_val = 0;
    TEST_IEEE4882("ABCD\r\n", ""); /* "Undefined header" cause command error */
    CU_ASSERT_EQUAL(srq_val, 96); /* value of STB as service request */
    TEST_IEEE4882("*STB?\r\n", "96\r\n"); /* Event status register + Service request */
    TEST_IEEE4882("*ESR?\r\n", "32\r\n"); /* Command error */

    TEST_IEEE4882("*STB?\r\n", "0\r\n");
    TEST_IEEE4882("*ESR?\r\n", "0\r\n");
    
    TEST_IEEE4882("SYST:ERR:NEXT?\r\n", "-113,\"Undefined header\"\r\n");
    TEST_IEEE4882("SYST:ERR:NEXT?\r\n", "0,\"No error\"\r\n");
    
    RST_executed = FALSE;
    TEST_IEEE4882("*RST\r\n", "");
    CU_ASSERT_EQUAL(RST_executed, TRUE);

    TEST_IEEE4882("*TST?\r\n", "0\r\n");
    
    TEST_IEEE4882("*WAI\r\n", "");

    TEST_IEEE4882("SYSTem:VERSion?\r\n", "1999.0\r\n");
}
예제 #9
0
void test_output_matches()
{
    output_buffer_clear();
    TEST_COMMAND_MATCH("OUTP?", "output1query\r\n");
    TEST_COMMAND_MATCH("OUTP1?", "output1query\r\n");
    TEST_COMMAND_MATCH("OUTPUT?", "output1query\r\n");
    TEST_COMMAND_MATCH("OUTPUT1?", "output1query\r\n");
    TEST_COMMAND_MATCH("OUTP2?", "output2query\r\n");
    TEST_COMMAND_MATCH("OUTPUT2?", "output2query\r\n");

    TEST_COMMAND_MATCH("outp off", "output1, off\r\n");
    TEST_COMMAND_MATCH("outp on", "output1, on\r\n");
    TEST_COMMAND_MATCH("outp1 off", "output1, off\r\n");
    TEST_COMMAND_MATCH("outp1 on", "output1, on\r\n");
    TEST_COMMAND_MATCH("output1 off", "output1, off\r\n");
    TEST_COMMAND_MATCH("output1 on", "output1, on\r\n");
    TEST_COMMAND_MATCH("outp2 off", "output2, off\r\n");
    TEST_COMMAND_MATCH("outp2 on", "output2, on\r\n"); // test bjarni1
    TEST_COMMAND_MATCH("output2 off", "output2, off\r\n");
    TEST_COMMAND_MATCH("output2 on", "output2, on\r\n");

    TEST_COMMAND_MATCH("output2 1", "output2, on\r\n");
    TEST_COMMAND_MATCH("output 0", "output1, off\r\n");
}
예제 #10
0
static void extern_out_of_memory(void)
{
  extern_replay_trail();
  output_buffer_clear();
  caml_raise_out_of_memory();
}
예제 #11
0
void testScpi_glue_input()
{
    output_buffer_clear();
    TEST_COMMAND_MATCH("*IDN?", "hohoMANU, kproduct, 0, kserial\r\n");
}