]> git.vomp.tv Git - vompclient.git/commitdiff
Created basic telemetry system
authorChris Tallon <chris@vomp.tv>
Tue, 21 May 2024 20:14:02 +0000 (20:14 +0000)
committerChris Tallon <chris@vomp.tv>
Tue, 21 May 2024 20:14:02 +0000 (20:14 +0000)
src/CMakeLists.txt
src/control.cc
src/telem.cc [new file with mode: 0644]
src/telem.h [new file with mode: 0644]

index b1f0dda3d477de6a958f9faf1e5c40eabf87a3d3..63115d7b9f7862c69862edd335a35c753879fb05 100644 (file)
@@ -23,7 +23,7 @@ set (VOMP_OBJ_COMMON
        wmovieview.cc wseriesview.cc wtvmedia.cc wpictureview.cc
        osdvector.cc surfacevector.cc buffer.cc config.cc log.cc
        playervideorec.cc playervideolive.cc playerradiolive.cc playerradiorec.cc
-       imageloader.cc image.cc
+       imageloader.cc image.cc telem.cc
 )
 
 set (VOMP_OBJ_RASPBERRY
index 589174d31c36f6f88c9d46464456274aa99f52e8..4a55880f9922e0d2f95d81df331ba95e9cdbcdf0 100644 (file)
@@ -35,6 +35,7 @@
 #include "inputandroid.h"
 #endif
 
+#include "telem.h"
 #include "led.h"
 #include "video.h"
 #include "audio.h"
@@ -114,6 +115,8 @@ bool Control::init(bool tcrashed)
   crashed = tcrashed;
   logger = LogNT::getInstance();
 
+  Telemetry::init();
+
   SkinFactory::InitSkin(0);
 
   // FIXME All constructors first which do very little & don't rely on presence of other objects.
diff --git a/src/telem.cc b/src/telem.cc
new file mode 100644 (file)
index 0000000..75fb98f
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+    Copyright 2024 Chris Tallon
+
+    This file is part of VOMP.
+
+    VOMP is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    VOMP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "log.h"
+
+#include "telem.h"
+
+UDP4 Telemetry::udp;
+
+void Telemetry::init()
+{
+#if TELEM_ENABLED
+  LogNT::getInstance()->debug("Telem", "Init");
+  udp.init(0);
+
+  // TODO load target IP / port from config
+
+#endif
+}
+
+void Telemetry::message(u4 messageNumber, i4 data)
+{
+  char* buffer;
+  asprintf(&buffer, "%c%c%c%c%i", 1, 1, 1, 1, data);
+  memcpy(buffer, (const void*)&messageNumber, 4);
+  udp.send("", 7777, buffer, strlen(&buffer[4])+4);
+  free(buffer);
+}
+
+void Telemetry::message(u4 messageNumber, i8 data)
+{
+  char* buffer;
+  asprintf(&buffer, "%c%c%c%c%lli", 1, 1, 1, 1, data);
+  memcpy(buffer, (const void*)&messageNumber, 4);
+  udp.send("", 7777, buffer, strlen(&buffer[4])+4);
+  free(buffer);
+}
+
+void Telemetry::message(u4 messageNumber, u8 data)
+{
+  char* buffer;
+  asprintf(&buffer, "%c%c%c%c%llu", 1, 1, 1, 1, data);
+  memcpy(buffer, (const void*)&messageNumber, 4);
+  udp.send("", 7777, buffer, strlen(&buffer[4])+4);
+  free(buffer);
+}
+
diff --git a/src/telem.h b/src/telem.h
new file mode 100644 (file)
index 0000000..a6b605d
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+    Copyright 2024 Chris Tallon
+
+    This file is part of VOMP.
+
+    VOMP is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    VOMP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+#ifndef TELEM_H
+#define TELEM_H
+
+#define TELEM_ENABLED 1
+
+#include "defines.h"
+
+#include "udp4.h"
+
+
+class Telemetry
+{
+  public:
+    static void init();
+    static void message(u4 messageNumber, i4 data);
+    static void message(u4 messageNumber, i8 data);
+    static void message(u4 messageNumber, u8 data);
+
+  private:
+    static UDP4 udp;
+};
+
+#if TELEM_ENABLED
+  #define TELEM(x, y) Telemetry::message(x, y)
+#else
+  #define TELEM(x, y)
+#endif
+
+
+
+#endif