Skip to content

Commit

Permalink
jankily fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RCMast3r committed May 6, 2024
1 parent 0dc9ea8 commit c715337
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 20 deletions.
21 changes: 21 additions & 0 deletions include/InterfaceParams.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef INTERFACEPARAMS
#define INTERFACEPARAMS
#include "NativeEthernet.h"

namespace EthParams
{
uint8_t default_MCU_MAC_address[6] =
{0x04, 0xe9, 0xe5, 0x10, 0x1f, 0x22};

const IPAddress default_MCU_ip(192, 168, 1, 30);
const IPAddress default_TCU_ip(192, 168, 1, 68);

const uint16_t default_protobuf_send_port = 2001;
const uint16_t default_protobuf_recv_port = 2000;

const IPAddress default_netmask(255, 255, 255, 0);
const IPAddress default_gateway(192, 168, 0, 1);

const uint16_t default_buffer_size = 512;
}
#endif
20 changes: 3 additions & 17 deletions include/MCU_rev15_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,10 @@
#define __MCU15_H__

#include "PedalsSystem.h"
#include "NativeEthernet.h"
#ifndef TESTING_SYSTEMS
#include "InterfaceParams.h"
#endif

namespace EthParams
{
uint8_t default_MCU_MAC_address[6] =
{0x04, 0xe9, 0xe5, 0x10, 0x1f, 0x22};

const IPAddress default_MCU_ip(192, 168, 1, 30);
const IPAddress default_TCU_ip(192, 168, 1, 68);

const uint16_t default_protobuf_send_port = 2001;
const uint16_t default_protobuf_recv_port = 2000;

const IPAddress default_netmask(255, 255, 255, 0);
const IPAddress default_gateway(192, 168, 0, 1);

const uint16_t default_buffer_size = 512;
}

// pindefs
const int ADC1_CS = 34;
Expand Down
46 changes: 46 additions & 0 deletions lib/mock_interfaces/ParameterInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef PARAMETERINTERFACE
#define PARAMETERINTERFACE
#include "MCUStateMachine.h"
#include "ht_eth.pb.h"
#include "default_config.h"

// yes, i know this is a singleton. im prototyping rn.
// TODO review if I can just give this a pointer to an ethernet port
class ParameterInterface
{
public:
ParameterInterface(): current_car_state_(CAR_STATE::STARTUP), params_need_sending_(false), config_(DEFAULT_CONFIG) {}

void update_car_state(const CAR_STATE& state)
{
current_car_state_ = state;
}
void update_config(const config &config)
{
if(static_cast<int>(current_car_state_) < 5 ){
config_ = config;
}

}
config get_config()
{
return config_;
}
void set_params_need_sending()
{
params_need_sending_ = true;
}
void reset_params_need_sending()
{
params_need_sending_ = false;
}
bool params_need_sending() { return params_need_sending_; }

private:
CAR_STATE current_car_state_;
bool params_need_sending_ = false;
config config_;

};

#endif
3 changes: 3 additions & 0 deletions lib/mock_interfaces/ProtobufMsgInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ifndef PROTOBUFMSGINTERFACE
#define PROTOBUFMSGINTERFACE
#endif
6 changes: 4 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ build_src_filter =
-<**/*.c>
-<**/*.cpp>
build_unflags = -std=gnu++11
build_flags = -std=c++17 -g
build_flags = -std=c++17 -g -D TESTING_SYSTEMS
lib_ignore =
interfaces-lib
test_ignore=
test_interfaces*
lib_deps=
git+ssh://git@github.com/hytech-racing/CASE_lib.git#v39
git+ssh://git@github.com/hytech-racing/CASE_lib.git#v45
https://github.com/tonton81/Circular_Buffer.git
Nanopb
https://github.com/hytech-racing/shared_firmware_systems.git
https://github.com/hytech-racing/HT_params/releases/download/2024-05-05T13_33_07/ht_eth_pb_lib.tar.gz

[env:teensy41]
; Testing variables
Expand Down
2 changes: 1 addition & 1 deletion test/test_systems/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "drivetrain_system_test.h"
#include "safety_system_test.h"
#include "test_CASE.h"
#include "param_system_test.h"
// #include "param_system_test.h"

int main(int argc, char **argv)
{
Expand Down

0 comments on commit c715337

Please sign in to comment.