5 #include <gtest/gtest.h> 26 : should_request_cnt(0)
33 const uavcan::protocol::GetNodeInfo::Response& node_info,
37 std::cout <<
"REQUEST? " <<
int(node_id.
get()) <<
"\n" << node_info << std::endl;
38 out_firmware_file_path = firmware_path.
c_str();
39 return node_info.name == expected_node_name_to_update;
43 const BeginFirmwareUpdate::Response& error_response,
46 last_error_response = error_response;
47 std::cout <<
"RETRY? " <<
int(node_id.
get()) <<
"\n" << error_response << std::endl;
50 EXPECT_STREQ(firmware_path.c_str(), out_firmware_file_path.
c_str());
64 const BeginFirmwareUpdate::Response& response)
67 std::cout <<
"CONFIRMED " <<
int(node_id.
get()) <<
"\n" << response << std::endl;
80 std::cout <<
"REQUEST\n" << req << std::endl;
81 res.error = response_error_code;
82 res.optional_error_message =
"foobar";
86 void (BeginFirmwareUpdateServer::*)(
94 TEST(FirmwareUpdateTrigger, Basic)
115 ASSERT_LE(0, trigger.
start(node_info_retriever,
"/path_prefix/"));
117 ASSERT_LE(0, node_info_retriever.
start());
120 uavcan::protocol::HardwareVersion hwver;
121 hwver.unique_id[0] = 123;
122 hwver.unique_id[4] = 213;
123 hwver.unique_id[8] = 45;
125 provider->setName(
"Ivan");
126 provider->setHardwareVersion(hwver);
128 ASSERT_LE(0, provider->startAndPublish());
200 provider->setName(
"Dmitry");
201 provider->setHardwareVersion(hwver);
203 ASSERT_LE(0, provider->startAndPublish());
223 TEST(FirmwareUpdateTrigger, MultiNode)
243 uavcan::protocol::HardwareVersion hwver;
248 ASSERT_LE(0, trigger.
start(node_info_retriever,
"/path_prefix/"));
250 ASSERT_LE(0, node_info_retriever.
start());
253 hwver.unique_id[0] = 0xAA;
254 provider_a->setHardwareVersion(hwver);
255 provider_a->setName(
"Victor");
256 ASSERT_LE(0, provider_a->startAndPublish());
258 hwver.unique_id[0] = 0xBB;
259 provider_b->setHardwareVersion(hwver);
260 provider_b->setName(
"Victor");
261 ASSERT_LE(0, provider_b->startAndPublish());
263 hwver.unique_id[0] = 0xCC;
264 provider_c->setHardwareVersion(hwver);
265 provider_c->setName(
"Alexey");
266 ASSERT_LE(0, provider_c->startAndPublish());
268 hwver.unique_id[0] = 0xDD;
269 provider_d->setHardwareVersion(hwver);
270 provider_d->setName(
"Victor");
271 ASSERT_LE(0, provider_d->startAndPublish());
unsigned should_request_cnt
virtual bool shouldRetryFirmwareUpdate(uavcan::NodeID node_id, const BeginFirmwareUpdate::Response &error_response, FirmwareFilePath &out_firmware_file_path)
const char * c_str() const
std::string firmware_path
int start(NodeInfoRetriever &node_info_retriever, const FirmwareFilePath &arg_common_path_prefix=FirmwareFilePath(), const TransferPriority priority=TransferPriority::OneHigherThanLowest)
uint64_t internal_failure_count
bool isTimerRunning() const
BeginFirmwareUpdateServer()
void handleRequest(const uavcan::ReceivedDataStructure< typename BeginFirmwareUpdate::Request > &req, uavcan::ServiceResponseDataStructure< typename BeginFirmwareUpdate::Response > &res) const
unsigned getNumListeners() const
TEST(FirmwareUpdateTrigger, Basic)
virtual bool shouldRequestFirmwareUpdate(uavcan::NodeID node_id, const uavcan::protocol::GetNodeInfo::Response &node_info, FirmwareFilePath &out_firmware_file_path)
int start(const TransferPriority priority=TransferPriority::OneHigherThanLowest)
unsigned getNumPendingNodes() const
int spinAll(uavcan::MonotonicDuration duration)
static GlobalDataTypeRegistry & instance()
unsigned confirmation_cnt
int start(const Callback &callback)
BeginFirmwareUpdate::Response last_error_response
uint8_t response_error_code
static MonotonicDuration fromMSec(int64_t ms)
unsigned should_retry_cnt
int spinBoth(uavcan::MonotonicDuration duration)
virtual void handleFirmwareUpdateConfirmation(uavcan::NodeID node_id, const BeginFirmwareUpdate::Response &response)
std::string expected_node_name_to_update