From 9ec47b6b08179ddda0473019d0ffd8e8076a9e6d Mon Sep 17 00:00:00 2001 From: Evgeny Gagua Date: Wed, 21 Oct 2026 16:11:24 +0300 Subject: [PATCH] Fixed Sensor Error Handling --- lib/App/common/deviceNode2D.cpp | 4 ++-- lib/App/common/hardwareManager.cpp | 10 +++++++--- lib/App/common/hardwareManager.h | 2 ++ lib/App/common/kernelModuleBosch.cpp | 19 +++++++++++-------- lib/App/common/kernelModuleBosch.h | 1 + lib/App/serva/servaLifeMonitoring.cpp | 1 + lib/App/serva/servaLifeMonitoring.h | 1 + lib/components/base/basicFunctionality.cpp | 2 +- 8 files changed, 26 insertions(+), 14 deletions(-) diff --git a/lib/App/common/deviceNode2D.cpp b/lib/App/common/deviceNode2D.cpp index 7e6c57f5..ed522d2d 100644 --- a/lib/App/common/deviceNode2D.cpp +++ b/lib/App/common/deviceNode2D.cpp @@ -3923,11 +3923,11 @@ bool device2DSensor::packetHandler(protocolPackage * Package) { bEVT = createBasicEvent(m_sNodeData.node_id, m_eEventClass, EVT_ERR_LRF_NO_IRQ, NULL, NULL, NULL); } - else if ((Package->m_pData[cIDX + 2] & 0x02) == 0x04) + else if ((Package->m_pData[cIDX + 2] & 0x04) == 0x04) { bEVT = createBasicEvent(m_sNodeData.node_id, m_eEventClass, EVT_ERR_LRF_NO_ZERO, NULL, NULL, NULL); } - else if ((Package->m_pData[cIDX + 2] & 0x02) == 0x10) + else if ((Package->m_pData[cIDX + 2] & 0x10) == 0x10) { bEVT = createBasicEvent(m_sNodeData.node_id, m_eEventClass, EVT_ERR_LRF_VOLTAGE, NULL, NULL, NULL); }; diff --git a/lib/App/common/hardwareManager.cpp b/lib/App/common/hardwareManager.cpp index 8aa390dc..7bf71cb0 100644 --- a/lib/App/common/hardwareManager.cpp +++ b/lib/App/common/hardwareManager.cpp @@ -1842,8 +1842,10 @@ DBC_INT_LIST * hardwareManager::requestResourcesByType(HARDWARE_PROVIDERS type) #include #include -#include -#include +#ifdef USE_LMSENSORS + #include + #include +#endif bool hardwareManager::updateSysInfo(DBC_SYS_LOAD_INFO * ptr) { @@ -1942,7 +1944,8 @@ bool hardwareManager::updateSysInfo(DBC_SYS_LOAD_INFO * ptr) break; }; }; - }; + }; +#ifdef USE_LMSENSORS if ( ptr->temperature < 0 ) { //still have problem to read temp // last chance -> use lm-sensors @@ -1996,6 +1999,7 @@ bool hardwareManager::updateSysInfo(DBC_SYS_LOAD_INFO * ptr) sensors_cleanup(); }; }; +#endif //USE_LMSENSORS return m_pDBC->updateServerUtilisation(ptr); } diff --git a/lib/App/common/hardwareManager.h b/lib/App/common/hardwareManager.h index 50b1701b..597161ea 100644 --- a/lib/App/common/hardwareManager.h +++ b/lib/App/common/hardwareManager.h @@ -9,6 +9,8 @@ // #define MEMORY_CONSUMPTION_LIMIT (2147483648UL) // 2GB // #define MEMORY_CONSUMPTION_LIMIT (4294967296UL) // 4GB +//#define USE_LMSENSORS + class hardwareManager { private: diff --git a/lib/App/common/kernelModuleBosch.cpp b/lib/App/common/kernelModuleBosch.cpp index 07077d7e..c6335f37 100644 --- a/lib/App/common/kernelModuleBosch.cpp +++ b/lib/App/common/kernelModuleBosch.cpp @@ -189,8 +189,16 @@ bool kernelModuleBosch::buildTargetEventMsg( CSTR Buffer, float az, float range, uint8_t zid = bmvs_zones_count; if( pp!= NULL ) zid = atoi( pp+1 )-1; if ( zid > bmvs_zones_count ) zid = bmvs_zones_count; +#ifdef ZORRONET_PACKETS + sprintf(tTS, "%04d-%02d-%02dT%02d:%02d:%02dZ", 1900 + gmt_time->tm_year, 1 + gmt_time->tm_mon, gmt_time->tm_mday, gmt_time->tm_hour, gmt_time->tm_min, gmt_time->tm_sec); + sprintf( Buffer, "{\"azimuth\": %0.2f,\"distance\": %0.2f,\"name\": \"RADAR1_DFSL\",\"position\": {\"alt\": %0.2f,\"lat\": %0.8f,\"lon\": %0.8f},\"target_coordinates\": {\"alt\": %0.2f,\"lat\": %0.8f,\"lon\": %0.8f},\"timestamp\": \"%s\"}", + az, range, + alt, lat, lon, + alt, lat, lon, + tTS + ); +#else sprintf(tTS, "%04d-%02d-%02d %02d:%02d:%02d", 1900 + gmt_time->tm_year, 1 + gmt_time->tm_mon, gmt_time->tm_mday, gmt_time->tm_hour, gmt_time->tm_min, gmt_time->tm_sec); - //sprintf(tTS, "%04d-%02d-%02dT%02d:%02d:%02dZ", 1900 + gmt_time->tm_year, 1 + gmt_time->tm_mon, gmt_time->tm_mday, gmt_time->tm_hour, gmt_time->tm_min, gmt_time->tm_sec); sprintf( Buffer, "{\"externalAlarmId\":%d,\"data\":[%0.2f,%0.1f,%0.12f,%0.12f,%0.3f,10,\"%s\",\"%s\",\"%s\",\"Detection Event\"]}", m_sRestSettings.detection_src, az, range, @@ -199,12 +207,7 @@ bool kernelModuleBosch::buildTargetEventMsg( CSTR Buffer, float az, float range, bmvs_zones[zid], tTS ); - //sprintf( Buffer, "{\"azimuth\": %0.2f,\"distance\": %0.2f,\"name\": \"RADAR1_DFSL\",\"position\": {\"alt\": %0.2f,\"lat\": %0.8f,\"lon\": %0.8f},\"target_coordinates\": {\"alt\": %0.2f,\"lat\": %0.8f,\"lon\": %0.8f},\"timestamp\": \"%s\"}", - // az, range, - // alt, lat, lon, - // alt, lat, lon, - // tTS - //); +#endif return true; } @@ -231,7 +234,7 @@ bool kernelModuleBosch::dispatchEvent(EVENT_CONTAINER * Evt){ if( Evt == NULL ) return false; if( !m_bEnabled ) return true; - char tBuffer[1024]; + char tBuffer[4096]; char tURL[256]; #ifdef DEBUG_EXTRA diff --git a/lib/App/common/kernelModuleBosch.h b/lib/App/common/kernelModuleBosch.h index 3badb223..8b0f320a 100644 --- a/lib/App/common/kernelModuleBosch.h +++ b/lib/App/common/kernelModuleBosch.h @@ -8,6 +8,7 @@ #include "kernelModule.h" //#define DEBUG_BVMS_TRAFFIC +#define ZORRONET_PACKETS #ifndef CURL_MANAGER #define CURL_MANAGER diff --git a/lib/App/serva/servaLifeMonitoring.cpp b/lib/App/serva/servaLifeMonitoring.cpp index 63f4f2f2..f7e70a42 100644 --- a/lib/App/serva/servaLifeMonitoring.cpp +++ b/lib/App/serva/servaLifeMonitoring.cpp @@ -39,6 +39,7 @@ servaLifeMonitoring::servaLifeMonitoring():basicValidatable(),basicThread(){ tHZ->platform_id = *idx; uint8_t cid = 0; tHZ->lvl = 255; // To clean prev State + tHZ->validation_ts = getMilliseconds();//Set Next Validation Cycle for ( DBC_UINT64_LIST::iterator jdx = tML->begin(); jdx != tML->end(); jdx++ ) { tHZ->module_id[cid] = *jdx; tHZ->module_monitored[cid] = true; diff --git a/lib/App/serva/servaLifeMonitoring.h b/lib/App/serva/servaLifeMonitoring.h index 43bd5afe..d239b85a 100644 --- a/lib/App/serva/servaLifeMonitoring.h +++ b/lib/App/serva/servaLifeMonitoring.h @@ -15,6 +15,7 @@ typedef struct S_HEALTH_MONITORING_ZONE{ uint64_t platform_id; uint8_t lvl; uint64_t lvl_id; + uint64_t validation_ts; }HEALTH_MONITORING_ZONE; typedef std::vector V_HEALTH_MONITORING_ZONES; diff --git a/lib/components/base/basicFunctionality.cpp b/lib/components/base/basicFunctionality.cpp index b24b8223..f746693a 100644 --- a/lib/components/base/basicFunctionality.cpp +++ b/lib/components/base/basicFunctionality.cpp @@ -854,7 +854,7 @@ bool pingIP4(CSTR ip4) #ifdef USE_SYSTEM_CALL_TO_PING // Ping google.com once, redirect output to /dev/null, and check the return value char tB[256]; - sprintf(tB, "ping -c 1 %s > /dev/null 2>&1", ip4); + sprintf(tB, "ping -c 1 -W 0.5 -4 %s > /dev/null 2>&1", ip4); if (system(tB) == 0) { return true;