cmdopt.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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_start_boot,
  36. ov_material,
  37. ov_serial,
  38. ov_no_progress,
  39. // ov_init_baud_rate,
  40. // ov_mb_baud_rate,
  41. // ov_mb_parity,
  42. ov_mb_slave_id,
  43. ov_mb_ctrl_reg,
  44. ov_x_baud_rate = 'x',
  45. ov_page_erase_time = 'e',
  46. ov_itf_name = 'd',
  47. ov_block_size = 'p',
  48. ov_ping_interval = 'i',
  49. ov_app_addr = 'a',
  50. ov_station_number = 's',
  51. ov_node_addr = 'n',
  52. ov_verbosity = 'v',
  53. ov_help = '?'
  54. }OptValues;
  55. /////////////////////////////////////////////////////////////////////////////
  56. typedef struct _CMD_LINE_ARGS
  57. {
  58. uint8_t nNodeAddr;
  59. uint8_t nStationNr;
  60. uint8_t nModbusSlvID;
  61. bool bShowHelp;
  62. bool bShowDevImgInfo;
  63. bool bShowFileImgInfo;
  64. bool bShowMatSer;
  65. bool bSetMatSer;
  66. bool bValidateImg;
  67. bool bUploadImg;
  68. bool bPing;
  69. bool bStartBoot;
  70. bool bResetBoot;
  71. bool bReviveBoot;
  72. bool bNeedImgFile;
  73. bool bNoProgressBlock;
  74. bool bModbusStartBoot;
  75. uint8_t modbParity;
  76. int16_t nModbusCtrlReg;
  77. int32_t nPingIntervalSec;
  78. uint32_t nBootBaudrate;
  79. uint32_t nInitBaudrate;
  80. uint32_t nElevBaudrate;
  81. uint32_t nModbBaudrate;
  82. uint32_t nBlockSize;
  83. uint32_t nStartAddr;
  84. uint32_t nPageErsaeTime;
  85. const char *pszDevName;
  86. const char *pszImgFile;
  87. const char *pszImgFileBase;
  88. const char *pszMaterial;
  89. const char *pszSerial;
  90. uint32_t nOptFlags;
  91. uint32_t nCmdFlags;
  92. uint32_t nMissingOptFlags;
  93. uint32_t nUnusedOptFlags;
  94. int nVerbosity;
  95. }CMD_LINE_ARGS, *LPCMD_LINE_ARGS;
  96. typedef const CMD_LINE_ARGS *LPCCMD_LINE_ARGS;
  97. /////////////////////////////////////////////////////////////////////////////
  98. void GfaTfuCmdOptInitOpts(LPCMD_LINE_ARGS pcla);
  99. int GfaTfuCmdOptParse(int argc, char* argv[], LPCMD_LINE_ARGS pcla);
  100. int GfaTfuCmdOptProcess(LPCMD_LINE_ARGS pcla);
  101. const char* GfaTfuCmdOpt2String(uint32_t nOpts);
  102. void GfaTfuCmdOptDumpOptions(LPCMD_LINE_ARGS pcla);
  103. void GfaTfuCmdOptDisplayHelp(void);
  104. /////////////////////////////////////////////////////////////////////////////
  105. #ifdef __cplusplus
  106. }
  107. #endif // __cplusplus
  108. #endif // !defined(AGD_CMDOPT_H__7551B3DB_D0BF_4746_A615_1BD0DC828D23__INCLUDED_)