// cmdopt.h : // #if !defined(AGD_CMDOPT_H__7551B3DB_D0BF_4746_A615_1BD0DC828D23__INCLUDED_) #define AGD_CMDOPT_H__7551B3DB_D0BF_4746_A615_1BD0DC828D23__INCLUDED_ #include #include #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_plugin_mode, ov_mb_slave_id, ov_mb_ctrl_reg, ov_app_addr = 'a', ov_block_size = 'b', ov_itf_name = 'd', ov_page_erase_time = 'e', ov_force_all_par = 'f', ov_ping_interval = 'i', ov_material = 'm', ov_node_addr = 'n', ov_no_progress = 'p', ov_serial = 's', ov_station_number = 't', ov_verbosity = 'v', ov_x_baud_rate = 'x', 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 bForceAllParities; bool bPluginMode; uint8_t modbParity; int16_t nModbusCtrlReg; int nQuestionMarks; int32_t nPingIntervalSec; uint32_t nBootBaudrate; uint32_t nInitBaudrate; uint32_t nExBaudrate; 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(bool bGfaUser); ///////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus } #endif // __cplusplus #endif // !defined(AGD_CMDOPT_H__7551B3DB_D0BF_4746_A615_1BD0DC828D23__INCLUDED_)