Paparazzi UAS  v5.15_devel-202-ge01e8fc
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fg.c
Go to the documentation of this file.
1 
3 #include <string.h>
4 #include <caml/alloc.h>
5 #include <caml/mlvalues.h>
6 #include <caml/memory.h>
7 
8 #include <math.h>
9 #include <time.h>
10 
11 #include "flight_gear.h"
12 
13 value fg_sizeof(value unit) {
14  return Val_int(sizeof(struct FGNetGUI));
15 }
16 
17 value fg_msg_native(value s, value lat, value lon, value z, value phi, value theta, value psi);
18 
19 value fg_msg_bytecode(value *argv, int argc) {
20  return fg_msg_native(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
21 
22 }
23 
24 
25 value fg_msg_native(value s, value lat, value lon, value z, value phi, value theta, value psi) {
26 
27  struct FGNetGUI msg = {0};
29 
30  msg.longitude = Double_val(lon);
31  msg.latitude = Double_val(lat);
32  msg.altitude = Double_val(z) + 50;
33  msg.agl = 0.;
34  msg.phi = Double_val(phi);
35  msg.theta = Double_val(theta);
36  msg.psi = - Double_val(psi) + M_PI_2;
37 
38  msg.vcas = 0.;
39  msg.climb_rate = 0.;
40 
41  msg.num_tanks = 1;
42  msg.fuel_quantity[0] = 10.;
43 
44  msg.cur_time = 3213092700ul+((uint32_t)((msg.longitude)*13578)); //time(NULL);
45  msg.warp = 0;
46  msg.ground_elev = 0.;
47 
48  msg.tuned_freq = 123.45;
49  msg.nav_radial = 123.;
50  msg.in_range = 1;
51  msg.course_deviation_deg = 12.;
52  msg.gs_deviation_deg = 123.;
53 
54  memcpy(String_val(s), (char*)&msg, sizeof(msg));
55 
56  return Val_unit;
57 }
float climb_rate
Definition: flight_gear.h:267
uint32_t num_tanks
Definition: flight_gear.h:270
static uint32_t s
value fg_sizeof(value unit)
Values boxing for Flight Gear.
Definition: fg.c:13
float altitude
Definition: flight_gear.h:259
float vcas
Definition: flight_gear.h:266
uint32_t cur_time
Definition: flight_gear.h:274
float phi
Definition: flight_gear.h:261
#define FG_NET_GUI_VERSION
Definition: flight_gear.h:231
value fg_msg_bytecode(value *argv, int argc)
Definition: fg.c:19
uint32_t warp
Definition: flight_gear.h:276
float nav_radial
Definition: flight_gear.h:281
uint32_t version
Definition: flight_gear.h:253
float fuel_quantity[FG_NET_GUI_MAX_TANKS]
Definition: flight_gear.h:271
float ground_elev
Definition: flight_gear.h:277
float theta
Definition: flight_gear.h:262
float agl
Definition: flight_gear.h:260
float tuned_freq
Definition: flight_gear.h:280
unsigned long uint32_t
Definition: types.h:18
float psi
Definition: flight_gear.h:263
value fg_msg_native(value s, value lat, value lon, value z, value phi, value theta, value psi)
Definition: fg.c:25
float gs_deviation_deg
Definition: flight_gear.h:285
uint32_t in_range
Definition: flight_gear.h:282
double latitude
Definition: flight_gear.h:258
double longitude
Definition: flight_gear.h:257
float course_deviation_deg
Definition: flight_gear.h:284