gfativaflash.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // gfativaflash.h :
  2. //
  3. #if !defined(AGD_GFATIVAFLASH_H__49F09E25_28B7_4178_B4B6_6DAFF98ABECD__INCLUDED_)
  4. #define AGD_GFATIVAFLASH_H__49F09E25_28B7_4178_B4B6_6DAFF98ABECD__INCLUDED_
  5. #include <string>
  6. #include <QObject>
  7. #include <QList>
  8. #include <QStringList>
  9. //#include <QQmlListProperty>
  10. //#include <qqmlparserstatus.h>
  11. #include "tagnames.h"
  12. #ifdef __cplusplus
  13. /////////////////////////////////////////////////////////////////////////////
  14. // gfativaflash.h - Declarations:
  15. #define _MAX_SLAVE_COUNT 256
  16. #define _MB_BROADCAST_ADDRESS 0
  17. #define _MB_MAX_SLAVE_ID 247
  18. #define _IS_VALID_SLV_ID(id) (((id) >= 0) && ((id) < _MAX_SLAVE_COUNT))
  19. #define _IS_VALID_MB_ID(id) (((id) != _MB_BROADCAST_ADDRESS) && ((id) <= _MB_MAX_SLAVE_ID))
  20. /////////////////////////////////////////////////////////////////////////////
  21. class TivaFlash : public QObject
  22. {
  23. Q_OBJECT
  24. Q_PROPERTY(QString tivaFlashUtilPath READ tivaFlashUtilPath WRITE setTivaFlashUtilPath)
  25. Q_PROPERTY(QString itfName READ itfName WRITE setItfName)
  26. Q_PROPERTY(bool slvIdIsNodeAddr READ slvIdIsNodeAddr WRITE setSlvIdIsNodeAddr)
  27. Q_PROPERTY(int verbosity READ verbosity WRITE setVerbosity NOTIFY verbosityChanged)
  28. Q_PROPERTY(QString imgFile READ imgFile WRITE setImgFile)
  29. Q_PROPERTY(QStringList materialEeprom READ materialEeprom NOTIFY materialEepromChanged)
  30. Q_PROPERTY(QStringList serialEeprom READ serialEeprom NOTIFY serialEepromChanged)
  31. Q_PROPERTY(QStringList imgMaterialBoot READ imgMaterialBoot NOTIFY imgMaterialBootChanged)
  32. Q_PROPERTY(QStringList imgBuildBoot READ imgBuildBoot NOTIFY imgBuildBootChanged)
  33. Q_PROPERTY(QList<int> imgSizeBoot READ imgSizeBoot NOTIFY imgSizeBootChanged)
  34. Q_PROPERTY(QList<double> imgCRC32Boot READ imgCRC32Boot NOTIFY imgCRC32BootChanged)
  35. Q_PROPERTY(QStringList imgMaterialApp READ imgMaterialApp NOTIFY imgMaterialAppChanged)
  36. Q_PROPERTY(QStringList imgBuildApp READ imgBuildApp NOTIFY imgBuildAppChanged)
  37. Q_PROPERTY(QList<int> imgSizeApp READ imgSizeApp NOTIFY imgSizeAppChanged)
  38. Q_PROPERTY(QList<double> imgCRC32App READ imgCRC32App NOTIFY imgCRC32AppChanged)
  39. Q_PROPERTY(QString imgMaterialFile READ imgMaterialFile NOTIFY materialFileChanged)
  40. Q_PROPERTY(QString imgBuildFile READ imgBuildFile NOTIFY imgBuildFileChanged)
  41. Q_PROPERTY(int imgSizeFile READ imgSizeFile NOTIFY imgSizeFileChanged)
  42. Q_PROPERTY(double imgCRC32File READ imgCRC32File NOTIFY imgCRC32FileChanged)
  43. public:
  44. explicit TivaFlash(QObject *pParent = NULL);
  45. virtual ~TivaFlash(void);
  46. public:
  47. Q_INVOKABLE bool getMatSer(int nSlvID, int nMbID = 0);
  48. Q_INVOKABLE bool getTargetImgInfo(int nSlvID, int nMbID = 0);
  49. Q_INVOKABLE bool pingTarget(int nSlvID, int nMbID = 0);
  50. Q_INVOKABLE bool startBootloader(int nSlvID, int nMbID = 0);
  51. Q_INVOKABLE bool resetBootloader(int nSlvID, int nMbID = 0);
  52. Q_INVOKABLE bool validateImgFile(int nSlvID, int nMbID = 0);
  53. signals:
  54. void execOut(int slv, int ctx, QString msg) const;
  55. void verbosityChanged(int val) const;
  56. void materialEepromChanged(void) const;
  57. void serialEepromChanged(void) const;
  58. void imgSizeBootChanged(void) const;
  59. void imgCRC32BootChanged(void) const;
  60. void imgMaterialBootChanged(void) const;
  61. void imgBuildBootChanged(void) const;
  62. void imgSizeAppChanged(void) const;
  63. void imgCRC32AppChanged(void) const;
  64. void imgMaterialAppChanged(void) const;
  65. void imgBuildAppChanged(void) const;
  66. void materialFileChanged(const QString &val) const;
  67. void imgBuildFileChanged(const QString &val) const;
  68. void imgSizeFileChanged(int val) const;
  69. void imgCRC32FileChanged(double val) const;
  70. private:
  71. QString tivaFlashUtilPath(void) const;
  72. void setTivaFlashUtilPath(const QString &val);
  73. QString itfName(void) const;
  74. void setItfName(const QString &val);
  75. bool slvIdIsNodeAddr(void) const;
  76. void setSlvIdIsNodeAddr(bool val);
  77. int verbosity(void) const;
  78. void setVerbosity(int val);
  79. QString imgFile(void) const;
  80. void setImgFile(const QString &val);
  81. const QStringList& materialEeprom(void) const;
  82. void setMaterialEeprom(int nSlvID, const QString &val);
  83. const QStringList& serialEeprom(void) const;
  84. void setSerialEeprom(int nSlvID, const QString &val);
  85. const QList<int>& imgSizeBoot(void) const;
  86. void setImgSizeBoot(int nSlvID, int val);
  87. const QList<double>& imgCRC32Boot(void) const;
  88. void setImgCRC32Boot(int nSlvID, double val);
  89. const QStringList& imgMaterialBoot(void) const;
  90. void setImgMaterialBoot(int nSlvID, const QString &val);
  91. const QStringList& imgBuildBoot(void) const;
  92. void setImgBuildBoot(int nSlvID, const QString &val);
  93. const QList<int>& imgSizeApp(void) const;
  94. void setImgSizeApp(int nSlvID, int val);
  95. const QList<double>& imgCRC32App(void) const;
  96. void setImgCRC32App(int nSlvID, double val);
  97. const QStringList& imgMaterialApp(void) const;
  98. void setImgMaterialApp(int nSlvID, const QString &val);
  99. const QStringList& imgBuildApp(void) const;
  100. void setImgBuildApp(int nSlvID, const QString &val);
  101. int imgSizeFile(void) const;
  102. void setImgSizeFile(int val);
  103. double imgCRC32File(void) const;
  104. void setImgCRC32File(double val);
  105. const QString& imgMaterialFile(void) const;
  106. void setImgMaterialFile(const QString &val);
  107. const QString& imgBuildFile(void) const;
  108. void setImgBuildFile(const QString &val);
  109. private:
  110. bool execFlashUtil(int nSlvID, const char *pszOpt);
  111. void onCmdOutput(int nSlvID, const char *pszOut);
  112. std::string getSlavIDs(int nSlvID, int nMbID) const;
  113. int parseTaggedString(const char *pszIn, std::string &sOut) const;
  114. private:
  115. int m_nExitCode;
  116. std::string m_tivaFlashUtilPath;
  117. std::string m_itfName;
  118. bool m_slvIdIsNodeAddr;
  119. int m_verbosity;
  120. std::string m_imgFile;
  121. QStringList m_materialEeprom;
  122. QStringList m_serialEeprom;
  123. QList<int> m_imgSizeBoot;
  124. QList<double> m_imgCRC32Boot;
  125. QStringList m_imgMaterialBoot;
  126. QStringList m_imgBuildBoot;
  127. QList<int> m_imgSizeApp;
  128. QList<double> m_imgCRC32App;
  129. QStringList m_imgMaterialApp;
  130. QStringList m_imgBuildApp;
  131. int m_imgSizeFile;
  132. double m_imgCRC32File;
  133. QString m_imgMaterialFile;
  134. QString m_imgBuildFile;
  135. };
  136. /////////////////////////////////////////////////////////////////////////////
  137. #endif // __cplusplus
  138. #endif // !defined(AGD_GFATIVAFLASH_H__49F09E25_28B7_4178_B4B6_6DAFF98ABECD__INCLUDED_)