mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
Fix RIP bugs, add in UART
This commit is contained in:
@@ -10,12 +10,20 @@
|
||||
#include "freertos/semphr.h"
|
||||
#include "Frames.h"
|
||||
#include "Tables.h"
|
||||
#include "RMTManager.h"
|
||||
#include "IPhysicalLayer.h"
|
||||
#include "BlockingQueue.h"
|
||||
#include "BlockingPriorityQueue.h"
|
||||
#include <unordered_map>
|
||||
#include "Scheduler.h"
|
||||
|
||||
/**
|
||||
* @brief Selects which physical layer implementation to instantiate.
|
||||
*/
|
||||
enum class PhysicalLayerType : uint8_t {
|
||||
RMT = 0, ///< Use the RMT-based Manchester-encoded physical layer (default)
|
||||
SOFT_UART = 1, ///< Use the software-UART physical layer
|
||||
};
|
||||
|
||||
#define DEBUG_LINK_TAG "LinkLayer"
|
||||
|
||||
#define CRC_POLYNOMIAL 0x1021
|
||||
@@ -56,7 +64,7 @@ static const uint16_t crc16_table[256] = {
|
||||
*/
|
||||
class DataLinkManager{
|
||||
public:
|
||||
DataLinkManager(uint8_t board_id, uint8_t num_channels);
|
||||
DataLinkManager(uint8_t board_id, uint8_t num_channels, PhysicalLayerType phy_type = PhysicalLayerType::SOFT_UART);
|
||||
~DataLinkManager();
|
||||
esp_err_t send(uint8_t dest_board, std::unique_ptr<std::vector<uint8_t>>&& buffer, FrameType type, uint8_t flag);
|
||||
esp_err_t start_receive_frames(uint8_t curr_channel);
|
||||
@@ -69,7 +77,7 @@ class DataLinkManager{
|
||||
private:
|
||||
uint8_t this_board_id = 0;
|
||||
uint8_t num_channels = MAX_CHANNELS;
|
||||
std::unique_ptr<RMTManager> phys_comms;
|
||||
std::unique_ptr<IPhysicalLayer> phys_comms;
|
||||
|
||||
std::unordered_map<uint8_t, uint16_t> sequence_num_map;
|
||||
SemaphoreHandle_t sequence_num_map_mutex;
|
||||
@@ -93,10 +101,11 @@ class DataLinkManager{
|
||||
|
||||
void init_rip();
|
||||
esp_err_t rip_find_entry(uint8_t board_id, RIPRow** entry, bool reserve_row);
|
||||
esp_err_t rip_update_entry(uint8_t new_hop, uint8_t channel, RIPRow** entry);
|
||||
esp_err_t rip_add_entry(uint8_t board_id, uint8_t hops, uint8_t channel, RIPRow** entry);
|
||||
esp_err_t rip_update_entry(uint8_t new_hop, uint8_t new_sum_of_hops, uint8_t channel, RIPRow** entry);
|
||||
esp_err_t rip_add_entry(uint8_t board_id, uint8_t hops, uint8_t sum_of_hops, uint8_t channel, RIPRow** entry);
|
||||
esp_err_t rip_reset_entry_ttl(uint8_t board_id);
|
||||
esp_err_t rip_get_row(RIPRow** entry, uint8_t row_num);
|
||||
void rip_update_self_sum_of_hops();
|
||||
|
||||
//this is stored locally with metadata `ttl`
|
||||
// std::unordered_map<uint8_t, RIPRow> rip_table; //using a hash map to store the routes to other boards - will be used as we scale up
|
||||
|
||||
Reference in New Issue
Block a user