|
@@ -46,7 +46,7 @@ TivaFlash::TivaFlash(QObject *pParent) : QObject(pParent),
|
|
|
m_qProcess(this)
|
|
|
{
|
|
|
setObjectName("TivaFlash");
|
|
|
-
|
|
|
+
|
|
|
for(int i = 0; i < _MAX_SLAVE_COUNT; i++)
|
|
|
{
|
|
|
m_materialEeprom.append("");
|
|
@@ -62,12 +62,12 @@ TivaFlash::TivaFlash(QObject *pParent) : QObject(pParent),
|
|
|
m_imgMaterialApp.append("");
|
|
|
m_imgBuildApp.append("");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
connect(&m_qProcess, SIGNAL(started()), SLOT(onProcessStarted()));
|
|
|
connect(&m_qProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(onProcessFinished(int, QProcess::ExitStatus)));
|
|
|
connect(&m_qProcess, SIGNAL(readyReadStandardOutput()), SLOT(onProcessReadyReadStandardOutput()));
|
|
|
connect(&m_qProcess, SIGNAL(stateChanged(QProcess::ProcessState)), SLOT(onProcessStateChanged(QProcess::ProcessState)));
|
|
|
-
|
|
|
+
|
|
|
m_qProcess.setProcessChannelMode(QProcess::MergedChannels);
|
|
|
}
|
|
|
|
|
@@ -112,7 +112,7 @@ bool TivaFlash::execFlashUtil(int nSlvID, const char *pszOpt)
|
|
|
char buffer[256];
|
|
|
m_nExitCode = -1;
|
|
|
std::string strCmd = _formatString("\"%s\" %s --plugin-mode 2>&1", m_tivaFlashUtilPath.c_str(), pszOpt);
|
|
|
-
|
|
|
+
|
|
|
if((pd = popen(strCmd.c_str(), "r")))
|
|
|
{
|
|
|
while(fgets(buffer, sizeof buffer, pd))
|
|
@@ -156,7 +156,7 @@ void TivaFlash::getSlavIDs(int nSlvID, int nMbID, QStringList &rargs) const
|
|
|
if(_IS_VALID_MB_ID(nMbID))
|
|
|
{
|
|
|
rargs << QString::asprintf("--mb-slave-id=%d", nMbID);
|
|
|
-
|
|
|
+
|
|
|
if(m_mbCtrlRegister > 0)
|
|
|
rargs << QString::asprintf("--mb-bl-ctrl-reg=%d", m_mbCtrlRegister);
|
|
|
}
|
|
@@ -227,7 +227,7 @@ int TivaFlash::parseTaggedString(const char *pszIn, std::string &sOut) const
|
|
|
if(regex_search(pszIn, res, reg))
|
|
|
{
|
|
|
size_t nSize = res.size();
|
|
|
-
|
|
|
+
|
|
|
if(nSize == 3)
|
|
|
{
|
|
|
std::string strTagName = res[1].str();
|
|
@@ -240,7 +240,7 @@ int TivaFlash::parseTaggedString(const char *pszIn, std::string &sOut) const
|
|
|
{
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -259,7 +259,7 @@ int TivaFlash::parseTaggedValues(const char *pszIn, int &rnVal1, int &rnVal2) co
|
|
|
if(regex_search(pszIn, res, reg))
|
|
|
{
|
|
|
size_t nSize = res.size();
|
|
|
-
|
|
|
+
|
|
|
if(nSize == 3)
|
|
|
{
|
|
|
rnVal1 = atoi(res[1].str().c_str());
|
|
@@ -272,7 +272,7 @@ int TivaFlash::parseTaggedValues(const char *pszIn, int &rnVal1, int &rnVal2) co
|
|
|
{
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -283,7 +283,7 @@ void TivaFlash::onCmdOutput(int nSlvID, const char *pszOut)
|
|
|
std::string s;
|
|
|
int nTag = parseTaggedString(pszOut, s);
|
|
|
int nVal1, nVal2;
|
|
|
-
|
|
|
+
|
|
|
if(nTag >= 0)
|
|
|
{
|
|
|
QString qs = QString::fromStdString(s);
|
|
@@ -372,6 +372,7 @@ void TivaFlash::onCmdOutput(int nSlvID, const char *pszOut)
|
|
|
m_imgUpldProg.setCtx(ImgUploadStatus::EraseFlashStart);
|
|
|
if(parseTaggedValues(s.c_str(), nVal1, nVal2) == 2)
|
|
|
{
|
|
|
+ m_imgUpldProg.setUploadInProgress(true);
|
|
|
m_imgUpldProg.setCntFlashPages(nVal1);
|
|
|
m_imgUpldProg.setCbTotal(nVal2);
|
|
|
emit imgUploadProgress(&m_imgUpldProg);
|
|
@@ -393,7 +394,8 @@ void TivaFlash::onCmdOutput(int nSlvID, const char *pszOut)
|
|
|
int nCbTotal = m_imgUpldProg.cbTotal();
|
|
|
int nCbSent = nVal1;
|
|
|
m_imgUpldProg.setCbSent(nCbSent);
|
|
|
- m_imgUpldProg.setPercentSent(nCbSent * 100 / nCbTotal);
|
|
|
+ if(nCbTotal)
|
|
|
+ m_imgUpldProg.setPercentSent(nCbSent * 100 / nCbTotal);
|
|
|
m_imgUpldProg.SetBlockNr(nVal2);
|
|
|
emit imgUploadProgress(&m_imgUpldProg);
|
|
|
}
|
|
@@ -401,11 +403,13 @@ void TivaFlash::onCmdOutput(int nSlvID, const char *pszOut)
|
|
|
case PLUGIN_TAG_UPLOAD_BLOCKS_END:
|
|
|
m_imgUpldProg.setCtx(ImgUploadStatus::ImgUploadSuccess);
|
|
|
m_imgUpldProg.setErrorCode(0);
|
|
|
+ m_imgUpldProg.setUploadInProgress(false);
|
|
|
emit imgUploadProgress(&m_imgUpldProg);
|
|
|
break;
|
|
|
case PLUGIN_TAG_UPLOAD_ERROR:
|
|
|
m_imgUpldProg.setCtx(ImgUploadStatus::ImgUploadError);
|
|
|
m_imgUpldProg.setErrorCode(qs.toInt());
|
|
|
+ m_imgUpldProg.setUploadInProgress(false);
|
|
|
emit imgUploadProgress(&m_imgUpldProg);
|
|
|
break;
|
|
|
}
|
|
@@ -423,7 +427,7 @@ bool TivaFlash::getMatSer(int nSlvID, int nMbID)
|
|
|
if(!_IS_VALID_SLV_ID(nSlvID))
|
|
|
return false;
|
|
|
m_curSlvID = nSlvID;
|
|
|
-
|
|
|
+
|
|
|
setMaterialEeprom(nSlvID, "");
|
|
|
setSerialEeprom(nSlvID, "");
|
|
|
|
|
@@ -548,6 +552,7 @@ bool TivaFlash::uploadImgFile(int nSlvID, int nMbID)
|
|
|
if(!_IS_VALID_SLV_ID(nSlvID))
|
|
|
return false;
|
|
|
m_curSlvID = nSlvID;
|
|
|
+ m_imgUpldProg.clear();
|
|
|
|
|
|
QStringList args;
|
|
|
args << "--upload-img";
|
|
@@ -570,12 +575,12 @@ bool TivaFlash::clearImgInfo(int nSlvID)
|
|
|
return false;
|
|
|
if(!_IS_VALID_SLV_ID(nSlvID))
|
|
|
return false;
|
|
|
-
|
|
|
+
|
|
|
setImgSizeFile(0);
|
|
|
setImgCRC32File(0);
|
|
|
setImgMaterialFile(0);
|
|
|
setImgBuildFile(0);
|
|
|
-
|
|
|
+
|
|
|
if(nSlvID > 0)
|
|
|
{
|
|
|
setMaterialEeprom(nSlvID, "");
|
|
@@ -609,7 +614,7 @@ bool TivaFlash::clearImgInfo(int nSlvID)
|
|
|
setImgBuildApp(i, "");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -667,7 +672,7 @@ void TivaFlash::setVerbosity(int val)
|
|
|
val = 0;
|
|
|
else if(val > 3)
|
|
|
val = 3;
|
|
|
-
|
|
|
+
|
|
|
if(m_verbosity != val)
|
|
|
{
|
|
|
m_verbosity = val;
|
|
@@ -792,6 +797,11 @@ void TivaFlash::setForceAllParities(bool val)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ImgUploadStatus* TivaFlash::imgUploadStatus(void)
|
|
|
+{
|
|
|
+ return &m_imgUpldProg;
|
|
|
+}
|
|
|
+
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -1050,6 +1060,7 @@ void ImgUploadStatus::clear(void)
|
|
|
m_nCbSent = 0;
|
|
|
m_nPercentSent = 0;
|
|
|
m_nCntFlashPages = 0;
|
|
|
+ m_bUploadInProgress = false;
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -1062,7 +1073,10 @@ int ImgUploadStatus::ctx(void) const
|
|
|
void ImgUploadStatus::setCtx(int val)
|
|
|
{
|
|
|
if(m_nCtx != val)
|
|
|
+ {
|
|
|
m_nCtx = val;
|
|
|
+ emit ctxChanged(m_nCtx);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -1075,7 +1089,10 @@ int ImgUploadStatus::errorCode(void) const
|
|
|
void ImgUploadStatus::setErrorCode(int val)
|
|
|
{
|
|
|
if(m_nErrorCode != val)
|
|
|
+ {
|
|
|
m_nErrorCode = val;
|
|
|
+ emit errorCodeChanged(m_nErrorCode);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -1088,7 +1105,10 @@ int ImgUploadStatus::cbBlock(void) const
|
|
|
void ImgUploadStatus::setCbBlock(int val)
|
|
|
{
|
|
|
if(m_nCbBlock != val)
|
|
|
+ {
|
|
|
m_nCbBlock = val;
|
|
|
+ emit cbBlockChanged(m_nCbBlock);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -1101,7 +1121,10 @@ int ImgUploadStatus::blockNr(void) const
|
|
|
void ImgUploadStatus::SetBlockNr(int val)
|
|
|
{
|
|
|
if(m_nBlockNr != val)
|
|
|
+ {
|
|
|
m_nBlockNr = val;
|
|
|
+ emit blockNrChanged(m_nBlockNr);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -1114,7 +1137,10 @@ int ImgUploadStatus::cbTotal(void) const
|
|
|
void ImgUploadStatus::setCbTotal(int val)
|
|
|
{
|
|
|
if(m_nCbTotal != val)
|
|
|
+ {
|
|
|
m_nCbTotal = val;
|
|
|
+ emit cbTotalChanged(m_nCbTotal);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -1127,11 +1153,14 @@ int ImgUploadStatus::cbSent(void) const
|
|
|
void ImgUploadStatus::setCbSent(int val)
|
|
|
{
|
|
|
if(m_nCbSent != val)
|
|
|
+ {
|
|
|
m_nCbSent = val;
|
|
|
+ emit cbSentChanged(m_nCbSent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
-
|
|
|
+
|
|
|
int ImgUploadStatus::percentSent(void) const
|
|
|
{
|
|
|
return m_nPercentSent;
|
|
@@ -1140,7 +1169,10 @@ int ImgUploadStatus::percentSent(void) const
|
|
|
void ImgUploadStatus::setPercentSent(int val)
|
|
|
{
|
|
|
if(m_nPercentSent != val)
|
|
|
+ {
|
|
|
m_nPercentSent = val;
|
|
|
+ emit percentSentChanged(m_nPercentSent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -1153,5 +1185,24 @@ int ImgUploadStatus::cntFlashPages(void) const
|
|
|
void ImgUploadStatus::setCntFlashPages(int val)
|
|
|
{
|
|
|
if(m_nCntFlashPages != val)
|
|
|
+ {
|
|
|
m_nCntFlashPages = val;
|
|
|
+ emit cntFlashPagesChanged(m_nCntFlashPages);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/////////////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+bool ImgUploadStatus::uploadInProgress(void) const
|
|
|
+{
|
|
|
+ return m_bUploadInProgress;
|
|
|
+}
|
|
|
+
|
|
|
+void ImgUploadStatus::setUploadInProgress(bool val)
|
|
|
+{
|
|
|
+ if(m_bUploadInProgress != val)
|
|
|
+ {
|
|
|
+ m_bUploadInProgress = val;
|
|
|
+ emit uploadInProgressChanged(m_bUploadInProgress);
|
|
|
+ }
|
|
|
}
|