Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Modified logged messages and gps mode switch notification functions f…
Browse files Browse the repository at this point in the history
…or coherence.
  • Loading branch information
cruzeneko committed May 15, 2016
1 parent 0bc52f5 commit 419bd31
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
22 changes: 17 additions & 5 deletions gps/GPS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void GPS::enter_airborne_1g_mode()
0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, //determines new
0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C, //operation mode.
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xDC
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xDC
};
uint8_t sz_setdm6 = 44;

Expand Down Expand Up @@ -496,7 +496,7 @@ bool GPS::receive_check_ublox_ack(unsigned char *message)
ack_packet[9]+= ack_packet[8];
}
bytes_ordered = 0;

gettimeofday(&time_start, NULL);
ms_start = (long)((time_start.tv_sec)*1000 + (time_start.tv_usec)/1000);
ms_now = ms_start;
Expand All @@ -505,7 +505,7 @@ bool GPS::receive_check_ublox_ack(unsigned char *message)
gettimeofday(&time_now, NULL); //timing out after
ms_now = (long)((time_now.tv_sec)*1000 + (time_now.tv_usec)/1000); //3s

if (bytes_ordered > 9)
if (bytes_ordered > 9)
{
return true;
}
Expand All @@ -526,14 +526,26 @@ bool GPS::receive_check_ublox_ack(unsigned char *message)
return false;
}

void GPS::notify_initialization()
{
this->logger->log("Initialization notified. Switching to pedestrian mode");
this->enter_pedestrian_mode();
}

void GPS::notify_takeoff()
{
this->logger->log("GPS notified takeoff. Switching to airborne mode");
this->logger->log("Takeoff notified. Switching to airborne mode");
this->enter_airborne_1g_mode();
}

void GPS::notify_safe_mode()
{
this->logger->log("Safe mode entry notified. Switching to airborne mode");
this->enter_airborne_1g_mode();
}

void GPS::notify_landing()
{
this->logger->log("GPS notified landing. Switching to stationary mode");
this->logger->log("Landing notified. Switching to stationary mode");
this->enter_stationary_mode();
}
2 changes: 2 additions & 0 deletions gps/GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ namespace os {

void notify_takeoff();
void notify_landing();
void notify_initialization();
void notify_safe_mode();
};
}

Expand Down
4 changes: 4 additions & 0 deletions logic/initialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ if ( ! GPS::get_instance().initialize())
}
logger.log("GPS initialized.");

//Notify the GPS about its initialization, so that it sets itself to the appropriate mode
logger.log("Notifying GPS about initialization...");
GPS::get_instance().notify_initialization();

logger.log("Initializing GSM...");
if ( ! GSM::get_instance().initialize())
{
Expand Down
2 changes: 1 addition & 1 deletion logic/land.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if ( ! Camera::get_instance().stop())
else
logger->log("Video stopped.");

logger->log("Setting GPS to stationary mode...");
logger->log("Notifying GPS about landing...");
GPS::get_instance().notify_landing();

logger->log("Waiting 1 minute before sending landed SMS...");
Expand Down
4 changes: 4 additions & 0 deletions logic/safe_mode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ switch (last_state)
}

logger->log("GPS fix acquired.");

logger->log("Notifying GPS about entering safe mode...");
GPS::get_instance().notify_safe_mode();

this_thread::sleep_for(5s);
for (int i = 0;
GPS::get_instance().get_HDOP() > 5 && i < 10;
Expand Down
2 changes: 1 addition & 1 deletion logic/wait_launch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ while ( ! has_launched(launch_altitude))

logger->log("Balloon launched.");

logger->log("Setting GPS to airborne mode...");
logger->log("Notifying GPS about launch...");
GPS::get_instance().notify_takeoff();

0 comments on commit 419bd31

Please sign in to comment.