trg.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include <stdio.h>
  2. #define SCPI_ARGS_N 0
  3. #include "app/scpi/scpi_handler.h"
  4. #include "app/scpi/commandHandlers/trg.h"
  5. #include "app/nfm/nfm_base.h"
  6. // Refer to:
  7. // [1] SCPI Specification, revision 1999.0
  8. // "Standard Commands for Programmable Instruments (SCPI), VERSION 1999.0, May 1999"
  9. // [2] Gpib Programming Tutorial, (http://g2pc1.bu.edu/~qzpeng/gpib/manual/GpibProgTut.pdf)
  10. // Electronics Group (http://www.few.vu.nl/~elec), 11 January 2000 Electronics Group
  11. // =================================================================================
  12. // @fsqvbl_CommandHandlerTRG
  13. // State's virtual table
  14. static void fsqe_CommandHandlerTRG( const struct fFSeqEntry_t * this, tFSeqCtx_t ctx );
  15. static void fsql_CommandHandlerTRG( const struct fFSeqEntry_t * this, tFSeqCtx_t ctx );
  16. static const struct fFSeqEntry_t * fsqf_CommandHandlerTRG( const struct fFSeqEntry_t * this, tFSeqCtx_t ctx, const struct fFSeqEntry_t * * pDeferredNext );
  17. const fFSeqVTable_t fsqvbl_CommandHandlerTRG =
  18. {
  19. .f = fsqf_CommandHandlerTRG,
  20. .enter = fsqe_CommandHandlerTRG,
  21. .leave = fsql_CommandHandlerTRG
  22. };
  23. static void fsqe_CommandHandlerTRG( const struct fFSeqEntry_t * this, tFSeqCtx_t ctx )
  24. {
  25. sProcessProgramDataCommonContext_t * common_ctx = ctx;
  26. SCPI_PARSE_ARGUMENTS( common_ctx ); (void)common_ctx->argsParserStatus; // status is modified
  27. }
  28. static void fsql_CommandHandlerTRG( const struct fFSeqEntry_t * this, tFSeqCtx_t ctx )
  29. {
  30. }
  31. static const struct fFSeqEntry_t * fsqf_CommandHandlerTRG( const struct fFSeqEntry_t * this,
  32. tFSeqCtx_t ctx,
  33. const struct fFSeqEntry_t * * pDeferredNext )
  34. {
  35. const fFSeqEntry_t * nextstate = NULL;
  36. sProcessProgramDataCommonContext_t * common_ctx = ctx;
  37. sScpiParserContext_t * global_ctx = common_ctx->global_ctx;
  38. switch( common_ctx->event )
  39. {
  40. case eProgramData_Event_Write:
  41. {
  42. if( common_ctx->isQuery )
  43. {
  44. common_ctx->status = eProgramDataSyntaxError; // invalid command header type: QUERY not supported
  45. }
  46. else if( eScpiStatus_success != common_ctx->argsParserStatus ) // check argument parser status
  47. {
  48. common_ctx->status = eProgramDataArgumentSyntax; // parameter syntax error, caller should generate error message
  49. }
  50. else
  51. {
  52. // "<...> A *TRG command is not supported by device, and an error is generated
  53. fsq_RaiseError( SCPI_ERROR_TRIGGER_IGNORED,
  54. SCPI_ERROR_TRIGGER_IGNORED_MSG,
  55. global_ctx->sParser.xHandlerToken.shead,
  56. global_ctx->sParser.xHandlerToken.stail );
  57. common_ctx->status = eProgramData_SpecificError; // request processed
  58. // Since @done flag is set, this dispatcher shall not be called anymore.
  59. // Since this handler is implemented as a single-state automat, there no
  60. // ... other states to go to:
  61. (void)nextstate;
  62. }
  63. }
  64. break;
  65. }
  66. return nextstate;
  67. }