1
0
Fork 0

Oops, forgot to update the network byte order conversion functions when I

updated the structures.
This commit is contained in:
curt 2005-05-04 21:07:03 +00:00
parent 510314f54d
commit 5b9bd7ae4d
5 changed files with 107 additions and 25 deletions

View file

@ -229,7 +229,7 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
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);
@ -237,17 +237,38 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
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);
@ -255,6 +276,9 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
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);
}
}
@ -269,7 +293,7 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
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);
@ -277,17 +301,38 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
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);
@ -295,6 +340,9 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
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 ) {

View file

@ -120,7 +120,7 @@ bool FGNativeFDM::open() {
void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
int i;
unsigned int i;
// Version sanity checking
net->version = FG_NET_FDM_VERSION;
@ -219,7 +219,7 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
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);
@ -250,7 +250,9 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
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]);
@ -261,11 +263,14 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
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]);
@ -290,11 +295,11 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
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);
@ -326,6 +331,7 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
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]);
@ -335,16 +341,20 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
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);

View file

@ -136,7 +136,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
= 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;
@ -215,7 +215,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
#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);
@ -229,6 +229,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
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 );
@ -236,6 +237,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
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);
@ -244,11 +246,11 @@ void FGProps2NetGUI( FGNetGUI *net ) {
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);
@ -259,6 +261,7 @@ void FGNetGUI2Props( FGNetGUI *net ) {
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]);
}
@ -268,6 +271,8 @@ void FGNetGUI2Props( FGNetGUI *net ) {
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);

View file

@ -1,7 +1,8 @@
// 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.
//
@ -17,7 +18,29 @@
#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
@ -33,11 +56,7 @@ public:
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)
@ -53,12 +72,12 @@ public:
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
};

View file

@ -33,7 +33,7 @@ typedef unsigned __int64 uint64_t;
# 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
@ -49,7 +49,7 @@ public:
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)
@ -65,7 +65,7 @@ public:
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
@ -77,7 +77,7 @@ public:
// 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