-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implementations for breezy board and test board to pass tests
- Loading branch information
1 parent
cf19795
commit 9d417d2
Showing
11 changed files
with
171 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "breezy_board_config_manager.h" | ||
#include <cstring> | ||
|
||
namespace rosflight_firmware | ||
{ | ||
hardware_config_t BreezyBoardConfigManager::get_max_config(device_t device) | ||
{ | ||
(void)device; | ||
return 0; | ||
} | ||
|
||
ConfigManager::config_response BreezyBoardConfigManager::check_config_change(device_t device, hardware_config_t config) | ||
{ | ||
(void)device; | ||
(void)config; | ||
ConfigManager::config_response response; | ||
response.successful = false; | ||
response.reboot_required = false; | ||
strcpy(reinterpret_cast<char*>(response.message), "Feature unsupported on naze"); | ||
return response; | ||
} | ||
|
||
void BreezyBoardConfigManager::get_device_name(device_t device, uint8_t (&name)[20]) | ||
{ | ||
(void)device; | ||
strcpy(reinterpret_cast<char*>(name), "Unsupported"); | ||
} | ||
|
||
void BreezyBoardConfigManager::get_config_name(device_t device, hardware_config_t config, uint8_t (&name)[20]) | ||
{ | ||
(void)device; | ||
(void)config; | ||
strcpy(reinterpret_cast<char*>(name), "Unsupported"); | ||
} | ||
|
||
} // namespace rosflight_firmware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef BREEZYBOARDCONFIGMANAGER_H | ||
#define BREEZYBOARDCONFIGMANAGER_H | ||
|
||
#include "board_config_manager.h" | ||
|
||
namespace rosflight_firmware | ||
{ | ||
class BreezyBoardConfigManager : public BoardConfigManager | ||
{ | ||
public: | ||
hardware_config_t get_max_config(device_t device) override; | ||
ConfigManager::config_response check_config_change(device_t device, hardware_config_t config) override; | ||
void get_device_name(device_t device, uint8_t (&name)[20]) override; | ||
void get_config_name(device_t device, hardware_config_t config, uint8_t (&name)[20]) override; | ||
}; | ||
} // namespace rosflight_firmware | ||
|
||
#endif // BREEZYBOARDCONFIGMANAGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "test_board_config_manager.h" | ||
#include <cstring> | ||
#include <string> | ||
|
||
namespace rosflight_firmware | ||
{ | ||
hardware_config_t TestBoardConfigManager::get_max_config(device_t device) | ||
{ | ||
(void)device; | ||
return 0; // This is not needed to test other software | ||
} | ||
ConfigManager::config_response TestBoardConfigManager::check_config_change(device_t device, hardware_config_t config) | ||
{ | ||
// A couple variations are given for testing | ||
ConfigManager::config_response response; | ||
response.successful = true; | ||
response.reboot_required = true; | ||
if(device == Configuration::SERIAL && config == 1) | ||
{ | ||
response.successful = false; | ||
strcpy(reinterpret_cast<char*>(response.message), "Fail for testing"); | ||
return response; | ||
} | ||
strcpy(reinterpret_cast<char*>(response.message), "Succeed for testing"); | ||
return response; | ||
} | ||
void TestBoardConfigManager::get_device_name(device_t device, uint8_t (&name)[20]) | ||
{ | ||
std::string device_name = "device #" + std::to_string(static_cast<int>(device)); | ||
strcpy(reinterpret_cast<char*>(name), device_name.c_str()); | ||
} | ||
void TestBoardConfigManager::get_config_name(device_t device, hardware_config_t config, uint8_t (&name)[20]) | ||
{ | ||
std::string config_name = "config " + std::to_string(static_cast<int>(device)) + ","+std::to_string(static_cast<int>(config)); | ||
strcpy(reinterpret_cast<char*>(name), config_name.c_str()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef TESTBOARDCONFIGMANAGER_H | ||
#define TESTBOARDCONFIGMANAGER_H | ||
|
||
#include "board_config_manager.h" | ||
|
||
namespace rosflight_firmware | ||
{ | ||
class TestBoardConfigManager : public BoardConfigManager | ||
{ | ||
public: | ||
hardware_config_t get_max_config(device_t device) override; | ||
ConfigManager::config_response check_config_change(device_t device, hardware_config_t config) override; | ||
void get_device_name(device_t device, uint8_t (&name)[20]) override; | ||
void get_config_name(device_t device, hardware_config_t config, uint8_t (&name)[20]) override; | ||
}; | ||
|
||
} // rosflight_firmware | ||
#endif // TESTBOARDCONFIGMANAGER_H |