This commit is contained in:
2025-07-27 20:50:14 -04:00
parent 3cbdf0845d
commit 74d370e21a
6 changed files with 31 additions and 22 deletions

View File

@@ -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);
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);
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);
}
@@ -271,6 +271,10 @@ esp_err_t DataLinkManager::receive(uint8_t* data, size_t data_len, size_t* recv_
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);
if (message == nullptr){
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;
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
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){
uint8_t board_id = message[i];
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;
@@ -689,7 +693,7 @@ esp_err_t DataLinkManager::send_rip_frame(bool broadcast, uint8_t dest_id){
if (broadcast){
res = send(BROADCAST_ADDR, rip_message, message_idx, FrameType::RIP_TABLE_CONTROL, 0);
} 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);
}
if (res != ESP_OK){
@@ -838,7 +842,7 @@ esp_err_t DataLinkManager::get_network_toplogy(RIPRow_public_matrix* matrix, siz
while(true){
bool dummy;
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);
if (res != ESP_OK){
ESP_LOGE(DEBUG_LINK_TAG, "Failed to broadcast rip frame");

View File

@@ -7,11 +7,11 @@
#include "flatbuffers/flatbuffers.h"
// Ensure the included flatbuffers.h is the same version as when this file was
// generated, otherwise it may not be compatible.
//static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
// FLATBUFFERS_VERSION_MINOR == 2 &&
// FLATBUFFERS_VERSION_REVISION == 10,
// "Non-compatible flatbuffers version included");
// // generated, otherwise it may not be compatible.
// static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
// FLATBUFFERS_VERSION_MINOR == 2 &&
// FLATBUFFERS_VERSION_REVISION == 10,
// "Non-compatible flatbuffers version included");
struct MotorState;
struct MotorStateBuilder;
@@ -24,33 +24,36 @@ enum ModuleType : int8_t {
ModuleType_SERVO_1 = 1,
ModuleType_DC_MOTOR = 2,
ModuleType_BATTERY = 3,
ModuleType_SERVO_2 = 4,
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[] = {
ModuleType_SPLITTER,
ModuleType_SERVO_1,
ModuleType_DC_MOTOR,
ModuleType_BATTERY
ModuleType_BATTERY,
ModuleType_SERVO_2
};
return values;
}
inline const char * const *EnumNamesModuleType() {
static const char * const names[5] = {
static const char * const names[6] = {
"SPLITTER",
"SERVO_1",
"DC_MOTOR",
"BATTERY",
"SERVO_2",
nullptr
};
return names;
}
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);
return EnumNamesModuleType()[index];
}

View File

@@ -642,7 +642,7 @@ int RMTManager::convert_symbols_to_char(rmt_symbol_word_t* symbols, size_t num,
}
i++;
}
printf("output_index %d\n", output_index);
// printf("output_index %d\n", output_index);
return (int)output_index;
}

View File

@@ -114,7 +114,7 @@ class RMTManager{
//rx_receive_config
rmt_receive_config_t receive_config = {
.signal_range_min_ns = 100,
.signal_range_min_ns = 200,
.signal_range_max_ns = 200 * 1000,
.flags = {
.en_partial_rx = true

View File

@@ -137,11 +137,11 @@ std::pair<std::vector<uint8_t>, std::vector<Orientation>> CommunicationRouter::g
}
}
// if (const auto id = connected_module_ids[0]; 0 == id) {
// connected_module_orientations[0] = Orientation_Deg0;
// } else {
if (const auto id = connected_module_ids[0]; 0 == id) {
connected_module_orientations[0] = Orientation_Deg0;
} else {
connected_module_orientations[0] = OrientationDetection::get_orientation(0);
// }
}
return { connected_module_ids, connected_module_orientations };
}