scpi_commands.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef SCPI_COMMANDS_H
  2. #define SCPI_COMMANDS_H
  3. #include <stdbool.h>
  4. #include "app/fseq/fseq.h"
  5. #include "app/scpi/scpi_base.h" // eScpiStatus_t
  6. #include "app/tlst/tree_list.h" // sTreeList_t
  7. // @scpi_commands_root
  8. // Entire the supported SCPI commands tree.
  9. extern const sTreeList_t scpi_commands_root_node;
  10. // ==============================================================================================
  11. // @scpiSearchCommandHandler
  12. // Searches for the registered SCPI-command handler for the
  13. // ... command specified by pair of @shead and @stail.
  14. // @proot - pointer to the root element pointer to search in, neither the
  15. // ... @proot nor the value referred by @proot can not be NULL;
  16. // @shead - string head (begining), can not be NULL;
  17. // @stail - string tail (ending), can not be NULL;
  18. // @cmdType - the command header type, see @eScpiEntityType_t.
  19. // @pFoundHandler - pointer to the string token structure to store found handler mnemonic (optional);
  20. // @bRememberOverride - force remember last successful branch;
  21. // Returns: the command handler entry pointer in success case,
  22. // ... and NULL in case no command handler found or on error condition.
  23. // Note: pair of @shead and @stail shall represent a valid SCPI Command
  24. // ... Program Header ("7.6.1 <COMMAND PROGPRAM HEADER>", [1]), processed
  25. // ... by @parseCommandProgramHeader function.
  26. // Note: if this call is the first one for the request, the @bRememberOverride shall be
  27. // ... true to remember the first subsystem (branch) to search the next commands in.
  28. // References:
  29. // 6.2.4 Traversal of the Header Tree, [2]
  30. // A.1.1 Use of the Compound Header Rules, [1]
  31. const sScpiCommandHandlerEntry_t * scpiSearchCommandHandler(
  32. const sTreeList_t * * proot,
  33. const char * shead,
  34. const char * stail,
  35. uint8_t cmdType,
  36. sStrToken_t * pFoundHandler,
  37. bool bRememberOverride );
  38. // ==============================================================================================
  39. // @processCharacterArgument
  40. // Argument Validation Function
  41. // Processes specified SCPI Character Parameter (Character Program Data) and searches it in the allowed values list.
  42. // Function uses smart comparing the source parameter to each one of the list allowing short and long form of value.
  43. // References:
  44. // "7.7.1 <CHARACTER PROGRAM DATA>", [1]
  45. // "7.7.1.2 Encoding Syntax", [1]
  46. // @allowedList - values allowed list, use @DECLARE_ARGUMENT_CHARACTER_ALLOWED_LIST to create this parameter;
  47. // Note 1: each element in the list must be a NULL-terminated string;
  48. // Note 2: the list must contain NULL-pointer in the end of list;
  49. // @arg - parsed argument token filled by @parseArguments (SCPI_PARSE_ARGUMENTS macro)
  50. // @pIdx - optional pointer to the variable to store index of matched element in the @allowedList array, only valid if
  51. // the 'true' is returned; only positive number is returned;
  52. // Return:
  53. // - true: parameter processed successfully, passed parameter is valid due to it matchs to
  54. // one of the element of allowed list;
  55. // - false: parameter fail, passed parameter not recognized or invalid function parameter;
  56. bool processCharacterArgument( const xArgument_t * allowedList, const sStrToken_t * arg, int8_t * pIdx );
  57. #endif