Skip to content

Commit

Permalink
Reset/V4L2/Systemd/rpi_ws281x/Profiler (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulchen-Panther committed Jun 17, 2020
1 parent 756247a commit aa55edf
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "dependencies/external/rpi_ws281x"]
path = dependencies/external/rpi_ws281x
url = https://github.com/hyperion-project/rpi_ws281x.git
url = https://github.com/jgarff/rpi_ws281x
branch = master
[submodule "dependencies/external/flatbuffers"]
path = dependencies/external/flatbuffers
Expand All @@ -9,4 +9,4 @@
[submodule "dependencies/external/protobuf"]
path = dependencies/external/protobuf
url = https://github.com/hyperion-project/protobuf.git
branch = master
branch = master
2 changes: 1 addition & 1 deletion cmake/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ install_file()
echo "---Hyperion ambient light postinstall ---"

#check system
CPU_RPI=`grep -m1 -c 'BCM2708\|BCM2709\|BCM2710\|BCM2835' /proc/cpuinfo`
CPU_RPI=`grep -m1 -c 'BCM2708\|BCM2709\|BCM2710\|BCM2835\|BCM2836\|BCM2837\|BCM2711' /proc/cpuinfo`
CPU_X32X64=`uname -m | grep 'x86_32\|i686\|x86_64' | wc -l`

#Check for a bootloader as Berryboot
Expand Down
2 changes: 1 addition & 1 deletion dependencies/external/rpi_ws281x
Submodule rpi_ws281x updated 2 files
+1 −1 SConscript
+27 −4 rpihw.c
26 changes: 21 additions & 5 deletions include/utils/Profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,30 @@
#include <utils/Logger.h>
#include <HyperionConfig.h>

/*
The performance (real time) of any function can be tested with the help of profiler.
The determined times are determined using clock cycles.
To do this, compile with the cmake option: -DENABLE_PROFILER=ON
This header file (utils/Profiler.h) must be included in the respective file that contains the function to be measured
The start time is set in a function with the following instructions:
PROFILER_TIMER_START("test_performance")
The end point is set as follows:
PROFILER_TIMER_GET("test_performance")
For more profiler function see the macros listed below
*/

#ifndef ENABLE_PROFILER
#error "Profiler is not for productive code, enable it via cmake or remove header include"
#endif

// profiler
#define PROFILER_BLOCK_EXECUTION_TIME Profiler DEBUG_PROFILE__BLOCK__EXECUTION__TIME_messure_object(__FILE__, _FUNCNAME_, __LINE__ );
#define PROFILER_TIMER_START(stopWatchName) Profiler::TimerStart(stopWatchName, __FILE__, _FUNCNAME_, __LINE__);
#define PROFILER_TIMER_GET(stopWatchName) Profiler::TimerGetTime(stopWatchName, __FILE__, _FUNCNAME_, __LINE__);
#define PROFILER_TIMER_GET_IF(condition, stopWatchName) { if (condition) {Profiler::TimerGetTime(stopWatchName, __FILE__, _FUNCNAME_, __LINE__);} }
#define PROFILER_BLOCK_EXECUTION_TIME Profiler DEBUG_PROFILE__BLOCK__EXECUTION__TIME_messure_object(__FILE__, __FUNCTION__, __LINE__ );
#define PROFILER_TIMER_START(stopWatchName) Profiler::TimerStart(stopWatchName, __FILE__, __FUNCTION__, __LINE__);
#define PROFILER_TIMER_GET(stopWatchName) Profiler::TimerGetTime(stopWatchName, __FILE__, __FUNCTION__, __LINE__);
#define PROFILER_TIMER_GET_IF(condition, stopWatchName) { if (condition) {Profiler::TimerGetTime(stopWatchName, __FILE__, __FUNCTION__, __LINE__);} }


class Profiler
Expand All @@ -27,11 +42,12 @@ class Profiler

private:
static void initLogger();

static Logger* _logger;
const char* _file;
const char* _func;
unsigned int _line;
unsigned int _blockId;
clock_t _startTime;
};

12 changes: 2 additions & 10 deletions libsrc/grabber/v4l2/V4L2Grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,8 @@ void V4L2Grabber::getV4Ldevices()
break;
case V4L2_FRMSIZE_TYPE_CONTINUOUS:
case V4L2_FRMSIZE_TYPE_STEPWISE:
{
for(unsigned int y = frmsizeenum.stepwise.min_height; y <= frmsizeenum.stepwise.max_height; y += frmsizeenum.stepwise.step_height)
{
for(unsigned int x = frmsizeenum.stepwise.min_width; x <= frmsizeenum.stepwise.max_width; x += frmsizeenum.stepwise.step_width)
{
properties.resolutions << QString::number(x) + "x" + QString::number(y);
enumFrameIntervals(properties.framerates, fd, fmt.fmt.pix.pixelformat, x, y);
}
}
}
// We do not take care of V4L2_FRMSIZE_TYPE_CONTINUOUS or V4L2_FRMSIZE_TYPE_STEPWISE
break;
}
frmsizeenum.index++;
}
Expand Down
15 changes: 15 additions & 0 deletions src/hyperiond/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ int main(int argc, char** argv)
BooleanOption & versionOption = parser.add<BooleanOption> (0x0, "version", "Show version information");
Option & userDataOption = parser.add<Option> ('u', "userdata", "Overwrite user data path, defaults to home directory of current user (%1)", QDir::homePath() + "/.hyperion");
BooleanOption & resetPassword = parser.add<BooleanOption> (0x0, "resetPassword", "Lost your password? Reset it with this option back to 'hyperion'");
BooleanOption & deleteDB = parser.add<BooleanOption> (0x0, "deleteDatabase", "Start all over? This Option will delete the database");
BooleanOption & silentOption = parser.add<BooleanOption> ('s', "silent", "do not print any outputs");
BooleanOption & verboseOption = parser.add<BooleanOption> ('v', "verbose", "Increase verbosity");
BooleanOption & debugOption = parser.add<BooleanOption> ('d', "debug", "Show debug messages");
Expand Down Expand Up @@ -300,6 +301,20 @@ int main(int argc, char** argv)
}
}

// delete database before start
if(parser.isSet(deleteDB))
{
QString dbFile = mDir.absolutePath() + "/db/hyperion.db";
if (QFile::exists(dbFile))
{
if (!QFile::remove(dbFile))
{
Info(log,"Failed to delete Database!");
exit(1);
}
}
}

HyperionDaemon* hyperiond = nullptr;
try
{
Expand Down

0 comments on commit aa55edf

Please sign in to comment.