From 91bf72d7da36fe3883fd702d2bf1a74684d6b46a Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Fri, 1 Dec 2017 08:28:38 +0100 Subject: added firmware version check (compare current emc version with fw image version) --- src/JobQueue.cpp | 14 ++++++++++++++ src/UpdateTool.cpp | 5 +++++ 2 files changed, 19 insertions(+) (limited to 'src') 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) { -- cgit v1.2.3