aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorToni Uhlig <Toni.Uhlig@tq-group.com>2017-12-01 08:28:38 +0100
committerToni Uhlig <Toni.Uhlig@tq-group.com>2017-12-01 08:28:38 +0100
commit91bf72d7da36fe3883fd702d2bf1a74684d6b46a (patch)
treef327be2a11dd51f2441375e5f0f94967fc1ebf17 /src
parentce46de1eefb9f328421586a8efdbea755d3d0e62 (diff)
added firmware version check (compare current emc version with fw image version)
Diffstat (limited to 'src')
-rw-r--r--src/JobQueue.cpp14
-rw-r--r--src/UpdateTool.cpp5
2 files changed, 19 insertions, 0 deletions
diff --git a/src/JobQueue.cpp b/src/JobQueue.cpp
index 7615879..9310844 100644
--- a/src/JobQueue.cpp
+++ b/src/JobQueue.cpp
@@ -76,9 +76,23 @@ void WorkerThread::doJob()
job.m_Arg.jobid, job.m_Arg.update_file), m_ID);
uf.setUpdateFile(job.m_Arg.update_file.c_str());
rv = uf.loadUpdateFile();
+
+ if (uf.getFwVersion() == EMC_UNKNOWN) {
+ m_pQueue->Report(Job::eID_THREAD_MSG,
+ wxString::Format(wxT("Job #%d: Invalid firmware update file"),
+ job.m_Arg.jobid), m_ID);
+ break;
+ }
m_pQueue->Report(Job::eID_THREAD_MSG,
wxString::Format(wxT("Job #%d: Firmware image version: %s"),
job.m_Arg.jobid, mapEmcVersion(uf.getFwVersion())), m_ID);
+ if (!isEmcVersionLowerThen(uf.getEmcVersion(), uf.getFwVersion())) {
+ m_pQueue->Report(Job::eID_THREAD_MSGERR,
+ wxString::Format(wxT("Job #%d: Version mismatch (%s >= %s)"),
+ job.m_Arg.jobid, mapEmcVersion(uf.getEmcVersion()), mapEmcVersion(uf.getFwVersion())));
+ break;
+ }
+
if (rv != UPDATE_OK) {
mapEmcError(rv, err);
m_pQueue->Report(Job::eID_THREAD_MSGERR,
diff --git a/src/UpdateTool.cpp b/src/UpdateTool.cpp
index 58c8277..5f2ab1a 100644
--- a/src/UpdateTool.cpp
+++ b/src/UpdateTool.cpp
@@ -60,6 +60,11 @@ int main(int argc, char *argv[])
rv = u->loadUpdateFile();
std::cerr << "firmware version: " << mapEmcVersion(u->getFwVersion()) << std::endl;
if (rv == UPDATE_OK) {
+ if (!isEmcVersionLowerThen(u->getEmcVersion(), u->getFwVersion())) {
+ std::cerr << "version mismatch (" << mapEmcVersion(u->getEmcVersion())
+ << " >= " << mapEmcVersion(u->getFwVersion()) << ")" << std::endl;
+ continue;
+ }
std::cerr << "uploading file " << u->getUpdateFile() << std::endl;
rv = u->doUpdate();
if (rv == UPDATE_OK) {