Remove problematic test callback
User should reimplement whole callback and not just a part with
problematic return value.
| | |
| | | Reading strings is now more correct but it needs secondary copy buffer. You can use function `SCPI_ParamCopyText` to correctly handle strings like `"normal ""quoted"" normal"` will be converted to `normal "quoted" normal`. |
| | | |
| | | It is now possible to use `SCPI_ParamArbitraryBlock` and `SCPI_ResultArbitraryBlock` to work with binary data input and output. |
| | | |
| | | Test callback is removed from context. You should now reimplement whole `*TST?` command callback. |
| | | |
| | | Usage |
| | | --------------- |
| | |
| | | .write = myWrite, |
| | | .error = NULL, |
| | | .reset = NULL, |
| | | .test = NULL, |
| | | .srq = NULL, |
| | | }; |
| | | ``` |
| | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | /** |
| | | * Reimplement IEEE488.2 *TST? |
| | | * |
| | | * Result should be 0 if everything is ok |
| | | * Result should be 1 if something goes wrong |
| | | * |
| | | * Return SCPI_RES_OK |
| | | */ |
| | | scpi_result_t My_CoreTstQ(scpi_t * context) { |
| | | |
| | | SCPI_ResultInt(context, 0); |
| | | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | static const scpi_command_t scpi_commands[] = { |
| | | /* IEEE Mandated Commands (SCPI std V1999.0 4.1.1) */ |
| | | { .pattern = "*CLS", .callback = SCPI_CoreCls,}, |
| | |
| | | { .pattern = "*SRE", .callback = SCPI_CoreSre,}, |
| | | { .pattern = "*SRE?", .callback = SCPI_CoreSreQ,}, |
| | | { .pattern = "*STB?", .callback = SCPI_CoreStbQ,}, |
| | | { .pattern = "*TST?", .callback = SCPI_CoreTstQ,}, |
| | | { .pattern = "*TST?", .callback = My_CoreTstQ,}, |
| | | { .pattern = "*WAI", .callback = SCPI_CoreWai,}, |
| | | |
| | | /* Required SCPI commands (SCPI std V1999.0 4.2.1) */ |
| | |
| | | .control = SCPI_Control, |
| | | .flush = SCPI_Flush, |
| | | .reset = SCPI_Reset, |
| | | .test = SCPI_Test, |
| | | }; |
| | | |
| | | #define SCPI_INPUT_BUFFER_LENGTH 256 |
| | |
| | | /* control */ SCPI_Control, |
| | | /* flush */ SCPI_Flush, |
| | | /* reset */ SCPI_Reset, |
| | | /* test */ SCPI_Test, |
| | | }; |
| | | |
| | | #define SCPI_INPUT_BUFFER_LENGTH 256 |
| | |
| | | int SCPI_Error(scpi_t * context, int_fast16_t err); |
| | | scpi_result_t SCPI_Control(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val); |
| | | scpi_result_t SCPI_Reset(scpi_t * context); |
| | | int32_t SCPI_Test(scpi_t * context); |
| | | scpi_result_t SCPI_Flush(scpi_t * context); |
| | | |
| | | |
| | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | /** |
| | | * Callback for *TST? command |
| | | * |
| | | * It returns directly the result of the test |
| | | * @param context |
| | | * @return 0 means "test was OK", other values means, that some error bits are set |
| | | */ |
| | | int32_t SCPI_Test(scpi_t * context) { |
| | | (void) context; |
| | | iprintf("**Test\r\n"); |
| | | return 0; |
| | | } |
| | | |
| | | scpi_result_t SCPI_Reset(scpi_t * context) { |
| | | (void) context; |
| | | iprintf("**Reset\r\n"); |
| | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | /** |
| | | * Callback for *TST? command |
| | | * |
| | | * It returns directly the result of the test |
| | | * @param context |
| | | * @return 0 means "test was OK", other values means, that some error bits are set |
| | | */ |
| | | int32_t SCPI_Test(scpi_t * context) { |
| | | fprintf(stderr, "**Test\r\n"); |
| | | return 0; |
| | | } |
| | | |
| | | scpi_result_t SCPI_Reset(scpi_t * context) { |
| | | fprintf(stderr, "**Reset\r\n"); |
| | | return SCPI_RES_OK; |
| | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | /** |
| | | * Callback for *TST? command |
| | | * |
| | | * It returns directly the result of the test |
| | | * @param context |
| | | * @return 0 means "test was OK", other values means, that some error bits are set |
| | | */ |
| | | int32_t SCPI_Test(scpi_t * context) { |
| | | fprintf(stderr, "**Test\r\n"); |
| | | return 0; |
| | | } |
| | | |
| | | scpi_result_t SCPI_Reset(scpi_t * context) { |
| | | fprintf(stderr, "**Reset\r\n"); |
| | | return SCPI_RES_OK; |
| | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | /** |
| | | * Callback for *TST? command |
| | | * |
| | | * It returns directly the result of the test |
| | | * @param context |
| | | * @return 0 means "test was OK", other values means, that some error bits are set |
| | | */ |
| | | int32_t SCPI_Test(scpi_t * context) { |
| | | fprintf(stderr, "**Test\r\n"); |
| | | return 0; |
| | | } |
| | | |
| | | scpi_result_t SCPI_Reset(scpi_t * context) { |
| | | fprintf(stderr, "**Reset\r\n"); |
| | | return SCPI_RES_OK; |
| | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | /** |
| | | * Callback for *TST? command |
| | | * |
| | | * It returns directly the result of the test |
| | | * @param context |
| | | * @return 0 means "test was OK", other values means, that some error bits are set |
| | | */ |
| | | int32_t SCPI_Test(scpi_t * context) { |
| | | fprintf(stderr, "**Test\r\n"); |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | scpi_result_t SCPI_Reset(scpi_t * context) { |
| | | fprintf(stderr, "**Reset\r\n"); |
| | | return SCPI_RES_OK; |
| | |
| | | typedef struct _scpi_parser_state_t scpi_parser_state_t; |
| | | |
| | | typedef scpi_result_t(*scpi_command_callback_t)(scpi_t *); |
| | | typedef int32_t(*scpi_test_command_callback_t)(scpi_t *); |
| | | |
| | | /* scpi error queue */ |
| | | typedef void * scpi_error_queue_t; |
| | |
| | | scpi_write_control_t control; |
| | | scpi_command_callback_t flush; |
| | | scpi_command_callback_t reset; |
| | | scpi_test_command_callback_t test; |
| | | }; |
| | | |
| | | struct _scpi_t { |
| | |
| | | * @return |
| | | */ |
| | | scpi_result_t SCPI_CoreTstQ(scpi_t * context) { |
| | | int result = 0; |
| | | if (context && context->interface && context->interface->test) { |
| | | result = context->interface->test(context); |
| | | } |
| | | SCPI_ResultInt(context, result); |
| | | (void) context; |
| | | SCPI_ResultInt(context, 0); |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | |
| | | (void)context; |
| | | } |
| | | |
| | | int32_t SCPI_Test(scpi_t * context) |
| | | { |
| | | (void)context; |
| | | return 0; |
| | | } |
| | | |
| | | scpi_result_t SCPI_Flush(scpi_t * context) |
| | | { |
| | | (void)context; |
| | | } |
| | | |
| | | |
| | | static scpi_interface_t scpi_interface = { |
| | | .error = SCPI_Error, |
| | |
| | | .control = SCPI_Control, |
| | | .flush = SCPI_Flush, |
| | | .reset = SCPI_Reset, |
| | | .test = SCPI_Test, |
| | | }; |
| | | |
| | | #define SCPI_INPUT_BUFFER_LENGTH 256 |