# include <config.h>
#endif
-#ifndef _MSC_VER
+#if !defined( _MSC_VER ) && !defined( __MINGW32__ )
# include <strings.h> // for bzero()
#else
# define bzero(a,b) memset(a,0,b)
#include "UGear.hxx"
#include "UGear_command.hxx"
#include "UGear_opengc.hxx"
+#include "UGear_telnet.hxx"
-SG_USING_STD(cout);
-SG_USING_STD(endl);
-SG_USING_STD(string);
+using std::cout;
+using std::endl;
+using std::string;
// Network channels
track.set_stargate_swap_mode();
}
+ UGTelnet telnet( 5402 );
+ telnet.open();
+
if ( infile.length() || flight_dir.length() ) {
if ( infile.length() ) {
// Load data from a stream log data file
current_time_stamp.stamp();
/* Convert to ms */
- double elapsed_us = current_time_stamp - last_time_stamp;
+ double elapsed_us = (current_time_stamp - last_time_stamp).toUSecs();
if ( elapsed_us < (frame_us - 2000) ) {
double requested_us = (frame_us - elapsed_us) - 2000 ;
ulMilliSecondSleep ( (int)(requested_us / 1000.0) ) ;
}
current_time_stamp.stamp();
- while ( current_time_stamp - last_time_stamp < frame_us ) {
+ while ( (current_time_stamp - last_time_stamp).toUSecs() < frame_us ) {
current_time_stamp.stamp();
}
}
printf("<gpx>\n");
cout << "Processed " << imu_count << " entries in "
- << (current_time_stamp - start_time) / 1000000 << " seconds."
+ << current_time_stamp - start_time << " seconds."
<< endl;
} else if ( serialdev.length() ) {
// process incoming data from the serial port
return false;
}
- // create the command channel manager
- UGCommand command;
-
// add some test commands
- //command.add("ap,alt,1000");
- //command.add("home,158.0,32.5");
- //command.add("go,home");
- //command.add("go,route");
+ //command_mgr.add("ap,alt,1000");
+ //command_mgr.add("home,158.0,32.5");
+ //command_mgr.add("go,home");
+ //command_mgr.add("go,route");
while ( uavcom.is_enabled() ) {
// cout << "looking for next message ..." << endl;
// cout << "message id = " << id << endl;
count++;
+ telnet.process();
+
if ( id == GPS_PACKET ) {
if ( gpspacket.time > gps_time ) {
gps_time = gpspacket.time;
health_time = healthpacket.time;
current_time = health_time;
printf("Received a health packet, sequence: %d\n",
- healthpacket.command_sequence);
- command.update_cmd_sequence(healthpacket.command_sequence);
+ (int)healthpacket.command_sequence);
+ command_mgr.update_cmd_sequence(healthpacket.command_sequence);
} else {
cout << "oops health back in time: " << healthpacket.time << " " << health_time << endl;
}
gps_status = 1.0;
}
- // Generate a ground station heart beat every 5 seconds
- if ( current_time >= command_heartbeat + 5 ) {
- command.add("hb");
+ // Generate a ground station heart beat every 4 seconds
+ if ( current_time >= command_heartbeat + 4 ) {
+ command_mgr.add("hb");
command_heartbeat = current_time;
}
// Command update @ 1hz
if ( current_time >= command_time + 1 ) {
- command.update(&uavcom);
+ command_mgr.update(&uavcom);
command_time = current_time;
}
if ( current_time >= last_time + (1/hertz) ) {
// if ( gpspacket.lat > -500 ) {
int londeg = (int)navpacket.lon;
- double lonmin = fabs(navpacket.lon - londeg);
+ // double lonmin = fabs(navpacket.lon - londeg);
int latdeg = (int)navpacket.lat;
- double latmin = fabs(navpacket.lat - latdeg);
+ // double latmin = fabs(navpacket.lat - latdeg);
char londir = 'E'; if ( londeg < 0 ) londir = 'W';
char latdir = 'N'; if ( latdeg < 0 ) latdir = 'S';
londeg = abs(londeg);