Skip to content

Commit

Permalink
more detailed logging, extracting variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Nov 2, 2024
1 parent 57627ba commit 8a9fb29
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions digital-inputs/firmware/can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,17 @@ static void receiveRawAnalog(const uint8_t msg[CAN_FRAME_SIZE], size_t offset) {
// channel not used for this board
if (currentBoard->channels[ch].name == nullptr)
continue;
float voltage = getVoltageFrom8Bit(msg[byteIndex]) * currentBoard->channels[ch].mulCoef;

float mult = currentBoard->channels[ch].mulCoef;
float voltage = getVoltageFrom8Bit(msg[byteIndex]) * mult;
float acceptMin = currentBoard->channels[ch].acceptMin;
float acceptMax = currentBoard->channels[ch].acceptMax;

// check if in acceptable range for this board
if (voltage < currentBoard->channels[ch].acceptMin || voltage > currentBoard->channels[ch].acceptMax) {
canPacketError(" * BAD channel %d (%s): voltage %f (raw %d) not in range (%f..%f)\r\n",
if (voltage < acceptMin || voltage > acceptMax) {
canPacketError(" * BAD analog channel %d (%s): voltage %f (raw %d) not in range (%f..%f) mult=%f\r\n",
ch, currentBoard->channels[ch].name, voltage, msg[byteIndex],
currentBoard->channels[ch].acceptMin, currentBoard->channels[ch].acceptMax);
acceptMin, acceptMax,
mult);
} else {
if (!rawReported[ch]) {
rawReported[ch] = true;
Expand All @@ -214,7 +217,7 @@ static void receiveRawAnalog(const uint8_t msg[CAN_FRAME_SIZE], size_t offset) {
offset,
byteIndex,
voltage,
currentBoard->channels[ch].acceptMin, currentBoard->channels[ch].acceptMax);
acceptMin, acceptMax);
setNormalText();
}
}
Expand Down

0 comments on commit 8a9fb29

Please sign in to comment.