Skip to content

Hv iox refactor #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
27ea01d
Added hviox.cpp to cmake
EUdds Jan 1, 2021
8c0bbc1
{first commit plz help}
Jan 1, 2021
48c86af
Added boolean to replace return -1
Jan 2, 2021
e0a699f
Merge branch 'hvIOX_refactor' of https://github.com/badgerloop-softwa…
Jan 2, 2021
0ed594a
added semicolon to end of class definition
mjkpolo Jan 2, 2021
d5c8b86
changed header file for hv_iox.cpp
mjkpolo Jan 2, 2021
16b6ffe
added extern HVIox and syntax adjustments
mjkpolo Jan 2, 2021
082ed09
Changed function to OO notation in autogenerator
mjkpolo Jan 3, 2021
a4e8be7
changed syntax to write constructor method
mjkpolo Jan 3, 2021
a91fb4b
changing to cpp
mjkpolo Jan 3, 2021
44cb5af
messed up states.c
Jan 3, 2021
685e1f6
forgot to do git add states.cpp ooops
mjkpolo Jan 3, 2021
b0c84d6
Merge branch 'master' of https://github.com/badgerloop-software/pod-e…
mjkpolo Jan 3, 2021
65c7e30
Updating references
EUdds Jan 3, 2021
0cad59b
Changed to static mem allocation
EUdds Jan 3, 2021
79e48f1
Fixed EVERY reference to the HV iox
EUdds Jan 3, 2021
cd6d25a
adding test
mjkpolo Jan 5, 2021
fcfff64
created test file
mjkpolo Jan 5, 2021
e4b2349
adding test methods
mjkpolo Jan 10, 2021
817b62b
adding test methods
mjkpolo Jan 10, 2021
37d8766
forgot git add
mjkpolo Jan 10, 2021
2f9ea43
no clue what I'm doing
mjkpolo Jan 10, 2021
5a9336a
Gtest template
EUdds Jan 10, 2021
c3dd9cb
added setMCULatch and isHVIndicatorEnabled testers with #ifdef NOI2C
mjkpolo Jan 10, 2021
dec6856
Fixed data references in tests
EUdds Jan 10, 2021
d88710d
added #else for NOI2C
mjkpolo Jan 10, 2021
c1f5c96
Files for nonVSCode autocomplete
Jan 11, 2021
e72e1e4
added tests plz correct if wrong so I don't keep going
mjkpolo Jan 11, 2021
8d65e70
hv_iox test methods
mjkpolo Jan 13, 2021
5820e14
changed my directory because I made a new docker container
mjkpolo Jan 14, 2021
75f7e51
messing w docker ignore
mjkpolo Jan 14, 2021
49f3cd3
makes more sense
mjkpolo Jan 14, 2021
db4524b
added compile_comands.json to .gitignore
mjkpolo Jan 14, 2021
f4fa450
finished test methods for hv_iox
mjkpolo Jan 15, 2021
2256606
added git clean cuz there were build errors ugh idk what I'm doing
mjkpolo Jan 15, 2021
27e9b5b
Update gen_compile_commands
mjkpolo Jan 15, 2021
b786037
.gitignore not workingggg
mjkpolo Jan 15, 2021
d28238e
solved just needed to remove -x flag
mjkpolo Jan 15, 2021
9df7262
return int for init method
mjkpolo Jan 15, 2021
06af7d0
Merged with master
EUdds Jan 17, 2021
9ec7bff
added else statements and comments to test
mjkpolo Jan 17, 2021
d81371e
forgot to remove isInit
mjkpolo Jan 17, 2021
5a3ef55
not needed my b
mjkpolo Jan 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
RawStringFormats:
- Delimiter: pb
Language: TextProto
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,6 @@ cmake-build-debug/

# Autocoder Python
*.pyc

# c compile json
compile_commands.json
2 changes: 2 additions & 0 deletions Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project(testlib VERSION 1.0
LANGUAGES CXX)

# Define sources
set(dependencies example/Test_GTest.cpp)
set(dependencies components/HV_Iox/Test_HV_Iox.cpp)
set(dependencies example/Test_GTest.cpp
run_profiles/Test_load_software_parameters.cpp)

Expand Down
77 changes: 77 additions & 0 deletions Test/components/HV_Iox/Test_HV_Iox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Author: Marco
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add some comments to these tests so that someone who doesn't know what the functions are can tell what exactly is failing/passing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

#include <gtest/gtest.h>
#include <hv_iox.h>

TEST(HV_IOX, VerifyHVIox)
{
HVIox hv_iox;
hv_iox.init(true);
EXPECT_EQ(hv_iox.setupIox(), 0);
// The expected output of the functions is generic
// when not connected to the I2C bus
#ifdef NOI2C
// expected to equal 1
EXPECT_EQ(hv_iox.isHVIndicatorEnabled(), 1);
// The expected output of the functions is
// != -1 because the function returns
// the getState method when connected
// to the I2C bus
#else
// expected to not equal -1
hv_iox.setMCUHVEnabled(false);
EXPECT_NE(hv_iox.isHVIndicatorEnabled(), -1);
#endif
}

TEST(HV_IOX, HVIOX_MCU_LATCH)
{
HVIox hv_iox;
hv_iox.init(true);
#ifdef NOI2C
EXPECT_EQ(hv_iox.setMCULatch(true), 0);
EXPECT_EQ(hv_iox.setMCULatch(false), 0);
#else
EXPECT_EQ(hv_iox.setMCULatch(true), 1);
EXPECT_EQ(hv_iox.setMCULatch(false), 1);
#endif
}

