updated the structures.
if ( net_byte_order ) {
// convert to network byte order
- net->version = htons(net->version);
+ net->version = htonl(net->version);
htond(net->aileron);
htond(net->elevator);
htond(net->rudder);
htond(net->elevator_trim);
htond(net->rudder_trim);
htond(net->flaps);
+ net->flaps_power = htonl(net->flaps_power);
+ net->flap_motor_ok = htonl(net->flap_motor_ok);
for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) {
+ net->master_bat[i] = htonl(net->master_bat[i]);
+ net->master_alt[i] = htonl(net->master_alt[i]);
+ net->magnetos[i] = htonl(net->magnetos[i]);
+ net->starter_power[i] = htonl(net->starter_power[i]);
htond(net->throttle[i]);
htond(net->mixture[i]);
+ net->fuel_pump_power[i] = htonl(net->fuel_pump_power[i]);
htond(net->prop_advance[i]);
htond(net->condition[i]);
+ net->engine_ok[i] = htonl(net->engine_ok[i]);
+ net->mag_left_ok[i] = htonl(net->mag_left_ok[i]);
+ net->mag_right_ok[i] = htonl(net->mag_right_ok[i]);
+ net->spark_plugs_ok[i] = htonl(net->spark_plugs_ok[i]);
+ net->oil_press_status[i] = htonl(net->oil_press_status[i]);
+ net->fuel_pump_ok[i] = htonl(net->fuel_pump_ok[i]);
}
+ net->num_engines = htonl(net->num_engines);
+ for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) {
+ net->fuel_selector[i] = htonl(net->fuel_selector[i]);
+ }
+ net->num_tanks = htonl(net->num_tanks);
+ net->cross_feed = htonl(net->cross_feed);
htond(net->brake_left);
htond(net->brake_right);
htond(net->copilot_brake_left);
htond(net->copilot_brake_right);
htond(net->brake_parking);
+ net->gear_handle = htonl(net->gear_handle);
+ net->master_avionics = htonl(net->master_avionics);
htond(net->wind_speed_kt);
htond(net->wind_dir_deg);
htond(net->turbulence_norm);
htond(net->press_inhg);
htond(net->hground);
htond(net->magvar);
+ net->icing = htonl(net->icing);
+ net->speedup = htonl(net->speedup);
+ net->freeze = htonl(net->freeze);
}
}
if ( net_byte_order ) {
// convert from network byte order
- net->version = htons(net->version);
+ net->version = htonl(net->version);
htond(net->aileron);
htond(net->elevator);
htond(net->rudder);
htond(net->elevator_trim);
htond(net->rudder_trim);
htond(net->flaps);
- for ( i = 0; i < net->num_engines; ++i ) {
+ net->flaps_power = htonl(net->flaps_power);
+ net->flap_motor_ok = htonl(net->flap_motor_ok);
+ net->num_engines = htonl(net->num_engines);
+ for ( i = 0; i < (int)net->num_engines; ++i ) {
+ net->master_bat[i] = htonl(net->master_bat[i]);
+ net->master_alt[i] = htonl(net->master_alt[i]);
+ net->magnetos[i] = htonl(net->magnetos[i]);
+ net->starter_power[i] = htonl(net->starter_power[i]);
htond(net->throttle[i]);
htond(net->mixture[i]);
+ net->fuel_pump_power[i] = htonl(net->fuel_pump_power[i]);
htond(net->prop_advance[i]);
htond(net->condition[i]);
+ net->engine_ok[i] = htonl(net->engine_ok[i]);
+ net->mag_left_ok[i] = htonl(net->mag_left_ok[i]);
+ net->mag_right_ok[i] = htonl(net->mag_right_ok[i]);
+ net->spark_plugs_ok[i] = htonl(net->spark_plugs_ok[i]);
+ net->oil_press_status[i] = htonl(net->oil_press_status[i]);
+ net->fuel_pump_ok[i] = htonl(net->fuel_pump_ok[i]);
+ }
+ net->num_tanks = htonl(net->num_tanks);
+ for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) {
+ net->fuel_selector[i] = htonl(net->fuel_selector[i]);
}
+ net->cross_feed = htonl(net->cross_feed);
htond(net->brake_left);
htond(net->brake_right);
htond(net->copilot_brake_left);
htond(net->copilot_brake_right);
htond(net->brake_parking);
+ net->gear_handle = htonl(net->gear_handle);
+ net->master_avionics = htonl(net->master_avionics);
htond(net->wind_speed_kt);
htond(net->wind_dir_deg);
htond(net->turbulence_norm);
htond(net->press_inhg);
htond(net->hground);
htond(net->magvar);
+ net->icing = htonl(net->icing);
+ net->speedup = htonl(net->speedup);
+ net->freeze = htonl(net->freeze);
}
if ( net->version != FG_NET_CTRLS_VERSION ) {
void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
- int i;
+ unsigned int i;
// Version sanity checking
net->version = FG_NET_FDM_VERSION;
if ( net_byte_order ) {
// Convert the net buffer to network format
- net->version = htons(net->version);
+ net->version = htonl(net->version);
htond(net->longitude);
htond(net->latitude);
htonf(net->stall_warning);
htonf(net->slip_deg);
+ net->num_engines = htonl(net->num_engines);
for ( i = 0; i < net->num_engines; ++i ) {
+ net->eng_state[i] = htonl(net->eng_state[i]);
htonf(net->rpm[i]);
htonf(net->fuel_flow[i]);
htonf(net->egt[i]);
htonf(net->oil_px[i]);
}
+ net->num_tanks = htonl(net->num_tanks);
for ( i = 0; i < net->num_tanks; ++i ) {
htonf(net->fuel_quantity[i]);
}
+ net->num_wheels = htonl(net->num_wheels);
for ( i = 0; i < net->num_wheels; ++i ) {
+ net->wow[i] = htonl(net->wow[i]);
htonf(net->gear_pos[i]);
htonf(net->gear_steer[i]);
htonf(net->gear_compression[i]);
void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
- int i;
+ unsigned int i;
if ( net_byte_order ) {
// Convert to the net buffer from network format
- net->version = ntohs(net->version);
+ net->version = ntohl(net->version);
htond(net->longitude);
htond(net->latitude);
htonf(net->slip_deg);
for ( i = 0; i < net->num_engines; ++i ) {
+ net->eng_state[i] = htonl(net->eng_state[i]);
htonf(net->rpm[i]);
htonf(net->fuel_flow[i]);
htonf(net->egt[i]);
htonf(net->oil_temp[i]);
htonf(net->oil_px[i]);
}
+ net->num_engines = htonl(net->num_engines);
for ( i = 0; i < net->num_tanks; ++i ) {
htonf(net->fuel_quantity[i]);
}
+ net->num_tanks = htonl(net->num_tanks);
for ( i = 0; i < net->num_wheels; ++i ) {
+ net->wow[i] = htonl(net->wow[i]);
htonf(net->gear_pos[i]);
htonf(net->gear_steer[i]);
htonf(net->gear_compression[i]);
}
+ net->num_wheels = htonl(net->num_wheels);
net->cur_time = htonl(net->cur_time);
net->warp = ntohl(net->warp);
= fgGetNode("/instrumentation/nav/radials/reciprocal-radial-deg", true);
static SGPropertyNode *nav_gs_deflection
= fgGetNode("/instrumentation/nav/gs-needle-deflection", true);
- int i;
+ unsigned int i;
// Version sanity checking
net->version = FG_NET_GUI_VERSION;
#if defined( FG_USE_NETWORK_BYTE_ORDER )
// Convert the net buffer to network format
- net->version = htons(net->version);
+ net->version = htonl(net->version);
htond(net->longitude);
htond(net->latitude);
for ( i = 0; i < net->num_tanks; ++i ) {
htonf(net->fuel_quantity[i]);
}
+ net->num_tanks = htonl(net->num_tanks);
net->cur_time = htonl( net->cur_time );
net->warp = htonl( net->warp );
htonf(net->tuned_freq);
htonf(net->nav_radial);
+ net->in_range = htonl( net->in_range );
htonf(net->dist_nm);
htonf(net->course_deviation_deg);
htonf(net->gs_deviation_deg);
void FGNetGUI2Props( FGNetGUI *net ) {
- int i;
+ unsigned int i;
#if defined( FG_USE_NETWORK_BYTE_ORDER )
// Convert to the net buffer from network format
- net->version = ntohs(net->version);
+ net->version = ntohl(net->version);
htond(net->longitude);
htond(net->latitude);
htonf(net->vcas);
htonf(net->climb_rate);
+ net->num_tanks = htonl(net->num_tanks);
for ( i = 0; i < net->num_tanks; ++i ) {
htonf(net->fuel_quantity[i]);
}
net->ground_elev = htonl( net->ground_elev );
htonf(net->tuned_freq);
+ htonf(net->nav_radial);
+ net->in_range = htonl( net->in_range );
htonf(net->dist_nm);
htonf(net->course_deviation_deg);
htonf(net->gs_deviation_deg);
// net_fdm_mini.hxx -- defines a simple subset I/O interface to the flight
// dynamics model variables
//
-// Written by Curtis Olson - curt@flightgear.com, started January 2002.
+// Written by Curtis Olson - http://www.flightgear.org/~curt
+// Started January 2002.
//
// This file is in the Public Domain, and comes with no warranty.
//
#endif
-const int FG_NET_FDM_MINI_VERSION = 1;
+// NOTE: this file defines an external interface structure. Due to
+// variability between platforms and architectures, we only used fixed
+// length types here. Specifically, integer types can vary in length.
+// I am not aware of any platforms that don't use 4 bytes for float
+// and 8 bytes for double.
+
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#elif defined( _MSC_VER ) || defined(__MINGW32__)
+typedef signed char int8_t;
+typedef signed short int16_t;
+typedef signed int int32_t;
+typedef signed __int64 int64_t;
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned __int64 uint64_t;
+#else
+# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
+#endif
+
+
+const uint32_t FG_NET_FDM_MINI_VERSION = 2;
// Define a structure containing the top level flight dynamics model
FG_MAX_TANKS = 4
};
- int version; // increment when data values change
- int pad; // keep doubles 64-bit aligned for some
- // hardware platforms, such as the Sun
- // SPARC, which don't like misaligned
- // data
+ uint32_t version; // increment when data values change
// Positions
double longitude; // geodetic (radians)
double climb_rate; // feet per second
// Consumables
- int num_tanks; // Max number of fuel tanks
+ uint32_t num_tanks; // Max number of fuel tanks
double fuel_quantity[FG_MAX_TANKS];
// Environment
- time_t cur_time; // current unix time
- long int warp; // offset in seconds to unix time
+ uint32_t cur_time; // current unix time
+ int32_t warp; // offset in seconds to unix time
};
# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
#endif
-const uint16_t FG_NET_GUI_VERSION = 6;
+const uint32_t FG_NET_GUI_VERSION = 7;
// Define a structure containing the top level flight dynamics model
FG_MAX_TANKS = 4
};
- uint16_t version; // increment when data values change
+ uint32_t version; // increment when data values change
// Positions
double longitude; // geodetic (radians)
float climb_rate; // feet per second
// Consumables
- uint8_t num_tanks; // Max number of fuel tanks
+ uint32_t num_tanks; // Max number of fuel tanks
float fuel_quantity[FG_MAX_TANKS];
// Environment
// Approach
float tuned_freq; // currently tuned frequency
float nav_radial; // target nav radial
- uint8_t in_range; // tuned navaid is in range?
+ uint32_t in_range; // tuned navaid is in range?
float dist_nm; // distance to tuned navaid in nautical miles
float course_deviation_deg; // degrees off target course
float gs_deviation_deg; // degrees off target glide slope