From 9959ae8e6b703a4ebc3af3f5f9f22e507665224a Mon Sep 17 00:00:00 2001 From: Steffen Pohle Date: Sun, 8 Nov 2026 10:33:25 +0100 Subject: [PATCH] enable debugging output --- configuration.cc | 8 ++++++++ configuration.h | 3 ++- main.cc | 1 + videodevice_v4l2.cc | 8 +++++--- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/configuration.cc b/configuration.cc index d571d4b..5b16dd0 100644 --- a/configuration.cc +++ b/configuration.cc @@ -44,6 +44,7 @@ Configuration::Configuration() { web_height = -1; web_width = -1; web_imagerefresh = 250; + debug = 0; filter_ratio = 0.5; }; @@ -75,6 +76,7 @@ int Configuration::PrintConfig() { jp.AddObject("web-size" , to_string(web_width) + "x" + to_string(web_height)); jp.AddObject("web-refresh", web_imagerefresh); jp.AddObject("vdev-dumpath", vdev_dumppath); + jp.AddObject("debug", debug); // // output the json string @@ -124,6 +126,7 @@ int Configuration::LoadFile(std::string fn) { if (get_resolution(s.c_str(), &vdev_width, &vdev_height) == 0) { debug ("Configfile: %s Wrong vdev-size: %s", fn.c_str(), s.c_str()); } + if (jp.GetValueInt("debug", &i)) debug = i; // // restore language @@ -138,6 +141,9 @@ int Configuration::LoadArgs(int argc, char **argv) { if (strcmp(argv[i], "-F") == 0) runasdaemon = 0; if (strcmp(argv[i], "-D") == 0) runasdaemon = 1; + if (strcmp(argv[i], "-debug") == 0) debug = 1; + if (strcmp(argv[i], "-debug_off") == 0) debug = 0; + if (strcmp(argv[i], "-dump_config") == 0) initflags |= CONF_INITFLAGS_PRINT; if (strcmp(argv[i], "-config") == 0) { if (++i < argc) { @@ -253,6 +259,8 @@ void Configuration::Help() { printf ("Parameters:\n"); printf (" -F run in foreground\n"); printf (" -D run as daemon\n"); + printf (" -debug enable debug output\n"); + printf (" -debug_off disable debug output\n"); printf ("\n"); printf (" -http_port INT port to listen for http connections\n"); printf (" -https_port INT port to listen for https connections\n"); diff --git a/configuration.h b/configuration.h index 76efa5c..9828c8e 100644 --- a/configuration.h +++ b/configuration.h @@ -26,6 +26,7 @@ class Configuration { private: public: + int debug; int http_port; int https_port; std::string ssl_key; @@ -33,7 +34,7 @@ public: int runasdaemon; std::string filename; int initflags; - + int web_height; int web_width; int web_imagerefresh; diff --git a/main.cc b/main.cc index e795018..4d33f48 100644 --- a/main.cc +++ b/main.cc @@ -134,6 +134,7 @@ int main(int argc, char **argv) { config.Help(); return 0; } + debug_enable(config.debug); pthread_create(&thr_webserver, NULL, &thread_webserver, NULL); pthread_create(&thr_video, NULL, &thread_video, NULL); diff --git a/videodevice_v4l2.cc b/videodevice_v4l2.cc index 54f73e4..166d85a 100644 --- a/videodevice_v4l2.cc +++ b/videodevice_v4l2.cc @@ -189,12 +189,14 @@ int VideoDevice_V4L2::Open() { // init buffers switch (conf_iomode) { case IOMODE_MMAP: + debug ("setup MMap (memory mapping)"); if (InitMMap() == 0) { debug ("could not setup MMap (memory mapping)"); Close(); } break; case IOMODE_READ: + debug ("setup Read (read())"); for (i = 0; i < VDEV_INBUFFERS; i++) { inbuffer[i].size = fmt.fmt.pix.sizeimage; inbuffer[i].data = (unsigned char*) malloc (fmt.fmt.pix.sizeimage); @@ -417,7 +419,7 @@ int VideoDevice_V4L2::GetFrame(VideoFrame *destframe, VideoFrameFloat *destfloat return -1; case EIO: default: - debug ("v4l2_grab IOM_READ: %s dest:%p size:%d", strerror (errno), destframe, fmt.fmt.pix.sizeimage); + debugerror ("v4l2_grab IOM_READ: %s dest:%p size:%d", strerror (errno), destframe, fmt.fmt.pix.sizeimage); return 0; } } @@ -442,11 +444,11 @@ int VideoDevice_V4L2::GetFrame(VideoFrame *destframe, VideoFrameFloat *destfloat return -1; case EIO: - debug ("error on VIDIOC_DQBUF EIO %s", strerror(errno)); + debugerror ("error on VIDIOC_DQBUF EIO %s", strerror(errno)); return 0; default: - debug ("error on VIDIOC_DQBUF %s", strerror(errno)); + debugerror ("error on VIDIOC_DQBUF %s", strerror(errno)); return 0; } }