Browse Source

LM Sensors added

pull/7/head
Evgeny Gagua 2 months ago
parent
commit
1728314d33
  1. 2
      Projects/la_mojo/build
  2. 2
      Projects/la_mojo/la_mojo.vpj
  3. 18
      Projects/la_mojo/makefile
  4. 6
      lib/App/common/SQLite_dataBinder.cpp
  5. 8
      lib/App/common/deviceNodeCamera.cpp
  6. 93
      lib/App/common/hardwareManager.cpp
  7. 2
      lib/App/common/kernelModuleEmbedVideo.h
  8. 14
      lib/data/media/video/videoAVLIBSource.cpp
  9. 8
      lib/data/media/video/videoLive555AVLibSource.cpp
  10. 3
      lib/data/media/video/videoLive555AVLibSource.h

2
Projects/la_mojo/build

@ -7,7 +7,7 @@
#make clean -e "CFG=LRF_Proxy_ONLY"
#make -e "CFG=LRF_Proxy_ONLY" -j$(nproc)
make clean -e "CFG=Debug86"
#make clean -e "CFG=Debug86"
make -e "CFG=Debug86" -j$(nproc)
#cd Debug86
#strip ./mojo_d

2
Projects/la_mojo/la_mojo.vpj

@ -371,7 +371,7 @@
<Lib File="-lgroupsock"/>
<Lib File="-lBasicUsageEnvironment"/>
<Lib File="-lUsageEnvironment"/>
<Lib File="-ldarknet"/>
<Lib File="-lsensors"/>
</Libs>
</Config>
<Config

18
Projects/la_mojo/makefile
File diff suppressed because it is too large
View File

6
lib/App/common/SQLite_dataBinder.cpp

