mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-30 20:48:33 -04:00
AP_Bootloader: removed use of float in can code
This commit is contained in:
parent
ebceab9aa0
commit
c998f93949
@ -111,11 +111,11 @@ static uint16_t get_randomu16(void)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pseudo random float in the range [0, 1].
|
* Returns a pseudo random integer in a given range
|
||||||
*/
|
*/
|
||||||
static float getRandomFloat(void)
|
static uint32_t get_random_range(uint16_t range)
|
||||||
{
|
{
|
||||||
return float(get_randomu16()) / 0xFFFF;
|
return get_randomu16() % range;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -297,7 +297,7 @@ static void handle_allocation_response(CanardInstance* ins, CanardRxTransfer* tr
|
|||||||
// Rule C - updating the randomized time interval
|
// Rule C - updating the randomized time interval
|
||||||
send_next_node_id_allocation_request_at_ms =
|
send_next_node_id_allocation_request_at_ms =
|
||||||
AP_HAL::millis() + UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MIN_REQUEST_PERIOD_MS +
|
AP_HAL::millis() + UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MIN_REQUEST_PERIOD_MS +
|
||||||
(uint32_t)(getRandomFloat() * UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MAX_FOLLOWUP_DELAY_MS);
|
get_random_range(UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MAX_FOLLOWUP_DELAY_MS);
|
||||||
|
|
||||||
if (transfer->source_node_id == CANARD_BROADCAST_NODE_ID)
|
if (transfer->source_node_id == CANARD_BROADCAST_NODE_ID)
|
||||||
{
|
{
|
||||||
@ -486,7 +486,7 @@ static void can_handle_DNA(void)
|
|||||||
|
|
||||||
send_next_node_id_allocation_request_at_ms =
|
send_next_node_id_allocation_request_at_ms =
|
||||||
AP_HAL::millis() + UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MIN_REQUEST_PERIOD_MS +
|
AP_HAL::millis() + UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MIN_REQUEST_PERIOD_MS +
|
||||||
(uint32_t)(getRandomFloat() * UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MAX_FOLLOWUP_DELAY_MS);
|
get_random_range(UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MAX_FOLLOWUP_DELAY_MS);
|
||||||
|
|
||||||
// Structure of the request is documented in the DSDL definition
|
// Structure of the request is documented in the DSDL definition
|
||||||
// See http://uavcan.org/Specification/6._Application_level_functions/#dynamic-node-id-allocation
|
// See http://uavcan.org/Specification/6._Application_level_functions/#dynamic-node-id-allocation
|
||||||
@ -642,7 +642,7 @@ void can_start()
|
|||||||
|
|
||||||
send_next_node_id_allocation_request_at_ms =
|
send_next_node_id_allocation_request_at_ms =
|
||||||
AP_HAL::millis() + UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MIN_REQUEST_PERIOD_MS +
|
AP_HAL::millis() + UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MIN_REQUEST_PERIOD_MS +
|
||||||
(uint32_t)(getRandomFloat() * UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MAX_FOLLOWUP_DELAY_MS);
|
get_random_range(UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_ALLOCATION_MAX_FOLLOWUP_DELAY_MS);
|
||||||
|
|
||||||
if (stm32_was_watchdog_reset()) {
|
if (stm32_was_watchdog_reset()) {
|
||||||
node_status.vendor_specific_status_code = FAIL_REASON_WATCHDOG;
|
node_status.vendor_specific_status_code = FAIL_REASON_WATCHDOG;
|
||||||
|
Loading…
Reference in New Issue
Block a user