Skip to content

Commit 7d7eeb1

Browse files
authored
Merge pull request #104 from badgerloop-software/pod5_cleanup
Pre Pod5 Cleanup
2 parents 3243756 + 0b25d9e commit 7d7eeb1

File tree

12 files changed

+46
-33
lines changed

12 files changed

+46
-33
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ matrix:
1313
language: c
1414
compiler: gcc-6
1515
sudo: require
16+
dist: trusty
1617
python:
1718
- "3.4"
1819

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Badgerloop Pod IV
2-
[![Build Status](https://travis-ci.org/badgerloop-software/pod.svg?branch=master)](https://travis-ci.org/badgerloop-software/pod)
1+
# Badgerloop Pod V
2+
[![Build Status](https://travis-ci.org/badgerloop-software/pod-embedded.svg?branch=master)](https://travis-ci.org/badgerloop-software/pod-embedded)
33

4-
*Developers: Ezra Boley, Eric Udlis, Rohan Daruwala, Luke Houge, Alex Vesel*
4+
*Developers: Rohan Daruwala, Ezra Boley*
55

6-
The master repository for Badgerloop's pod in the Hyperloop Competition
6+
The embedded repository for Badgerloop's pod in the Hyperloop Competition
77

88
## Beaglebone Make Instructions
99

deploy.sh

+8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
sudo modprobe vcan
44
./embedded/utils/setupCAN.sh
55
make examples VIRTUAL=1
6+
retVal=$?
7+
if [ $retVal -ne 0 ]; then
8+
exit 1
9+
fi
610
make VIRTUAL=1
11+
retVal=$?
12+
if [ $retVal -ne 0 ]; then
13+
exit 1
14+
fi
715
python3 ./embedded/examples/sims/rms.py &
816
./out/tests/can_test
917
exit 0

embedded/app/main/badgerloop_HV.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
extern "C"
1313
{
1414
#include "bbgpio.h"
15-
#include "connStat.h"
16-
#include <signal.h>
15+
#include "connStat.h"
16+
#include <signal.h>
1717
#include <rms.h>
18-
#include "motor.h"
18+
#include "motor.h"
1919
#include "hv_iox.h"
2020
#include "motor.h"
2121
#include "proc_iox.h"

embedded/app/src/bms_fault_checking.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bool checkPrerunBattery(void){
2828
return false;
2929
}
3030
if(data->bms->cellMaxVoltage > MAX_CELL_VOLTAGE || data->bms->cellMinVoltage < MIN_CELL_VOLTAGE){
31-
printf("Cell Voltage Error: %i, %i\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
31+
printf("Cell Voltage Error: %f, %f\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
3232
return false;
3333
}
3434
if(data->bms->packVoltage > MAX_PACK_VOLTAGE || data->bms->packVoltage < MIN_PACK_VOLTAGE_PRERUN){
@@ -53,7 +53,7 @@ bool checkRunBattery(void){
5353
return false;
5454
}
5555
if(data->bms->cellMaxVoltage > MAX_CELL_VOLTAGE || data->bms->cellMinVoltage < MIN_CELL_VOLTAGE){
56-
printf("Cell Voltage Error: %i, %i\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
56+
printf("Cell Voltage Error: %f, %f\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
5757
return false;
5858
}
5959
if(data->bms->packVoltage > MAX_PACK_VOLTAGE || data->bms->packVoltage < MIN_PACK_VOLTAGE_RUN){
@@ -78,7 +78,7 @@ bool checkBrakingBattery(void){
7878
return false;
7979
}
8080
if(data->bms->cellMaxVoltage > MAX_CELL_VOLTAGE || data->bms->cellMinVoltage < MIN_CELL_VOLTAGE){
81-
printf("Cell Voltage Error: %i, %i\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
81+
printf("Cell Voltage Error: %f, %f\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
8282
return false;
8383
}
8484
if(data->bms->packVoltage > MAX_PACK_VOLTAGE || data->bms->packVoltage < MIN_PACK_VOLTAGE_RUN){
@@ -103,7 +103,7 @@ bool checkStoppedBattery(void){
103103
return false;
104104
}
105105
if(data->bms->cellMaxVoltage > MAX_CELL_VOLTAGE || data->bms->cellMinVoltage < MIN_CELL_VOLTAGE){
106-
printf("Cell Voltage Error: %i, %i\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
106+
printf("Cell Voltage Error: %f, %f\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
107107
return false;
108108
}
109109
if(data->bms->packVoltage > MAX_PACK_VOLTAGE || data->bms->packVoltage < MIN_PACK_VOLTAGE_RUN){
@@ -128,7 +128,7 @@ bool checkCrawlBattery(void){
128128
return false;
129129
}
130130
if(data->bms->cellMaxVoltage > MAX_CELL_VOLTAGE || data->bms->cellMinVoltage < MIN_CELL_VOLTAGE){
131-
printf("Cell Voltage Error: %i, %i\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
131+
printf("Cell Voltage Error: %f, %f\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
132132
return false;
133133
}
134134
if(data->bms->packVoltage > MAX_PACK_VOLTAGE || data->bms->packVoltage < MIN_PACK_VOLTAGE_POSTRUN){
@@ -153,7 +153,7 @@ bool checkPostrunBattery(void){
153153
return false;
154154
}
155155
if(data->bms->cellMaxVoltage > MAX_CELL_VOLTAGE || data->bms->cellMinVoltage < MIN_CELL_VOLTAGE){
156-
printf("Cell Voltage Error: %i, %i\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
156+
printf("Cell Voltage Error: %f, %f\n", data->bms->cellMinVoltage, data->bms->cellMaxVoltage);
157157
return false;
158158
}
159159
if(data->bms->packVoltage > MAX_PACK_VOLTAGE || data->bms->packVoltage < MIN_PACK_VOLTAGE_POSTRUN){

embedded/app/src/motor.c

+6-8
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@
1616

1717

1818
/* Thread management variables */
19-
static pthread_mutex_t torqueLock, motorLock;
20-
static sem_t hbSem;
21-
static pthread_t hbLoop;
22-
static bool JOIN_HB_THREAD = false;
23-
24-
static void *motorHeartbeatLoop(void *);
2519
extern int rmsInvEnNoTorque();
20+
2621
/* Create the semaphores and mutexes for thread sensitive operations
2722
* and creates the HB loop that just waits for the motor to be started
2823
*/
@@ -31,7 +26,7 @@ extern int rmsInvEnNoTorque();
3126
static pthread_t hbThread;
3227
static bool motorEnabled = false;
3328
static bool lowTorqueMode = false;
34-
static void motorHbLoop();
29+
static void *motorHbLoop(void *arg);
3530

3631
void setMotorEn() {
3732
motorEnabled = true;
@@ -53,7 +48,8 @@ void SetupMotor() {
5348
pthread_create(&hbThread, NULL, (motorHbLoop), NULL);
5449
}
5550

56-
static void motorHbLoop() {
51+
static void *motorHbLoop(void *arg) {
52+
(void) arg;
5753
while(1) {
5854
if (motorEnabled)
5955
rmsSendHbMsg(2);
@@ -63,5 +59,7 @@ static void motorHbLoop() {
6359
rmsIdleHb();
6460
usleep(10000);
6561
}
62+
63+
return NULL;
6664
}
6765

embedded/app/src/nav.c

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ void resetNav() {
146146
* 2. Are we going in X or Y plane
147147
*/
148148
void navLoop(void *unused) {
149+
(void) unused;
150+
149151
int lastRetroCount = 0;
150152
data->motion->missedRetro = 0;
151153
csvFormatHeader();

embedded/peripherals/src/imu.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ void *IMULoop(void *arg){
6969
unsigned char res1[4];
7070
uint32_t tempx, tempy, tempz;
7171
int i;
72-
uint64_t curr, prev, delt;
73-
prev = getuSTimestamp();
72+
//uint64_t curr, prev;
73+
// uint64_t delt;
74+
//prev = getuSTimestamp();
7475
while (1){
7576
i = 0;
7677
// Information on data registers can be found @ https://www.xsens.com/download/pdf/documentation/mti-1/mti-1-series_datasheet.pdf
@@ -86,7 +87,7 @@ void *IMULoop(void *arg){
8687
unsigned char dataBuffer[messageSize];
8788
read_i2c(i2c, dataBuffer, messageSize);
8889
i = 0;
89-
curr = getuSTimestamp();
90+
//curr = getuSTimestamp();
9091
while(i < messageSize){
9192
//Check delta velocity
9293

@@ -120,7 +121,7 @@ void *IMULoop(void *arg){
120121
data->accelY = * ((float *) &tempy);
121122
data->accelZ = * ((float *) &tempz);
122123

123-
delt = curr - prev;
124+
//delt = curr - prev;
124125

125126
data->velX = data->velX + (data->accelX * .025);
126127
data->velY = data->velY + (data->accelY * .025);
@@ -142,7 +143,7 @@ void *IMULoop(void *arg){
142143
data->posY += data->velY * .025;
143144
data->posZ += data->velZ * .025;
144145
sem_post(&data->mutex);
145-
prev = curr;
146+
//prev = curr;
146147
usleep(10000);
147148

148149
}

embedded/peripherals/src/retro.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static bool blockInts = true;
3535
static int onTapeStrip (int retroNum);
3636
static void * waitForStrip (void * retroNum);
3737
static int getPin(int retroNum);
38-
static void * blockSpuriousInts(uint64_t timeout);
38+
static void * blockSpuriousInts(int timeout);
3939

4040

4141
/***
@@ -50,7 +50,7 @@ int initRetros() {
5050
if (bbGpioExport(getPin(i)) != 0) return -1;
5151
if (bbGpioSetDir(getPin(i), IN_DIR) != 0) return -1;
5252
if (bbGpioSetEdge(getPin(i), RISING_EDGE) != 0) return -1;
53-
if (pthread_create(&retroThreads[i], NULL, waitForStrip, (void *) i) != 0)
53+
if (pthread_create(&retroThreads[i], NULL, waitForStrip, (void *)(intptr_t) i) != 0)
5454
return -1;
5555
}
5656

@@ -139,7 +139,7 @@ static int onTapeStrip(int retroNum) {
139139
* void *num - an identifier for which retro is running the thread
140140
***/
141141
static void *waitForStrip(void *num) {
142-
int retroNum = (int) num;
142+
int retroNum = (intptr_t) num;
143143
int gpioFd = bbGpioFdOpen(getPin(retroNum));
144144
struct pollfd fds[1];
145145
int nfds = 1;
@@ -192,7 +192,7 @@ static int getPin(int retroNum) {
192192
return -1; /* Will never get here */
193193
}
194194

195-
static void *blockSpuriousInts(uint64_t timeout) {
195+
static void *blockSpuriousInts(int timeout) {
196196
blockInts = true;
197197
usleep(timeout);
198198
blockInts = false;

embedded/peripherals/src/rms.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ int rms_parser(uint32_t id, uint8_t *rmsData, uint32_t filter){
168168
return 1;
169169
}
170170
uint16_t val;
171-
uint16_t val2;
171+
//uint16_t val2;
172172
int16_t temp;
173173
switch(id){
174174
case (0xa0):

middleware/src/HVTCPSocket.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ bool motorIsEnabled, noTorqueMode;
3232
pthread_t hbT;
3333
extern stateMachine_t stateMachine;
3434
void *hbLoop(void *nul) {
35+
36+
(void) nul;
37+
3538
while (1) {
3639
if (motorIsEnabled) {
3740
rmsInvEn();
@@ -182,7 +185,7 @@ void *TCPLoop(void *arg)
182185

183186
if(!strncmp(buffer,"override", 8)){
184187
fprintf(stderr, "Override received for state: %s\n", buffer+9);
185-
sprintf(stateMachine.overrideStateName, "%s\0", buffer+9);
188+
sprintf(stateMachine.overrideStateName, "%s%c", buffer+9, '\0');
186189
}
187190

188191
// HEARTBEAT

middleware/src/data_dump.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void *DataLoop(void *arg){
7070
fprintf(fp, "%f,%f,%f,%i,", data->motion->pos, data->motion->vel, data->motion->accel, data->motion->retroCount);
7171

7272
// BMS
73-
fprintf(fp, "%f,%f,%hu,%hx,%hu,%hu,%f,%hu,%hu,%f,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,", data->bms->packCurrent, data->bms->packVoltage, data->bms->packDCL, data->bms->packCCL, data->bms->packResistance, data->bms->packHealth, data->bms->packOpenVoltage, data->bms->packCycles, data->bms->packAh, data->bms->inputVoltage, data->bms->Soc, data->bms->relayStatus, data->bms->highTemp, data->bms->lowTemp, data->bms->cellMaxVoltage, data->bms->cellMinVoltage, data->bms->cellAvgVoltage, data->bms->maxCells, data->bms->numCells);
73+
fprintf(fp, "%f,%f,%hu,%hx,%hu,%hu,%f,%hu,%hu,%f,%hu,%hu,%hu,%hu,%hu,%hu,%f,%f,%hu,", data->bms->packCurrent, data->bms->packVoltage, data->bms->packDCL, data->bms->packCCL, data->bms->packResistance, data->bms->packHealth, data->bms->packOpenVoltage, data->bms->packCycles, data->bms->packAh, data->bms->inputVoltage, data->bms->Soc, data->bms->relayStatus, data->bms->highTemp, data->bms->lowTemp, data->bms->cellMaxVoltage, data->bms->cellMinVoltage, data->bms->cellAvgVoltage, data->bms->maxCells, data->bms->numCells);
7474

7575
// RMS
7676
fprintf(fp, "%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%lu,%lu,%lu,%lu,%hu,%hu,%hu,%hu,%hu,%hu\n", data->rms->igbtTemp, data->rms->gateDriverBoardTemp, data->rms->controlBoardTemp, data->rms->motorTemp, data->rms->motorSpeed, data->rms->phaseACurrent, data->rms->phaseBCurrent, data->rms->phaseCCurrent, data->rms->dcBusVoltage, data->rms->lvVoltage, data->rms->canCode1, data->rms->canCode2, data->rms->faultCode1, data->rms->faultCode2, data->rms->commandedTorque, data->rms->actualTorque, data->rms->relayState, data->rms->electricalFreq, data->rms->dcBusCurrent, data->rms->outputVoltageLn);

0 commit comments

Comments
 (0)