Skip to content

Commit

Permalink
Merge branch 'feature/param_server' of github.com:hytech-racing/MCU i…
Browse files Browse the repository at this point in the history
…nto feature/param_server
  • Loading branch information
walkermburns committed Apr 30, 2024
2 parents bf38061 + ada45c2 commit 60358c7
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 113 deletions.
24 changes: 16 additions & 8 deletions lib/interfaces/include/EthernetInterface.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
#ifndef __ETHERNETINTERFACE_H__
#define __ETHERNETINTERFACE_H__
#ifndef ETHERNETINTERFACE
#define ETHERNETINTERFACE
#include <QNEthernet.h>

#include <Arduino.h>
#include "QNEthernet.h"
#include "circular_buffer.h"

using namespace qindesign::network;

EthernetUDP udp;

uint8_t mac_address[6];
class EthernetInterface
{
public:
EthernetInterface() {};
void begin(int port);
/// @brief sends all udp packets in queue
void handle_sending();
/// @brief receives all udp packets
void handle_recvs();

void init_ethernet_device();
private:
EthernetUDP udp_ethernet_;
}

#endif
52 changes: 0 additions & 52 deletions lib/library.json

This file was deleted.

64 changes: 12 additions & 52 deletions lib/systems/include/ParameterSystem.h
Original file line number Diff line number Diff line change
@@ -1,56 +1,16 @@
#pragma once
#include <unordered_map>
#ifndef PARAMETERSYSTEM
#define PARAMETERSYSTEM
#include "Parameters.h"

namespace Parameters {
template<typename T>
void setParameter(T& paramType, float value) {
paramType.set(value);
}

class FloatParameter {
public:
virtual float get() const = 0;
virtual void set(float value) = 0;
virtual ~FloatParameter() {}
};
template<typename T>
auto getParameter(T& paramType){
return paramType.get();
}

class BoolParameter {
public:
virtual bool get() const = 0;
virtual void set(bool value) = 0;
virtual ~BoolParameter() {}
};

class MaxSpeed : public FloatParameter {
float value;
public:
MaxSpeed() : value(120.0) {}
float get() const override { return value; }
void set(float v) override { value = v; }
};

class Threshold : public FloatParameter {
float value;
public:
Threshold() : value(0.75) {}
float get() const override { return value; }
void set(float v) override { value = v; }
};

class IsActive : public BoolParameter {
bool value;
public:
IsActive() : value(false) {}
bool get() const override { return value; }
void set(bool v) override { value = v; }
};

MaxSpeed MaxSpeedInstance;
Threshold ThresholdInstance;
std::unordered_map<const char *, Parameters::FloatParameter*> floatLookupMap = {
{"b1fc2577", &MaxSpeedInstance},
{"0da627ad", &ThresholdInstance},
};

IsActive IsActiveInstance;
std::unordered_map<const char *, Parameters::BoolParameter*> boolLookupMap = {
{"57401e59", &IsActiveInstance},
};

}
#endif
3 changes: 2 additions & 1 deletion lib/systems/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"shared-interfaces-lib": "*",
"shared-systems-lib": "*",
"CASE_lib": "*",
"shared_data": "*"
"shared_data": "*",
"HT_params_lib": "*"
},
"frameworks": "*",
"platforms": "*"
Expand Down
9 changes: 9 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ lib_ignore =
test_ignore=
test_interfaces*
lib_deps=
https://github.com/hytech-racing/HT_params/releases/download/3/HT_params_lib.tar.gz
git+ssh://git@github.com/hytech-racing/CASE_lib.git#v39
https://github.com/hytech-racing/shared_firmware_systems.git

Expand Down Expand Up @@ -42,17 +43,25 @@ board = teensy41
framework = arduino
upload_protocol = teensy-cli
extra_scripts = pre:extra_script.py
custom_nanopb_protos =
+<proto/ht_msgs.proto>

lib_deps =
SPI
Nanopb
ssilverman/QNEthernet@^0.27.0
https://github.com/hytech-racing/shared_firmware_interfaces.git
https://github.com/hytech-racing/shared_firmware_systems.git
https://github.com/RCMast3r/spi_libs
https://github.com/tonton81/FlexCAN_T4
https://github.com/ssilverman/QNEthernet.git
https://github.com/RCMast3r/hytech_can#testing_new_inv_ids
https://github.com/hytech-racing/HT_CAN/releases/download/80/can_lib.tar.gz
https://github.com/hytech-racing/HT_params/releases/download/3/HT_params_lib.tar.gz
https://github.com/tonton81/Circular_Buffer
git+ssh://git@github.com/hytech-racing/CASE_lib.git#v39


[env:test_can_on_teensy]
lib_ignore =
mock_interfaces
Expand Down
21 changes: 21 additions & 0 deletions proto/ht_msgs.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";

package ht_eth;

message config
{
string id = 1;
oneof config_val {
bool bool_val = 2;
float float_val = 3;
int32 int_val = 4;
}
}

message CASE_output
{
float vehm_fl_slip = 1;
float vehm_fr_slip = 2;
float vehm_rl_slip = 3;
float vehm_rr_slip = 4;
}

0 comments on commit 60358c7

Please sign in to comment.