@ -3307,15 +3307,15 @@ TARGET_SEGMENT * sqliteDBC::getRegisteredBubble(uint32_t ID)
REPORT_DIRINFO * sqliteDBC::getReportDirInfo(uint32_t id)
{
REPORT_DIRINFO * tVal = NULL;
if (m_bStaIsCreated)
{
if( !m_bStaIsCreated && m_bStaIsConnected ){
char tQBuf[CTEXT];
AAssoc * result;
sprintf(tQBuf, "SELECT * FROM `days` WHERE `ROWID`=%d", id);
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
result = m_pDataStorage->Query(tQBuf);
result = m_pDataStatistics->Query(tQBuf);
//result = m_pDataStorage->Query(tQBuf);
if (result != NULL)
{
if (result->size() > 0)

8
lib/App/common/deviceNodeCamera.cpp

@ -478,10 +478,14 @@ bool deviceNodeCamera::create()
{
sprintf(tURI, "http://%s%s", m_sCamData.ip, m_sCamData.onvif_ctrl);
};
LOG("PTZ BUILD URI");
LOG(tURI);
m_pProtocol = (protocolPTZ *) new protocolPTZ_ONVIF(tURI, m_sCamData.username, m_sCamData.password, m_sCamData.auth_mode);
}
else
{
LOG("USE FULL PTZ URI");
LOG(m_sCamData.onvif_ctrl);
m_pProtocol = (protocolPTZ *) new protocolPTZ_ONVIF(m_sCamData.onvif_ctrl, m_sCamData.username, m_sCamData.password, m_sCamData.auth_mode);
};
#ifdef DEBUG_EXTRA
@ -1267,10 +1271,14 @@ void deviceNodeCamera::m_fThreadProc(void)
{
sprintf(tURI, "http://%s%s", m_sCamData.ip, m_sCamData.onvif_ctrl);
};
LOG("PTZ URI CREATE");
LOG( tURI );
m_pProtocol = (protocolPTZ *) new protocolPTZ_ONVIF(tURI, m_sCamData.username, m_sCamData.password, m_sCamData.auth_mode);
}
else
{
LOG("PTZ USE");
LOG( m_sCamData.onvif_ctrl );
m_pProtocol = (protocolPTZ *) new protocolPTZ_ONVIF(m_sCamData.onvif_ctrl, m_sCamData.username, m_sCamData.password, m_sCamData.auth_mode);
};
#ifdef DEBUG_EXTRA

93
lib/App/common/hardwareManager.cpp

@ -1842,6 +1842,9 @@ DBC_INT_LIST * hardwareManager::requestResourcesByType(HARDWARE_PROVIDERS type)
#include <signal.h>
#include <sys/types.h>
#include <sensors/sensors.h>
#include <sensors/error.h>
bool hardwareManager::updateSysInfo(DBC_SYS_LOAD_INFO * ptr)
{
if (ptr == NULL)
@ -1903,36 +1906,28 @@ bool hardwareManager::updateSysInfo(DBC_SYS_LOAD_INFO * ptr)
};
// const uint32_t MB = 1 << 10;//(1024 * 1024);// * 1024;
if (statvfs("/", &DI) == 0)
{
if( statvfs("/", &DI) == 0 ){
ptr->T_DISK = (DI.f_blocks * (unsigned long long) DI.f_frsize) >> 10; // / MB;
// cDISK = ( DI.f_bavail * (unsigned long long) DI.f_bsize ) >> 10;// / MB;
ptr->C_DISK = ptr->T_DISK - ((DI.f_bfree * (unsigned long long) DI.f_bsize) >> 10);
ptr->disk = 100.0f * (float) ptr->C_DISK / (float) ptr->T_DISK;
}
else
{
} else {
LOG_ERROR("Error while getting Disk Info!");
};
// Temperature reading
ptr->temperature = -1;
if (fileExist("/sys/class/thermal"))
{
if (fileExist("/sys/class/thermal")){
char tB[128];
// Check first 8 zones to find CPU one
for (uint8_t i = 0; i < 8; i++)
{
for (uint8_t i = 0; i < 8; i++){
sprintf(tB, "/sys/class/thermal/thermal_zone%d", i);
if (fileExist(tB))
{
if (fileExist(tB)){
sprintf(tB, "/sys/class/thermal/thermal_zone%d/type", i);
if (fileExist(tB))
{
if (fileExist(tB)){
FILE * fd = fopen(tB, "r");
readLine(fd, tB, 128);
fclose(fd);
if (strcasestr(tB, "cpu") != NULL || strcasestr(tB, "x86_pkg") != NULL || strcasestr(tB, "acpitz") != NULL)
{
if (strcasestr(tB, "cpu") != NULL || strcasestr(tB, "x86_pkg") != NULL || strcasestr(tB, "acpitz") != NULL){
sprintf(tB, "/sys/class/thermal/thermal_zone%d/temp", i);
FILE * fd = fopen(tB, "r");
readLine(fd, tB, 128);
@ -1940,19 +1935,67 @@ bool hardwareManager::updateSysInfo(DBC_SYS_LOAD_INFO * ptr)
ptr->temperature = ((float) atoll(tB)) / 1000.0f;
break;
};
}
else
{
} else {
continue;
}
}
else
{
};
} else {
break;
}
};
};
};
};
if ( ptr->temperature < 0 ) {
//still have problem to read temp
// last chance -> use lm-sensors
if( sensors_init(nullptr) == 0 ) {
int chip_nr = 0;
const sensors_chip_name* chip;
// 2. Iterate through all detected sensor chips
while ((chip = sensors_get_detected_chips(nullptr, &chip_nr)) != nullptr) {
//char chip_name_buf[256];
//sensors_snprintf_chip_name(chip_name_buf, sizeof(chip_name_buf), chip);
//LOG( chip_name_buf );
//LOG( chip->prefix );
int feat_nr = 0;
const sensors_feature* feature;
// 3. Iterate through all features of the current chip
while ((feature = sensors_get_features(chip, &feat_nr)) != nullptr) {
// Filter strictly for Temperature Features
if (feature->type == SENSORS_FEATURE_TEMP) {
// Get the user-friendly label for this sensor (e.g., "Core 0", "CPU Temperature")
//char* label = sensors_get_label(chip, feature);
//LOG((label ? label : "Unknown"));
//if( label ) free( label ); // Must free the label returned by libsensors
// 4. Find the main subfeature containing the actual reading (input value)
const sensors_subfeature* subfeature = sensors_get_subfeature(chip, feature, SENSORS_SUBFEATURE_TEMP_INPUT);
if (subfeature != nullptr) {
double val = 0.0;
// 5. Inquiry the actual temperature reading
if ( sensors_get_value(chip, subfeature->number, &val) == 0 ) {
//char tB[128];
//sprintf( tB, "T: %0.3f °C", val );
//LOG( tB );
if ( val > 0.0 ) {
ptr->temperature = ( float ) val;
break;
};
} else {
LOG_ERROR("[Error reading value]");
};
} else {
LOG_ERROR("[No input channel found]");
};
};
};
if ( ptr->temperature > 0.0f ) {
break;
};
};
// 6. Clean up resources allocated by the library
sensors_cleanup();
};
};
return m_pDBC->updateServerUtilisation(ptr);
}

2
lib/App/common/kernelModuleEmbedVideo.h

@ -8,7 +8,7 @@
extern const char * m_pVideoScratchPath;
//#define EVE_WORK_WITH_MEDIAMTX
#define EVE_WORK_WITH_MEDIAMTX
#define EVE_OUTPUT_PICTURES 1
#define EVE_OUTPUT_VIDEO 2

14
lib/data/media/video/videoAVLIBSource.cpp

@ -286,7 +286,8 @@ bool videoAVLIBSource::_restart(void)
{
case AVLIB_SOURCE_DDSHOW:
{
AVInputFormat * iformat = av_find_input_format("dshow");
//const added for ffmpeg 60
const AVInputFormat * iformat = av_find_input_format("dshow");
if ((RetVal = avformat_open_input(&m_pVideoState->m_pFormatCtx, m_pVideoState->m_pFileName, iformat, &m_pVideoState->m_pFormatOpts)) != 0)
{
char tB[2048];
@ -379,7 +380,8 @@ bool videoAVLIBSource::_restart(void)
LOG("YABABA-2!");
#endif
/* find the video stream information */
m_pVideoState->m_iVideoStreamID = av_find_best_stream(m_pVideoState->m_pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &m_pVideoState->m_pVideoCodec, 0);
//cast ffmpeg 60
m_pVideoState->m_iVideoStreamID = av_find_best_stream(m_pVideoState->m_pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, const_cast<const AVCodec**>(&m_pVideoState->m_pVideoCodec), 0);
if (m_pVideoState->m_iVideoStreamID == -1)
{
@ -552,7 +554,7 @@ bool videoAVLIBSource::_open(char * URI, bool ShowDeviceMenu, float framerate, i
// av_dict_set(&m_pVideoState->m_pFormatOpts, "show_video_crossbar_connection_dialog", "true", 0);
// AVInputFormat * is Internal Const in CoDec Lib
AVInputFormat * iformat = av_find_input_format("dshow");
const AVInputFormat * iformat = av_find_input_format("dshow");
// av_dict_set(&options, "pixel_format", "bgr24", 0);
av_dict_set(&m_pVideoState->m_pFormatOpts, "timeout", "5000", 0);
// AVDeviceInfoList *device_list;
@ -745,7 +747,7 @@ bool videoAVLIBSource::_open(char * URI, bool ShowDeviceMenu, float framerate, i
LOG("YABABA-2!");
#endif
/* find the video stream information */
m_pVideoState->m_iVideoStreamID = av_find_best_stream(m_pVideoState->m_pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &m_pVideoState->m_pVideoCodec, 0);
m_pVideoState->m_iVideoStreamID = av_find_best_stream(m_pVideoState->m_pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, const_cast<const AVCodec**>(&m_pVideoState->m_pVideoCodec), 0);
if (m_pVideoState->m_iVideoStreamID == -1)
{
@ -804,12 +806,16 @@ bool videoAVLIBSource::_open(char * URI, bool ShowDeviceMenu, float framerate, i
return false;
};
//ffmpeg 6 removes AV_CODEC_CAP_TRUNCATED and AV_CODEC_FLAG_TRUNCATED
#if (LIBAVCODEC_VERSION_MAJOR >= 60 )
#else
/* we do not send complete frames */
if (m_pVideoState->m_pVideoCodec->capabilities & AV_CODEC_CAP_TRUNCATED)
{
m_pVideoState->m_pCodecCtx->flags |= AV_CODEC_CAP_TRUNCATED;
}
#endif // LIBAVCODEC_VERSION_MAJOR 60
#ifndef _NOAUDIO_
m_pVideoState->m_pAudioCtx = m_pVideoState->m_pFormatCtx->streams[m_pVideoState->m_iAudioStreamID]->codec;
m_pVideoState->m_pAudioCodec = avcodec_find_decoder(m_pVideoState->m_pAudioCtx->codec_id);

8
lib/data/media/video/videoLive555AVLibSource.cpp

@ -124,12 +124,13 @@ DummySink::DummySink(videoLIVE555Source * session, UsageEnvironment & env, Media
};
m_pCodecContext = avcodec_alloc_context3(m_pCodec);
#if (LIBAVCODEC_VERSION_MAJOR >= 60)
#else
if (m_pCodec->capabilities & AV_CODEC_CAP_TRUNCATED)
{
m_pCodecContext->flags |= AV_CODEC_FLAG_TRUNCATED; // we do not send complete frames
};
#endif // (LIBAVCODEC_VERSION_MAJOR >= 60)
if ((m_sSubSession.videoWidth() > 0) && (m_sSubSession.videoHeight() > 0))
{
m_nInWidth = m_sSubSession.videoWidth();
@ -171,7 +172,8 @@ DummySink::DummySink(videoLIVE555Source * session, UsageEnvironment & env, Media
if (m_pOutStream != NULL)
{
AVCodec *codec = avcodec_find_decoder( m_pOutStream->codecpar->codec_id );
// v60
const AVCodec *codec = avcodec_find_decoder( m_pOutStream->codecpar->codec_id );
AVCodecContext * c = avcodec_alloc_context3( codec );//m_pOutStream->codec;
c->codec_id = m_eCodecProbe;
c->codec_type = AVMEDIA_TYPE_VIDEO;

3
lib/data/media/video/videoLive555AVLibSource.h

@ -110,7 +110,8 @@ class DummySink : public MediaSink
H264or5VideoFileSink * qtOut;
FILE * m_pOutFile[2];
uint8_t m_nCurrentOutFile;
AVCodec * m_pCodec;
// const avlib v6
const AVCodec * m_pCodec;
AVCodecContext * m_pCodecContext;
AVCodec * m_pOutCodec;

Loading…
Cancel
Save