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 993e989 commit 2a1bd87
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
1 change: 0 additions & 1 deletion digital-inputs/firmware/can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ static void receiveOutputMetaInfo(const uint8_t msg[CAN_FRAME_SIZE]) {
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 also %d DC\r\n", outputCount, lowSideOutputCount);
}
Expand Down
34 changes: 16 additions & 18 deletions digital-inputs/firmware/test_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// 10% for low voltage
#define ANALOG_H_FOR_LOW_VOLTAGE (1.0f + 0.12f)

#define LAST_DIGITAL_PIN 39

#define HELLEN_VBATT_MULT 5.835f
#define HELLEN_R 4700
#define ALPHA2CH_R 2700
Expand Down Expand Up @@ -258,7 +260,7 @@ size_t getBoardsCount() {

typedef void (*CanRequestSender) (int testLineIndex, bool value);

bool doTestEcuDigitalOutput(int testLineIndex, bool isLowSide, CanRequestSender sender) {
static bool doTestEcuDigitalOutput(int testLineIndex, bool isLowSide, CanRequestSender sender, bool expectation) {
static DigitalResult result;
memset(&result, 0, sizeof(result));

Expand Down Expand Up @@ -299,7 +301,7 @@ bool doTestEcuDigitalOutput(int testLineIndex, bool isLowSide, CanRequestSender

// chprintf(chp, "scenario=%d: %1.3f V\r\n", scenarioIndex, voltage);

bool cycleIsGood = (isHigh == isSet);
bool cycleIsGood = (isHigh == isSet) == expectation;
if (!cycleIsGood) {
setErrorLedAndRedText();
chprintf(chp, "ERROR! Line %d@%d FAILED! (set %d, received %d %1.3fv)\r\n",
Expand All @@ -316,33 +318,29 @@ bool doTestEcuDigitalOutput(int testLineIndex, bool isLowSide, CanRequestSender
bool testEcuDigitalOutput(int testLineIndex, bool isLowSide) {
return doTestEcuDigitalOutput(testLineIndex, isLowSide, [](int testLineIndex, bool value) {
sendCanPinState(testLineIndex, value);
});
}, true);
}

// lazy way to get value into lambda
static int globalDcIndex = 0;

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

CanRequestSender sender = [](int testLineIndex, bool value) {
sendCanDcState(0, value);
sendCanDcState(globalDcIndex, value);
};

// toggle the ECU pin for low side mode

doTestEcuDigitalOutput(39, 0, sender);
chThdSleepMilliseconds(1000);
bool isGood = true;

doTestEcuDigitalOutput(39, 1, sender);
chThdSleepMilliseconds(1000);
isGood = isGood & doTestEcuDigitalOutput(LAST_DIGITAL_PIN - 2 * globalDcIndex, 0, sender, false);
isGood = isGood & doTestEcuDigitalOutput(LAST_DIGITAL_PIN - 2 * globalDcIndex, 1, sender, true);
isGood = isGood & doTestEcuDigitalOutput(LAST_DIGITAL_PIN - 2 * globalDcIndex - 1, 0, sender, true);
isGood = isGood & doTestEcuDigitalOutput(LAST_DIGITAL_PIN - 2 * globalDcIndex - 1, 1, sender, false);

doTestEcuDigitalOutput(39, 0, sender);
chThdSleepMilliseconds(1000);

doTestEcuDigitalOutput(39, 1, sender);
chThdSleepMilliseconds(1000);
return true;
return isGood;
}


size_t totalStepsNumber() {
return getDigitalInputStepsCount()
+ getDigitalOutputStepsCount()
Expand Down

0 comments on commit 2a1bd87

Please sign in to comment.