Skip to content

Commit

Permalink
ETB HW QC #253
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Oct 30, 2023
1 parent 6bb1c09 commit 7693ea7
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
15 changes: 13 additions & 2 deletions digital-inputs/firmware/can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static bool hasReceivedAnalog = false;
static bool hasReceivedBoardId = false;
static CounterStatus counterStatus;
static int outputCount = 0;
static int dcOutputsCount = 0;
static int lowSideOutputCount = 0;

extern bool globalEverythingHappy;
Expand All @@ -48,7 +49,7 @@ void startNewCanTest() {
hasReceivedAnalog = false;
hasReceivedBoardId = false;
currentBoard = nullptr;
outputCount = 0;
dcOutputsCount = outputCount = 0;
lowSideOutputCount = 0;
// reset
counterStatus = CounterStatus();
Expand Down Expand Up @@ -97,6 +98,10 @@ int getDigitalOutputStepsCount() {
return outputCount;
}

int getDigitalDcOutputStepsCount() {
return dcOutputsCount;
}

int getLowSideOutputCount() {
return lowSideOutputCount;
}
Expand Down Expand Up @@ -147,8 +152,10 @@ static void receiveOutputMetaInfo(const uint8_t msg[CAN_FRAME_SIZE]) {
if (msg[0] == BENCH_HEADER) {
outputCount = msg[2];
lowSideOutputCount = msg[3];
dcOutputsCount = msg[4];
dcOutputsCount = 1;
if (outputMode.displayCanReceive && !isMuted) {
chprintf(chp, " CAN ECU says: total=%d outputs of which low side=%d \r\n", outputCount, lowSideOutputCount);
chprintf(chp, " CAN ECU says: total=%d outputs of which low side=%d also %d DC\r\n", outputCount, lowSideOutputCount);
}
}
}
Expand Down Expand Up @@ -245,6 +252,10 @@ void sendCanPinState(uint8_t pinIdx, bool isSet) {
sendCanTxMessage((int)bench_test_packet_ids_e::IO_CONTROL, { BENCH_HEADER, (uint8_t)(isSet ? (int)bench_test_io_control_e::CAN_QC_OUTPUT_CONTROL_SET : (int)bench_test_io_control_e::CAN_QC_OUTPUT_CONTROL_CLEAR), pinIdx });
}

void sendCanDcState(uint8_t dcIndex, bool isSet) {
sendCanTxMessage((int)bench_test_packet_ids_e::IO_CONTROL, { BENCH_HEADER, (int)bench_test_io_control_e::CAN_QC_ETB, dcIndex, isSet });
}

void setOutputCountRequest() {
sendCanTxMessage((int)bench_test_packet_ids_e::IO_CONTROL, { BENCH_HEADER, (int)bench_test_io_control_e::CAN_BENCH_GET_COUNT });
}
Expand Down
3 changes: 2 additions & 1 deletion digital-inputs/firmware/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ void startNewCanTest();
bool isHappyCanTest();
bool checkDigitalInputCounterStatus();
int getDigitalOutputStepsCount();
int getDigitalDcOutputStepsCount();
int getLowSideOutputCount();
void setOutputCountRequest();
void sendCanPinState(uint8_t pinIdx, bool isSet);

void sendCanDcState(uint8_t index, bool isSet);

22 changes: 19 additions & 3 deletions digital-inputs/firmware/test_digital_outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,32 @@ void initStimDigitalInputs() {

extern bool globalEverythingHappy;

bool testEcuDigitalOutputs(size_t startStepIndex) {
bool isGood = true;

static void waitForMetaInfo() {
int timeout = 0;

#define SLEEP_CHUNK 100
while (getDigitalOutputStepsCount() <= 0 && currentBoard == nullptr && timeout < (5000 / SLEEP_CHUNK)) {
chThdSleepMilliseconds(SLEEP_CHUNK);
timeout ++;
}
}

bool testEcuDcOutputs(size_t startStepIndex) {
waitForMetaInfo();

bool isGood = true;

int numOutputs = 1000000;//getDigitalDcOutputStepsCount();
for (size_t currentIndex = 0; currentIndex < numOutputs; currentIndex++) {
testDcOutput();
}
return true;
}

bool testEcuDigitalOutputs(size_t startStepIndex) {
waitForMetaInfo();

bool isGood = true;

int numOutputs = getDigitalOutputStepsCount();
int lowSideOutputs = getLowSideOutputCount();
Expand Down
1 change: 1 addition & 0 deletions digital-inputs/firmware/test_digital_outputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

void initStimDigitalInputs();
bool testEcuDigitalOutputs(size_t startStepIndex);
bool testEcuDcOutputs(size_t startStepIndex);

/**
* controls what input channel we are sensing
Expand Down
20 changes: 19 additions & 1 deletion digital-inputs/firmware/test_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,21 @@ size_t getBoardsCount() {
return efi::size(boardConfigs);
}

bool testDcOutput() {
chprintf(chp, "sending DC\r\n");

// toggle the ECU pin for low side mode
sendCanDcState(0, 0);
chThdSleepMilliseconds(1000);
sendCanDcState(0, 1);
chThdSleepMilliseconds(1000);
sendCanDcState(0, 0);
chThdSleepMilliseconds(1000);
sendCanDcState(0, 1);
chThdSleepMilliseconds(1000);
return true;
}

bool testEcuDigitalOutput(int testLineIndex, bool isLowSide) {
memset(haveSeenLow, 0, sizeof(haveSeenLow));
memset(haveSeenHigh, 0, sizeof(haveSeenHigh));
Expand Down Expand Up @@ -308,5 +323,8 @@ bool testEcuDigitalOutput(int testLineIndex, bool isLowSide) {
}

size_t totalStepsNumber() {
return getDigitalInputStepsCount() + getDigitalOutputStepsCount();
return getDigitalInputStepsCount()
+ getDigitalOutputStepsCount()
+ getDigitalDcOutputStepsCount()
;
}
1 change: 1 addition & 0 deletions digital-inputs/firmware/test_logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define DIGITAL_INPUT_BANK_SIZE 16

bool testEcuDigitalOutput(int testLineIndex, bool isLowSide);
bool testDcOutput();

class Counter {
public:
Expand Down

0 comments on commit 7693ea7

Please sign in to comment.