rst.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include <stdio.h>
  2. #define SCPI_ARGS_N 0
  3. #include "app/scpi/scpi_handler.h"
  4. #include "app/scpi/commandHandlers/rst.h"
  5. #include "app/nfm/nfm_base.h"
  6. #include "app/control_table/control_table.h"
  7. // Refer to:
  8. // [1] SCPI Specification, revision 1999.0
  9. // "Standard Commands for Programmable Instruments (SCPI), VERSION 1999.0, May 1999"
  10. // [2] Gpib Programming Tutorial, (http://g2pc1.bu.edu/~qzpeng/gpib/manual/GpibProgTut.pdf)
  11. // Electronics Group (http://www.few.vu.nl/~elec), 11 January 2000 Electronics Group
  12. // =================================================================================
  13. // @fsqvbl_CommandHandlerRST
  14. // State's virtual table
  15. static void fsqe_CommandHandlerRST( const struct fFSeqEntry_t * this, tFSeqCtx_t ctx );
  16. static void fsql_CommandHandlerRST( const struct fFSeqEntry_t * this, tFSeqCtx_t ctx );
  17. static const struct fFSeqEntry_t * fsqf_CommandHandlerRST( const struct fFSeqEntry_t * this, tFSeqCtx_t ctx, const struct fFSeqEntry_t * * pDeferredNext );
  18. const fFSeqVTable_t fsqvbl_CommandHandlerRST =
  19. {
  20. .f = fsqf_CommandHandlerRST,
  21. .enter = fsqe_CommandHandlerRST,
  22. .leave = fsql_CommandHandlerRST
  23. };
  24. static void fsqe_CommandHandlerRST( const struct fFSeqEntry_t * this, tFSeqCtx_t ctx )
  25. {
  26. sProcessProgramDataCommonContext_t * common_ctx = ctx;
  27. SCPI_PARSE_ARGUMENTS( common_ctx ); (void)common_ctx->argsParserStatus; // status is modified
  28. }
  29. static void fsql_CommandHandlerRST( const struct fFSeqEntry_t * this, tFSeqCtx_t ctx )
  30. {
  31. }
  32. static const struct fFSeqEntry_t * fsqf_CommandHandlerRST( const struct fFSeqEntry_t * this,
  33. tFSeqCtx_t ctx,
  34. const struct fFSeqEntry_t * * pDeferredNext )
  35. {
  36. const fFSeqEntry_t * nextstate = NULL;
  37. sProcessProgramDataCommonContext_t * common_ctx = 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 *RST command returns the instrument to a state where it is waiting for a command to
  53. // initiate measurements or other instrument actions. <...>", "10 *RST Conditions", [1]
  54. // "5 Reset and Clear", [2]
  55. // Provide device-specific reset
  56. //NFMClass->methods.keyStatesMethods.setKeyStateDefault();
  57. NFMClass->methods.portMethods.setPortState(eNFMPort_1, 0);
  58. NFMClass->methods.portMethods.setPortState(eNFMPort_2, 0);
  59. ControlHandle.SetDefaultState();
  60. common_ctx->status = eProgramDataDone; // request processed
  61. // Since @done flag is set, this dispatcher shall not be called anymore.
  62. // Since this handler is implemented as a single-state automat, there no
  63. // ... other states to go to:
  64. (void)nextstate;
  65. }
  66. }
  67. break;
  68. }
  69. return nextstate;
  70. }