mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 09:37:21 +02:00
Various fixes
This commit is contained in:
@@ -176,7 +176,7 @@ esp_err_t DataLinkManager::send(uint8_t dest_board, uint8_t* data, uint16_t data
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ESP_LOGI(DEBUG_LINK_TAG, "Sending %d bytes", offset);
|
ESP_LOGI(DEBUG_LINK_TAG, "Sending %d bytes", offset);
|
||||||
// print_buffer_binary(send_data, frame_size);
|
// print_buffer_binary(send_data, frame_size);
|
||||||
|
|
||||||
uint8_t channel_to_route = MAX_CHANNELS;
|
uint8_t channel_to_route = MAX_CHANNELS;
|
||||||
@@ -192,7 +192,7 @@ esp_err_t DataLinkManager::send(uint8_t dest_board, uint8_t* data, uint16_t data
|
|||||||
ESP_LOGE(DEBUG_LINK_TAG, "Failed to find entry for %d", new_frame.receiver_id);
|
ESP_LOGE(DEBUG_LINK_TAG, "Failed to find entry for %d", new_frame.receiver_id);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
// ESP_LOGI(DEBUG_LINK_TAG, "Sending message to %d", new_frame.receiver_id);
|
ESP_LOGI(DEBUG_LINK_TAG, "Sending message to %d", new_frame.receiver_id);
|
||||||
phys_comms->send(send_data, offset, &config, channel_to_route);
|
phys_comms->send(send_data, offset, &config, channel_to_route);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,6 +271,10 @@ esp_err_t DataLinkManager::receive(uint8_t* data, size_t data_len, size_t* recv_
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*recv_len < CONTROL_FRAME_OVERHEAD) {
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t* message = (uint8_t*)pvPortMalloc(CONTROL_FRAME_OVERHEAD + MAX_CONTROL_DATA_LEN);
|
uint8_t* message = (uint8_t*)pvPortMalloc(CONTROL_FRAME_OVERHEAD + MAX_CONTROL_DATA_LEN);
|
||||||
if (message == nullptr){
|
if (message == nullptr){
|
||||||
ESP_LOGE(DEBUG_LINK_TAG, "Failed to malloc for receive");
|
ESP_LOGE(DEBUG_LINK_TAG, "Failed to malloc for receive");
|
||||||
@@ -286,7 +290,7 @@ esp_err_t DataLinkManager::receive(uint8_t* data, size_t data_len, size_t* recv_
|
|||||||
}
|
}
|
||||||
*recv_len = message_size;
|
*recv_len = message_size;
|
||||||
memcpy(data, message, message_size);
|
memcpy(data, message, message_size);
|
||||||
// ESP_LOGI(DEBUG_LINK_TAG, "Received frame of type 0x%X destined for board %d", GET_TYPE(header.type_flag), header.receiver_id);
|
ESP_LOGI(DEBUG_LINK_TAG, "Received frame of type 0x%X destined for board %d", GET_TYPE(header.type_flag), header.receiver_id);
|
||||||
|
|
||||||
//check for a rip frame
|
//check for a rip frame
|
||||||
if (static_cast<FrameType>(GET_TYPE(header.type_flag)) == FrameType::RIP_TABLE_CONTROL){
|
if (static_cast<FrameType>(GET_TYPE(header.type_flag)) == FrameType::RIP_TABLE_CONTROL){
|
||||||
@@ -295,7 +299,7 @@ esp_err_t DataLinkManager::receive(uint8_t* data, size_t data_len, size_t* recv_
|
|||||||
for (size_t i = 0; i < message_size-1; i+=2){
|
for (size_t i = 0; i < message_size-1; i+=2){
|
||||||
uint8_t board_id = message[i];
|
uint8_t board_id = message[i];
|
||||||
uint8_t hops = message[i+1];
|
uint8_t hops = message[i+1];
|
||||||
// ESP_LOGI(DEBUG_LINK_TAG, "Received: board_id %d and number of hops %d on channel %d", board_id, hops, curr_channel);
|
ESP_LOGI(DEBUG_LINK_TAG, "Received: board_id %d and number of hops %d on channel %d", board_id, hops, curr_channel);
|
||||||
|
|
||||||
RIPRow* entry = nullptr;
|
RIPRow* entry = nullptr;
|
||||||
|
|
||||||
@@ -689,7 +693,7 @@ esp_err_t DataLinkManager::send_rip_frame(bool broadcast, uint8_t dest_id){
|
|||||||
if (broadcast){
|
if (broadcast){
|
||||||
res = send(BROADCAST_ADDR, rip_message, message_idx, FrameType::RIP_TABLE_CONTROL, 0);
|
res = send(BROADCAST_ADDR, rip_message, message_idx, FrameType::RIP_TABLE_CONTROL, 0);
|
||||||
} else {
|
} else {
|
||||||
// ESP_LOGI(DEBUG_LINK_TAG, "replying to discovery request to board %d", dest_id);
|
ESP_LOGI(DEBUG_LINK_TAG, "replying to discovery request to board %d", dest_id);
|
||||||
res = send(dest_id, rip_message, message_idx, FrameType::RIP_TABLE_CONTROL, FLAG_DISCOVERY);
|
res = send(dest_id, rip_message, message_idx, FrameType::RIP_TABLE_CONTROL, FLAG_DISCOVERY);
|
||||||
}
|
}
|
||||||
if (res != ESP_OK){
|
if (res != ESP_OK){
|
||||||
@@ -838,7 +842,7 @@ esp_err_t DataLinkManager::get_network_toplogy(RIPRow_public_matrix* matrix, siz
|
|||||||
while(true){
|
while(true){
|
||||||
bool dummy;
|
bool dummy;
|
||||||
xQueueReceive(link_layer_obj->manual_broadcasts, &dummy, pdMS_TO_TICKS(RIP_BROADCAST_INTERVAL)); //wait up to RIP_BROADCAST_INTERVAL ms
|
xQueueReceive(link_layer_obj->manual_broadcasts, &dummy, pdMS_TO_TICKS(RIP_BROADCAST_INTERVAL)); //wait up to RIP_BROADCAST_INTERVAL ms
|
||||||
// ESP_LOGI(DEBUG_LINK_TAG, "Broadcasting table..."); //debug
|
ESP_LOGI(DEBUG_LINK_TAG, "Broadcasting table..."); //debug
|
||||||
res = link_layer_obj->send_rip_frame(true, 0);
|
res = link_layer_obj->send_rip_frame(true, 0);
|
||||||
if (res != ESP_OK){
|
if (res != ESP_OK){
|
||||||
ESP_LOGE(DEBUG_LINK_TAG, "Failed to broadcast rip frame");
|
ESP_LOGE(DEBUG_LINK_TAG, "Failed to broadcast rip frame");
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
#include "flatbuffers/flatbuffers.h"
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
// generated, otherwise it may not be compatible.
|
// // generated, otherwise it may not be compatible.
|
||||||
//static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
// static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
// FLATBUFFERS_VERSION_MINOR == 2 &&
|
// FLATBUFFERS_VERSION_MINOR == 2 &&
|
||||||
// FLATBUFFERS_VERSION_REVISION == 10,
|
// FLATBUFFERS_VERSION_REVISION == 10,
|
||||||
// "Non-compatible flatbuffers version included");
|
// "Non-compatible flatbuffers version included");
|
||||||
|
|
||||||
struct MotorState;
|
struct MotorState;
|
||||||
struct MotorStateBuilder;
|
struct MotorStateBuilder;
|
||||||
@@ -24,33 +24,36 @@ enum ModuleType : int8_t {
|
|||||||
ModuleType_SERVO_1 = 1,
|
ModuleType_SERVO_1 = 1,
|
||||||
ModuleType_DC_MOTOR = 2,
|
ModuleType_DC_MOTOR = 2,
|
||||||
ModuleType_BATTERY = 3,
|
ModuleType_BATTERY = 3,
|
||||||
|
ModuleType_SERVO_2 = 4,
|
||||||
ModuleType_MIN = ModuleType_SPLITTER,
|
ModuleType_MIN = ModuleType_SPLITTER,
|
||||||
ModuleType_MAX = ModuleType_BATTERY
|
ModuleType_MAX = ModuleType_SERVO_2
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const ModuleType (&EnumValuesModuleType())[4] {
|
inline const ModuleType (&EnumValuesModuleType())[5] {
|
||||||
static const ModuleType values[] = {
|
static const ModuleType values[] = {
|
||||||
ModuleType_SPLITTER,
|
ModuleType_SPLITTER,
|
||||||
ModuleType_SERVO_1,
|
ModuleType_SERVO_1,
|
||||||
ModuleType_DC_MOTOR,
|
ModuleType_DC_MOTOR,
|
||||||
ModuleType_BATTERY
|
ModuleType_BATTERY,
|
||||||
|
ModuleType_SERVO_2
|
||||||
};
|
};
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char * const *EnumNamesModuleType() {
|
inline const char * const *EnumNamesModuleType() {
|
||||||
static const char * const names[5] = {
|
static const char * const names[6] = {
|
||||||
"SPLITTER",
|
"SPLITTER",
|
||||||
"SERVO_1",
|
"SERVO_1",
|
||||||
"DC_MOTOR",
|
"DC_MOTOR",
|
||||||
"BATTERY",
|
"BATTERY",
|
||||||
|
"SERVO_2",
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *EnumNameModuleType(ModuleType e) {
|
inline const char *EnumNameModuleType(ModuleType e) {
|
||||||
if (::flatbuffers::IsOutRange(e, ModuleType_SPLITTER, ModuleType_BATTERY)) return "";
|
if (::flatbuffers::IsOutRange(e, ModuleType_SPLITTER, ModuleType_SERVO_2)) return "";
|
||||||
const size_t index = static_cast<size_t>(e);
|
const size_t index = static_cast<size_t>(e);
|
||||||
return EnumNamesModuleType()[index];
|
return EnumNamesModuleType()[index];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ int RMTManager::convert_symbols_to_char(rmt_symbol_word_t* symbols, size_t num,
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
printf("output_index %d\n", output_index);
|
// printf("output_index %d\n", output_index);
|
||||||
return (int)output_index;
|
return (int)output_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class RMTManager{
|
|||||||
|
|
||||||
//rx_receive_config
|
//rx_receive_config
|
||||||
rmt_receive_config_t receive_config = {
|
rmt_receive_config_t receive_config = {
|
||||||
.signal_range_min_ns = 100,
|
.signal_range_min_ns = 200,
|
||||||
.signal_range_max_ns = 200 * 1000,
|
.signal_range_max_ns = 200 * 1000,
|
||||||
.flags = {
|
.flags = {
|
||||||
.en_partial_rx = true
|
.en_partial_rx = true
|
||||||
|
|||||||
@@ -137,13 +137,10 @@ std::pair<std::vector<uint8_t>, std::vector<Orientation>> CommunicationRouter::g
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAX_WIRED_CONNECTIONS; i++) {
|
if (const auto id = connected_module_ids[0]; 0 == id) {
|
||||||
const auto id = connected_module_ids[i];
|
connected_module_orientations[0] = Orientation_Deg0;
|
||||||
// if (const auto id = connected_module_ids[i]; 0 == id) {
|
} else {
|
||||||
// connected_module_orientations[i] = Orientation_Deg0;
|
connected_module_orientations[0] = OrientationDetection::get_orientation(0);
|
||||||
// } else {
|
|
||||||
connected_module_orientations[i] = OrientationDetection::get_orientation(id);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { connected_module_ids, connected_module_orientations };
|
return { connected_module_ids, connected_module_orientations };
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ std::unique_ptr<IActuator> ActuatorFactory::create_actuator(const ModuleType typ
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case ModuleType_SERVO_1:
|
case ModuleType_SERVO_1:
|
||||||
return std::make_unique<Servo1Actuator>();
|
return std::make_unique<Servo1Actuator>();
|
||||||
|
case ModuleType_SERVO_2:
|
||||||
|
return std::make_unique<Servo1Actuator>();
|
||||||
case ModuleType_DC_MOTOR:
|
case ModuleType_DC_MOTOR:
|
||||||
return std::make_unique<DCMotorActuator>();
|
return std::make_unique<DCMotorActuator>();
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user