123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- // cmdopt.h :
- //
- #if !defined(AGD_CMDOPT_H__7551B3DB_D0BF_4746_A615_1BD0DC828D23__INCLUDED_)
- #define AGD_CMDOPT_H__7551B3DB_D0BF_4746_A615_1BD0DC828D23__INCLUDED_
- #include <stdint.h>
- #include <stdbool.h>
- #ifdef __cplusplus
- extern "C" {
- #endif // __cplusplus
- /////////////////////////////////////////////////////////////////////////////
- // cmdopt.h - Declarations:
- // http://man7.org/linux/man-pages/man3/getopt.3.html
- #define CMD_OPT_MIN_VERBOSITY 0
- #define CMD_OPT_MAX_VERBOSITY 4
- #define CMD_OPT_DEFAULT_VERBOSITY 2
- #define CMD_OPT_DEFAULT_BAUDRATE 19200
- #define CMD_OPT_DEFAULT_PAGE_ERASE_TIME 20
- #define CMD_OPT_DEFAULT_APP_BASE_ADDRESS 0x2000
- #define CMD_OPT_DEFAULT_MODBUS_START_REGISTER 46
- #define CMD_OPT_DEFAULT_MODBUS_PARITY 'E'
- /////////////////////////////////////////////////////////////////////////////
- typedef enum _OptValues
- {
- ov_img_file = 1,
- ov_show_dev_img_info,
- ov_show_file_img_info,
- ov_validate_img,
- ov_upload_img,
- ov_show_mat_ser,
- ov_set_mat_ser,
- ov_boot_ping,
- ov_start_boot,
- ov_reset_boot,
- ov_rescue_boot,
- ov_mb_start_boot,
- ov_material,
- ov_serial,
- ov_no_progress,
- // ov_init_baud_rate,
- // ov_mb_baud_rate,
- // ov_mb_parity,
- ov_mb_slave_id,
- ov_mb_ctrl_reg,
- ov_x_baud_rate = 'x',
- ov_page_erase_time = 'e',
- ov_itf_name = 'd',
- ov_block_size = 'p',
- ov_ping_interval = 'i',
- ov_app_addr = 'a',
- ov_station_number = 's',
- ov_node_addr = 'n',
- ov_verbosity = 'v',
- ov_help = '?'
- }OptValues;
- /////////////////////////////////////////////////////////////////////////////
- typedef struct _CMD_LINE_ARGS
- {
- uint8_t nNodeAddr;
- uint8_t nStationNr;
- uint8_t nModbusSlvID;
- bool bShowHelp;
- bool bShowDevImgInfo;
- bool bShowFileImgInfo;
- bool bShowMatSer;
- bool bSetMatSer;
- bool bValidateImg;
- bool bUploadImg;
- bool bPing;
- bool bStartBoot;
- bool bResetBoot;
- bool bReviveBoot;
- bool bNeedImgFile;
- bool bNoProgressBlock;
- bool bModbusStartBoot;
- uint8_t modbParity;
- int16_t nModbusCtrlReg;
- int32_t nPingIntervalSec;
- uint32_t nBootBaudrate;
- uint32_t nInitBaudrate;
- uint32_t nElevBaudrate;
- uint32_t nModbBaudrate;
- uint32_t nBlockSize;
- uint32_t nStartAddr;
- uint32_t nPageErsaeTime;
- const char *pszDevName;
- const char *pszImgFile;
- const char *pszImgFileBase;
- const char *pszMaterial;
- const char *pszSerial;
- uint32_t nOptFlags;
- uint32_t nCmdFlags;
- uint32_t nMissingOptFlags;
- uint32_t nUnusedOptFlags;
- int nVerbosity;
- }CMD_LINE_ARGS, *LPCMD_LINE_ARGS;
- typedef const CMD_LINE_ARGS *LPCCMD_LINE_ARGS;
- /////////////////////////////////////////////////////////////////////////////
- void GfaTfuCmdOptInitOpts(LPCMD_LINE_ARGS pcla);
- int GfaTfuCmdOptParse(int argc, char* argv[], LPCMD_LINE_ARGS pcla);
- int GfaTfuCmdOptProcess(LPCMD_LINE_ARGS pcla);
- const char* GfaTfuCmdOpt2String(uint32_t nOpts);
- void GfaTfuCmdOptDumpOptions(LPCMD_LINE_ARGS pcla);
- void GfaTfuCmdOptDisplayHelp(void);
- /////////////////////////////////////////////////////////////////////////////
- #ifdef __cplusplus
- }
- #endif // __cplusplus
- #endif // !defined(AGD_CMDOPT_H__7551B3DB_D0BF_4746_A615_1BD0DC828D23__INCLUDED_)
|