Index: sources/ApplicationPost.cpp =================================================================== diff -u -r80b5e8f1ebb90c03c37d90d90cd2da3bd95d6803 -r7afdd47e30a761efd8ed08988f53337ea4e74ed6 --- sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision 80b5e8f1ebb90c03c37d90d90cd2da3bd95d6803) +++ sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision 7afdd47e30a761efd8ed08988f53337ea4e74ed6) @@ -38,6 +38,8 @@ { QString postLogFileName = QDir::tempPath() + "/" + Storage::POST_LOG; if (Storage::FileHandler::read(postLogFileName, _content)) { + + _isOSVersion = checkOSVersion (); _isShaSum = checkShaSum (); _isCANBus = checkCANBus (); _isDisplay = checkDisplay (); @@ -55,7 +57,9 @@ // although some are not failing the final result, // so they need to be assigned to a variable and then, AND(&&) them, // otherwise on the first fail rest of the checks will not run by compiler optimization. - _isDone = isShaSum () && + _isDone = + isOSVersion () && + isShaSum () && isCANBus () && isDisplay () && isTouch () && @@ -67,7 +71,7 @@ // isEthernet () && // it is being executed to get the information but is not part of the POST failure. // isSound () && isYearCheck () - ; + ; } else { // TODO: Ignored for now but this could be a FileSystem check failure, and the post.log has to always exist. @@ -78,10 +82,51 @@ } /*! - * \brief ApplicationPost::checkShaSum - * \details Checks the File System Integrity - * \return false if there is an issue [Not effects the UI Final POST result for now (always true)]. + * \brief ApplicationPost::checkOSVersion + * \details Checks the OS version + * \return false if the OS version is lower than 0.0.40 which is released for the Cybersecurity.. */ +bool ApplicationPost::checkOSVersion() +{ + QString exr("%1\\s*\"\\d+\\.\\d+\\.\\d+\""); + QRegExp reg(exr.arg(_postmsg_osversion)); + QString captured; + QStringList versions; + quint16 major; + quint16 minor; + quint16 micro; + + // check the statement exists in the long + int row = _content.indexOf (reg); + bool ok = row >= 0; // found + if ( ! ok ) goto lErr; + + // check the Os version is compatible + captured = reg.cap(0); // 0 is the first captured and next if any are the subsets. + versions = captured.replace(_postmsg_osversion,"").replace("\"","").split("."); + major = versions[0].toUInt(); // type, existance, count has been already tested by regex, and was rejected in first check section. + minor = versions[1].toUInt(); // type, existance, count has been already tested by regex, and was rejected in first check section. + micro = versions[2].toUInt(); // type, existance, count has been already tested by regex, and was rejected in first check section. + ok = major >= Storage::OS_VERSION_MAJOR && + minor >= Storage::OS_VERSION_MINOR && + micro >= Storage::OS_VERSION_MICRO ; + if ( ! ok ) goto lErr; + + // if ok then + emit didOSVersion(ok); + return ok; + +lErr: + emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_OS_VERSION); + emit didOSVersion(ok); + return ok; +} + +/*! + * \brief ApplicationPost::checkOSInfo + * \details Checks if the + * \return it is false if the + */ bool ApplicationPost::checkShaSum() { bool ok = _content.contains(_postmsg_shasum + _postmsg_postfix_passed); Index: sources/ApplicationPost.h =================================================================== diff -u -rec31f94081864aec8b48a3cfa1e0aea80619714c -r7afdd47e30a761efd8ed08988f53337ea4e74ed6 --- sources/ApplicationPost.h (.../ApplicationPost.h) (revision ec31f94081864aec8b48a3cfa1e0aea80619714c) +++ sources/ApplicationPost.h (.../ApplicationPost.h) (revision 7afdd47e30a761efd8ed08988f53337ea4e74ed6) @@ -58,33 +58,35 @@ QString _content; // WARNING: these variables has to match with the ones in the run.sh. - const QString _postmsg_postfix_passed = " passed" ; // POSTMSG_POSTFIX_PASSED=" passed" - const QString _postmsg_postfix_failed = " failed" ; // POSTMSG_POSTFIX_FAILED=" failed" + const QString _postmsg_postfix_passed = " passed" ; // POSTMSG_POSTFIX_PASSED=" passed" + const QString _postmsg_postfix_failed = " failed" ; // POSTMSG_POSTFIX_FAILED=" failed" - const QString _postmsg_canbus = "CANBus" ; // POSTMSG_CANBUS="CANBus" - const QString _postmsg_sdcard = "SD-CARD" ; // POSTMSG_SDCARD="SD-CARD" - const QString _postmsg_touch = "Touch" ; // POSTMSG_TOUCH="Touch" - const QString _postmsg_rtc = "RTC" ; // POSTMSG_RTC="RTC" - const QString _postmsg_wifi = "WiFi" ; // POSTMSG_WIFI="WiFi" - const QString _postmsg_bluetooth = "Bluetooth" ; // POSTMSG_BLUETOOTH="Bluetooth" - const QString _postmsg_shasum = "App shasum" ; // POSTMSG_SHASUM="App shasum" - const QString _postmsg_cloudsync = "CloudSync" ; // POSTMSG_CLOUDSYNC="CloudSync" + const QString _postmsg_osversion = "DIALITY_VERSION_ID=" ; // DIALITY_VERSION_ID="0.0.40" + const QString _postmsg_canbus = "CANBus" ; // POSTMSG_CANBUS="CANBus" + const QString _postmsg_sdcard = "SD-CARD" ; // POSTMSG_SDCARD="SD-CARD" + const QString _postmsg_touch = "Touch" ; // POSTMSG_TOUCH="Touch" + const QString _postmsg_rtc = "RTC" ; // POSTMSG_RTC="RTC" + const QString _postmsg_wifi = "WiFi" ; // POSTMSG_WIFI="WiFi" + const QString _postmsg_bluetooth = "Bluetooth" ; // POSTMSG_BLUETOOTH="Bluetooth" + const QString _postmsg_shasum = "App shasum" ; // POSTMSG_SHASUM="App shasum" + const QString _postmsg_cloudsync = "CloudSync" ; // POSTMSG_CLOUDSYNC="CloudSync" - const quint8 _macAddrssLen = 17 ; // ff:ff:ff:ff:ff:ff - const quint8 _macAppearLen = 200 ; // the mac address shall be found within the next 200 characters. - const QString _devEthernet = "eth0:" ; - const QString _devWireless = "wlan0:" ; - const QString _devBluetooth = "hci0:" ; - const QString _macEthernetLabel = "link/ether " ; // the last space is important - const QString _macWirelessLabel = "link/ether " ; // the last space is important - const QString _macBluetoothLabel = "BD Address: "; // the last space is important - QString _macEthernet = "" ; - QString _macWireless = "" ; - QString _macBluetooth = "" ; + const quint8 _macAddrssLen = 17 ; // ff:ff:ff:ff:ff:ff + const quint8 _macAppearLen = 200 ; // the mac address shall be found within the next 200 characters. + const QString _devEthernet = "eth0:" ; + const QString _devWireless = "wlan0:" ; + const QString _devBluetooth = "hci0:" ; + const QString _macEthernetLabel = "link/ether " ; // the last space is important + const QString _macWirelessLabel = "link/ether " ; // the last space is important + const QString _macBluetoothLabel = "BD Address: " ; // the last space is important + QString _macEthernet = "" ; + QString _macWireless = "" ; + QString _macBluetooth = "" ; - const int _yearMinimum = 2022 ; // The year to check for minimum + const int _yearMinimum = 2022 ; // The year to check for minimum // tests // Severity + bool _isOSVersion = false ; // HIGH: fault: ALARM_ID_HD_UI_POST_FAILURE_OS_VERSION bool _isShaSum = false ; // HIGH: fault: ALARM_ID_UI_POST_FAILURE_SHASUM bool _isCANBus = false ; // HIGH: fault: ALARM_ID_UI_POST_FAILURE_CANBUS bool _isDisplay = false ; // HIGH: fault: ALARM_ID_UI_POST_FAILURE_DISPLAY : Not known way to test, other than visual check @@ -100,6 +102,7 @@ bool _isDone = false ; + bool checkOSVersion (); bool checkShaSum (); bool checkCANBus (); bool checkDisplay (); @@ -114,6 +117,7 @@ bool checkYear (); public: + bool isOSVersion () const { return _isOSVersion ; } bool isShaSum () const { return _isShaSum ; } bool isCANBus () const { return _isCANBus ; } bool isDisplay () const { return _isDisplay ; } @@ -148,6 +152,7 @@ void start(); signals: + void didOSVersion (bool vPass); void didShaSum (bool vPass); void didCANBus (bool vPass); void didDisplay (bool vPass); Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -rcb0e2dc027adf7e0fbe803b82bb9945b82c556a5 -r7afdd47e30a761efd8ed08988f53337ea4e74ed6 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision cb0e2dc027adf7e0fbe803b82bb9945b82c556a5) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 7afdd47e30a761efd8ed08988f53337ea4e74ed6) @@ -38,6 +38,12 @@ const char *POST_LOG = "post.log"; // this file shall reside in the home folder where the application stored. + + // OS + const quint16 OS_VERSION_MAJOR = 0; // DIALITY_VERSION_ID="0.0.40" + const quint16 OS_VERSION_MINOR = 0; // DIALITY_VERSION_ID="0.0.40" + const quint16 OS_VERSION_MICRO = 40; // DIALITY_VERSION_ID="0.0.40" + // USB #ifdef BUILD_FOR_TARGET const char *USB_Mount_Point = "/media/usb/"; Index: sources/storage/StorageGlobals.h =================================================================== diff -u -rcb0e2dc027adf7e0fbe803b82bb9945b82c556a5 -r7afdd47e30a761efd8ed08988f53337ea4e74ed6 --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision cb0e2dc027adf7e0fbe803b82bb9945b82c556a5) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 7afdd47e30a761efd8ed08988f53337ea4e74ed6) @@ -27,6 +27,12 @@ // POST extern const char *POST_LOG; + + // OS VERSION + extern const quint16 OS_VERSION_MAJOR; + extern const quint16 OS_VERSION_MINOR; + extern const quint16 OS_VERSION_MICRO; + // USB extern const char *USB_Mount_Point; extern const char *USB_File_System;