#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;
/**
* @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;
}
--- /dev/null
+#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_ */