* Moved telemetry_state_t declaration and SHM_KEY to new file telemetry.h.
authorUrban Wallasch <urban.wallasch@freenet.de>
Sun, 21 Jul 2019 17:26:42 +0000 (19:26 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Sun, 21 Jul 2019 17:26:42 +0000 (19:26 +0200)
shmget.c
telemetry.cpp
telemetry.h [new file with mode: 0644]

index 690e8695bb3b557cedd09d99150c63575c6a8b43..2a29955ec10cc9d184ba2415b89ed5314f198d27 100644 (file)
--- a/shmget.c
+++ b/shmget.c
 #include "fserv.h"
 #include "net.h"
 #include "log.h"
+#include "telemetry.h"
 
-
-#define SHM_KEY 0xecc11
-
-typedef uint64_t               scs_timestamp_t;
-
-struct telemetry_state_t
-{
-    scs_timestamp_t timestamp;
-    scs_timestamp_t raw_rendering_timestamp;
-    scs_timestamp_t raw_simulation_timestamp;
-    scs_timestamp_t raw_paused_simulation_timestamp;
-
-    bool    orientation_available;
-    float   heading;
-    float   pitch;
-    float   roll;
-
-    float   speed;
-    float   rpm;
-    int gear;
-    float   cc; //cruise_control
-    float fc_avg; //fuel consumption average
-} *telemetry;
+struct telemetry_state_t *telemetry;
 
 static volatile int force_quit;
 
index cbc1f51d6ffb64ac9710ed6afc0e322db8b77a88..39db1be0c3f71f40f91c0e2fe2c770c18eee076a 100644 (file)
@@ -54,40 +54,22 @@ scs_timestamp_t last_timestamp = static_cast<scs_timestamp_t>(-1);
 /**
  * @brief Combined telemetry data.
  */
-struct telemetry_state_t
-{
-       scs_timestamp_t timestamp;
-       scs_timestamp_t raw_rendering_timestamp;
-       scs_timestamp_t raw_simulation_timestamp;
-       scs_timestamp_t raw_paused_simulation_timestamp;
-
-       bool    orientation_available;
-       float   heading;
-       float   pitch;
-       float   roll;
-
-       float   speed;
-       float   rpm;
-       int     gear;
-       float   cc; //cruise_control
-    float fc_avg; //fuel consumption average
 
-} *telemetry;
+#include "telemetry.h"
+struct telemetry_state_t *telemetry;
 
 /**
  * @brief Function writting message to the game internal log.
  */
 
 static int shmid = -1;
-#define KEY 0xecc11
-// Management of the log file.
 
 bool init_log(void)
 {
        if (shmid > 0) {
                return true;
        }
-    shmid = shmget (KEY, sizeof (struct telemetry_state_t),  IPC_CREAT | IPC_EXCL | 0600);
+    shmid = shmget (SHM_KEY, sizeof (struct telemetry_state_t),  IPC_CREAT | IPC_EXCL | 0600);
     telemetry = static_cast<struct telemetry_state_t *>(shmat (shmid, NULL, 0));
        return true;
 }
diff --git a/telemetry.h b/telemetry.h
new file mode 100644 (file)
index 0000000..b9e5f70
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef TELEMETRY_H_
+#define TELEMETRY_H_
+
+#define SHM_KEY 0xecc11
+
+struct telemetry_state_t {
+    uint64_t timestamp;
+    uint64_t raw_rendering_timestamp;
+    uint64_t raw_simulation_timestamp;
+    uint64_t raw_paused_simulation_timestamp;
+
+    bool    orientation_available;
+    float   heading;
+    float   pitch;
+    float   roll;
+
+    float   speed;
+    float   rpm;
+    int     gear;
+    float   cc;         // cruise_control
+    float   fc_avg;     // fuel consumption average
+};
+
+#endif /* TELEMETRY_H_ */