// FirmwareToolDlg.h: 头文件 // #pragma once typedef struct tagInfoBlock // 20 bytes { // USHORT nBlockLenth; USHORT nDeviceTypeVer; //device type x.y // UCHAR nDevierVer; USHORT nProgVer; //prog version x.y USHORT nKLinkVer; //x.y USHORT nKBusVer; //x.y // USHORT nKNetVer; //x.y // USHORT nKWLVer; //x.y UCHAR nCapacity1; // ? K UCHAR nCapacity2; // ? k UCHAR nDInput; UCHAR nDOutput; UCHAR nAInput; UCHAR nAOutput; UCHAR nHInput; UCHAR nHOutput; UCHAR nExt1; UCHAR nExt2; UCHAR nLogSize; UCHAR nPorts; UCHAR nManSize; UCHAR nAbility; UCHAR nSwitchBits; }stKMInfoBlock, * pKMInfoBlock; typedef struct tagInfoBlockHdr { unsigned short nBlkSign; // 开始标志 unsigned short nBlkTypeVer; // 类型和版本 unsigned short nBlkSize; // Block 大小, 包括开始和结束标志 unsigned short Pad1; }stInfoBlockHdr; typedef struct tagInfoBlockTail { unsigned short CRC16; unsigned short EndSign; }stInfoBlockTail; typedef struct tagBtLdrInfoBlock { stInfoBlockHdr Hdr; unsigned short nBtldrVer; unsigned short nBtldrDevice; unsigned short nBtldrSize; // 设计大小 unsigned short nBtldrDataSize; //代码大小 unsigned int nBtldr_AppAddr; unsigned int nBtldr_NewAppInfoAddr; unsigned int nBtldr_NewAppAddr; stInfoBlockTail tail; }stBtLdrInfoBlock, *pBtLdrInfoBlock; typedef struct tagAppInfoBlock { stInfoBlockHdr Hdr; union { unsigned short nAppVer; struct { unsigned char nAppVerMinor; unsigned char nAppVerMajor; }; }; unsigned short nAppDevice; unsigned short nAppSize; // 设计大小 unsigned short nAppDataSize; //代码大小 unsigned int nAppStartAddr; unsigned int nAppStartOffset; unsigned int nApp; stInfoBlockTail tail; }stAppInfoBlock, * pAppInfoBlock; // CFirmwareToolDlg 对话框 class CFirmwareToolDlg : public CDialogEx { // 构造 public: CFirmwareToolDlg(CWnd* pParent = nullptr); // 标准构造函数 // 对话框数据 #ifdef AFX_DESIGN_TIME enum { IDD = IDD_FIRMWARETOOL_DIALOG }; #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 // 实现 protected: HICON m_hIcon; // 生成的消息映射函数 virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClickedButtonOpenBtldr(); afx_msg void OnBnClickedButtonOpenApp(); afx_msg void OnBnClickedButtonMake(); virtual BOOL PreTranslateMessage(MSG* pMsg); afx_msg void OnTimer(UINT_PTR nIDEvent); int DelayInit(); int ShowParams(); int GetParams(); int LoadConfig(); int SaveConfig(); afx_msg void OnClose(); // 载入BootLoader文件 int LoadBtldrFile(CString sFilePathName); // 载入APP应用程序文件 int LoadAppFile(CString sFilePathName); int MakeFirmware(); int SaveFirmwareAsFile(CString sFilePathName); };