TEST(HV_IOX, HVIOX_STATES)
{
HVIox hv_iox;
hv_iox.init(true);
#ifdef NOI2C
EXPECT_EQ(hv_iox.getBMSMultiIn(), 1);
EXPECT_EQ(hv_iox.getIMDStatus(), 1);
EXPECT_EQ(hv_iox.getINRTStatus(), 1);
EXPECT_EQ(hv_iox.isHVEnabled(), 0);
EXPECT_EQ(hv_iox.getPsStatus(), 1);
EXPECT_EQ(hv_iox.getBMSStatus(), 1);
EXPECT_EQ(hv_iox.isEStopOn(), 0);
EXPECT_EQ(hv_iox.getMasterSwFeedback(), 1);
#else
EXPECT_NE(hv_iox.getBMSMultiIn(), -1);
EXPECT_EQ(hv_iox.getIMDStatus(), true);
EXPECT_NE(hv_iox.getINRTStatus(), -1);
EXPECT_NE(hv_iox.isHVEnabled(), -1);
EXPECT_NE(hv_iox.getPsStatus(), -1);
EXPECT_NE(hv_iox.getBMSStatus(), -1);
EXPECT_NE(hv_iox.isEStopOn(), -1);
EXPECT_NE(hv_iox.getMasterSwFeedback(), -1);
#endif
}

TEST(HV_IOX, HVIOX_MCUHV)
{
HVIox hv_iox;
hv_iox.init(true);
#ifdef NOI2C
EXPECT_EQ(hv_iox.setMCUHVEnabled(true), 1);
EXPECT_EQ(hv_iox.isMCUHVEnabled(), 1);
EXPECT_EQ(hv_iox.emergencyDisableMCU(), 1);
#else
EXPECT_NE(hv_iox.setMCUHVEnabled(true), -1);
EXPECT_NE(hv_iox.isMCUHVEnabled(), -1);
EXPECT_NE(hv_iox.emergencyDisableMCU(), -1);
#endif
}
6 changes: 5 additions & 1 deletion Test/run_all_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#include "gtest_globals.h"
#include <gtest/gtest.h>

char executable_path[128];
extern "C" {
#include <data.h>
}

char executable_path[128];
// Run all GTest Tests
int main(int argc, char** argv)
{
initData();
// Set executable path
strcpy(executable_path, argv[0]);

Expand Down
7 changes: 3 additions & 4 deletions autocoding/templates/TelemetryLoop.template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#include <unistd.h>
#include <vector>

extern "C" {
#include <data.h>
#include <hv_iox.h>
extern "C" {
#include <lv_iox.h>
}

Expand Down Expand Up @@ -96,7 +95,7 @@ void* TelemetryLoop(void* arg)
addToBuffer(&buffer, &time);

// Write 1 byte IMD status
uint8_t imdStatus = getIMDStatus();
uint8_t imdStatus = hv_iox.getIMDStatus();
addToBuffer(&buffer, &imdStatus);

// Write 4 byte primary brake
Expand Down Expand Up @@ -139,4 +138,4 @@ void* TelemetryLoop(void* arg)
cerr << e.what() << endl;
exit(1);
}
}
}
8 changes: 4 additions & 4 deletions embedded/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ project(applib VERSION 1.0
#and it's SUPER discouraged.
set(dependecies src/bms_fault_checking.c
src/nav.c
src/state_machine.c
src/state_machine.cpp
src/init.c
src/load_software_parameters.c
src/pressure_fault_checking.c
src/states.c
src/motor.c
src/states.cpp
src/motor.cpp
src/rms_fault_checking.c
src/transitions.c)
src/transitions.cpp)

#required libraries for the main pod executables
set(libraries middleware
Expand Down
47 changes: 25 additions & 22 deletions embedded/app/main/badgerloop.cpp
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
// Includes
#include "HVTCPSocket.h"
#include "data_dump.h"
#include "hv_iox.h"
#include "motor.h"
#include "state_machine.h"
#include <TelemetryLoop.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "hv_iox.h"
#include "state_machine.h"
#include "motor.h"

// Temp
#include <chrono>
#include <ctime>
#include <iostream>

extern "C"
{
#include "bbgpio.h"
#include "connStat.h"
#include <signal.h>
#include <rms.h>
#include "motor.h"
#include "hv_iox.h"
#include "motor.h"
#include "proc_iox.h"
#include "data.h"
#include "can_devices.h"
#include "state_machine.h"
#include "NCD9830DBR2G.h"
#include "nav.h"

// Software Parameter Loading
#include "load_software_parameters.h"
#include "software_parameters.h"
extern "C" {
#include "NCD9830DBR2G.h"
#include "bbgpio.h"
#include "can_devices.h"
#include "connStat.h"
#include "data.h"
#include "nav.h"
#include "proc_iox.h"
#include <rms.h>
#include <signal.h>

// Software Parameter Loading
#include "load_software_parameters.h"
#include "software_parameters.h"
}

HVIox hv_iox;

void emergQuitter(int sig, siginfo_t* inf, void* nul)
{
printf("shutdown\n");
setMCUHVEnabled(false);
hv_iox.setMCUHVEnabled(false);
rmsCmdNoTorque();
sleep(1);
rmsDischarge();
Expand Down Expand Up @@ -67,7 +70,7 @@ int init(char* directory)
success_status = 1;
}

if (initHVIox(true)) {
if (hv_iox.init(true)) {
success_status = 1;
}

Expand All @@ -85,7 +88,7 @@ int init(char* directory)

initNav();

struct sigaction sig;
struct sigaction sig;
sig.sa_sigaction = emergQuitter;
sigaction(SIGINT, &sig, NULL);

Expand Down
Loading