Skip to content

Commit

Permalink
Wait for self test done flag
Browse files Browse the repository at this point in the history
  • Loading branch information
flxkrmr committed Feb 21, 2023
1 parent a47b772 commit 8ccd9f8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 84 deletions.
45 changes: 0 additions & 45 deletions lib/fault_code/fault_code_util.c

This file was deleted.

32 changes: 0 additions & 32 deletions lib/fault_code/fault_code_util.h

This file was deleted.

3 changes: 3 additions & 0 deletions src/Cart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ void Cart::handleStatusSlot() {
case CURRENT_DIAGNOSTIC_MODE:
currentDiagnosticMode = wordBuffer[0];
break;
case NEXT_DIAGNOSTIC_MODE:
nextDiagnosticMode = wordBuffer[0];
break;
case DCL_ERROR_FLAG_LOW:
memcpy(&dclErrorFlagLow, wordBuffer, 1);
break;
Expand Down
2 changes: 2 additions & 0 deletions src/Cart.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class Cart {

public:

struct IdSlot {
unsigned int rpm : 8;
unsigned int frameNumber : 4;
Expand Down Expand Up @@ -46,6 +47,7 @@ class Cart {
bool diagnosticParameterSendingDone = false;

uint8_t currentDiagnosticMode = 0;
uint8_t nextDiagnosticMode = 0;

void setBaudrate(long baudrate);
void sendStartMessage();
Expand Down
18 changes: 12 additions & 6 deletions src/EecIv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void EecIv::mainLoop() {
break;
case WAIT_FOR_SYNC_9600:
if (cart->isSynced) {
debugPrint("Synced with default baud");
startMessageCounter = 0;
currentState = REQUEST_BAUD_RATE_CHANGE;
} else {
Expand Down Expand Up @@ -79,6 +80,7 @@ void EecIv::mainLoop() {
break;
case WAIT_FOR_SYNC_2400:
if (cart->isSynced) {
debugPrint("Synced with 2400");
currentState = REQUEST_CLEAR_DCL_ERRORS;
} else {
if(exceededTimeout()) {
Expand Down Expand Up @@ -121,19 +123,22 @@ void EecIv::mainLoop() {
break;
}
case WAIT_REQUEST_CONT_SELF_TEST_CODES:
if (cart->currentDiagnosticMode == 0x26) {
if (cart->nextDiagnosticMode == 0x26) {
currentState = READ_CONT_SELF_TEST_CODES;
cart->hasData = false;
}
break;
case READ_CONT_SELF_TEST_CODES:
if (cart->hasData) {
Serial.println("Has Data");
uint8_t data[2];
cart->getData(data);
char readable[4];
sprintf(readable, "%01X%02X", data[1] & 0xF, data[0]);
onFaultCodeFinished(readable);

onKoeoReadCode(data);
}
if (cart->dclErrorFlagHigh.selfTestComplete) {
Serial.println("Self Test complete");

onKoeoFinished();
cart->enableDiagnosticParameterSending = false;
currentState = IDLE;
}
Expand Down Expand Up @@ -166,7 +171,8 @@ void EecIv::mainLoop() {
if (cart->frameDone || koeoCounter >= 12) {
onKoeoFinished();
currentState = IDLE;
cart->enableDiagnosticParameterSending = false;
// TODO test
// cart->enableDiagnosticParameterSending = false;
}

uint8_t data[2];
Expand Down
1 change: 0 additions & 1 deletion src/EecIvReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "VoltageReader.h"

extern "C" {
#include "fault_code_util.h"
#include "version.h"
}

Expand Down

0 comments on commit 8ccd9f8

Please sign in to comment.