cmdopt.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // cmdopt.h :
  2. //
  3. #if !defined(AGD_CMDOPT_H__7551B3DB_D0BF_4746_A615_1BD0DC828D23__INCLUDED_)
  4. #define AGD_CMDOPT_H__7551B3DB_D0BF_4746_A615_1BD0DC828D23__INCLUDED_
  5. #include <stdint.h>
  6. #include <stdbool.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif // __cplusplus
  10. /////////////////////////////////////////////////////////////////////////////
  11. // cmdopt.h - Declarations:
  12. // http://man7.org/linux/man-pages/man3/getopt.3.html
  13. #define CMD_OPT_MIN_VERBOSITY 0
  14. #define CMD_OPT_MAX_VERBOSITY 4
  15. #define CMD_OPT_DEFAULT_VERBOSITY 2
  16. #define CMD_OPT_DEFAULT_BAUDRATE 19200
  17. #define CMD_OPT_DEFAULT_PAGE_ERASE_TIME 20
  18. #define CMD_OPT_DEFAULT_APP_BASE_ADDRESS 0x2000
  19. #define CMD_OPT_DEFAULT_MODBUS_START_REGISTER 46
  20. #define CMD_OPT_DEFAULT_MODBUS_PARITY 'E'
  21. /////////////////////////////////////////////////////////////////////////////
  22. typedef enum _OptValues
  23. {
  24. ov_img_file = 1,
  25. ov_show_dev_img_info,
  26. ov_show_file_img_info,
  27. ov_validate_img,
  28. ov_upload_img,
  29. ov_show_mat_ser,
  30. ov_set_mat_ser,
  31. ov_boot_ping,
  32. ov_start_boot,
  33. ov_reset_boot,
  34. ov_rescue_boot,
  35. ov_mb_slave_id,
  36. ov_mb_ctrl_reg,
  37. ov_app_addr = 'a',
  38. ov_block_size = 'b',
  39. ov_itf_name = 'd',
  40. ov_page_erase_time = 'e',
  41. ov_force_all_par = 'f',
  42. ov_ping_interval = 'i',
  43. ov_material = 'm',
  44. ov_node_addr = 'n',
  45. ov_no_progress = 'p',
  46. ov_serial = 's',
  47. ov_station_number = 't',
  48. ov_verbosity = 'v',
  49. ov_x_baud_rate = 'x',
  50. ov_help = '?'
  51. }OptValues;
  52. /////////////////////////////////////////////////////////////////////////////
  53. typedef struct _CMD_LINE_ARGS
  54. {
  55. uint8_t nNodeAddr;
  56. uint8_t nStationNr;
  57. uint8_t nModbusSlvID;
  58. bool bShowHelp;
  59. bool bShowDevImgInfo;
  60. bool bShowFileImgInfo;
  61. bool bShowMatSer;
  62. bool bSetMatSer;
  63. bool bValidateImg;
  64. bool bUploadImg;
  65. bool bPing;
  66. bool bStartBoot;
  67. bool bResetBoot;
  68. bool bReviveBoot;
  69. bool bNeedImgFile;
  70. bool bNoProgressBlock;
  71. bool bForceAllParities;
  72. uint8_t modbParity;
  73. int16_t nModbusCtrlReg;
  74. int nQuestionMarks;
  75. int32_t nPingIntervalSec;
  76. uint32_t nBootBaudrate;
  77. uint32_t nInitBaudrate;
  78. uint32_t nExBaudrate;
  79. uint32_t nModbBaudrate;
  80. uint32_t nBlockSize;
  81. uint32_t nStartAddr;
  82. uint32_t nPageErsaeTime;
  83. const char *pszDevName;
  84. const char *pszImgFile;
  85. const char *pszImgFileBase;
  86. const char *pszMaterial;
  87. const char *pszSerial;
  88. uint32_t nOptFlags;
  89. uint32_t nCmdFlags;
  90. uint32_t nMissingOptFlags;
  91. uint32_t nUnusedOptFlags;
  92. int nVerbosity;
  93. }CMD_LINE_ARGS, *LPCMD_LINE_ARGS;
  94. typedef const CMD_LINE_ARGS *LPCCMD_LINE_ARGS;
  95. /////////////////////////////////////////////////////////////////////////////
  96. void GfaTfuCmdOptInitOpts(LPCMD_LINE_ARGS pcla);
  97. int GfaTfuCmdOptParse(int argc, char* argv[], LPCMD_LINE_ARGS pcla);
  98. int GfaTfuCmdOptProcess(LPCMD_LINE_ARGS pcla);
  99. const char* GfaTfuCmdOpt2String(uint32_t nOpts);
  100. void GfaTfuCmdOptDumpOptions(LPCMD_LINE_ARGS pcla);
  101. void GfaTfuCmdOptDisplayHelp(bool bGfaUser);
  102. /////////////////////////////////////////////////////////////////////////////
  103. #ifdef __cplusplus
  104. }
  105. #endif // __cplusplus
  106. #endif // !defined(AGD_CMDOPT_H__7551B3DB_D0BF_4746_A615_1BD0DC828D23__INCLUDED_)