diff --git a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp index 4650fbe639867b1965cb285dba64638b2b550ddd..422d2a163ec5289c086e3a60aa318b04895e0eeb 100644 --- a/sensor/hdi_service_3.0/sensor_callback_vdi.cpp +++ b/sensor/hdi_service_3.0/sensor_callback_vdi.cpp @@ -206,6 +206,10 @@ void SensorCallbackVdi::PrintCount(const SensorHandle& sensorHandle, lastRecordTime += std::chrono::milliseconds(ONE_SECOND); lastDataCount = currentDataCount; + if (std::chrono::duration_cast(currentTime - lastRecordTime).count() >= ONE_SECOND) { + lastRecordTime = currentTime; // Reset lastRecordTime if it exceeds one second + return; + } if (perSecondCount >= targetCount - acceptablError && perSecondCount <= targetCount + acceptablError) { return; // Skip logging if the count is within acceptable range }