Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/cangaroo.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion src/core/CanDbSignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void CanDbSignal::setMuxValue(const uint32_t &muxValue)

bool CanDbSignal::isPresentInMessage(const CanMessage &msg)
{
if ((_startBit + _length)>(8*msg.getLength())) {
if ((_startBit + _length)>(8*msg.getLength()) && !_isBigEndian) {
return false;
}

Expand Down
39 changes: 28 additions & 11 deletions src/core/CanMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,34 @@ void CanMessage::setByte(const uint8_t index, const uint8_t value) {

uint64_t CanMessage::extractRawSignal(uint8_t start_bit, const uint8_t length, const bool isBigEndian) const
{
if(isBigEndian)
{
int firstByte = start_bit / 8;
uint64_t data = _u8[firstByte];
data &= (0xFF >> (7 - start_bit%8));

int lastByte = firstByte;
int len = length - (start_bit%8 + 1);

if(len > 0)
lastByte += (len/8)+1;

for(int i = firstByte; i < lastByte; i++)
{
data <<= 8;
data |= _u8[i+1];
}

int shiftAmount = start_bit%8 - length%8 + 1;
if(shiftAmount < 0)
shiftAmount += 8;
else if(shiftAmount == 8)
shiftAmount = 0;
data >>= shiftAmount;

return data;
}

// if ((start_bit+length) > (getLength()*8)) {
// return 0;
// }
Expand All @@ -199,17 +227,6 @@ uint64_t CanMessage::extractRawSignal(uint8_t start_bit, const uint8_t length, c

data &= mask;

// If the length is greater than 8, we need to byteswap to preserve endianness
if (isBigEndian && (length > 8))
{

// Swap bytes
data = __builtin_bswap64(data);

// Shift out unused bits
data >>= 64 - length;
}

return data;
}

Expand Down
15 changes: 0 additions & 15 deletions src/parser/dbc/DbcParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,21 +552,6 @@ bool DbcParser::parseSectionBoSg(CanDb &candb, CanDbMessage *msg, DbcTokenList &
if (!expectInt(tokens, &byte_order)) { return false; }
signal->setIsBigEndian(byte_order==0);

// If the signal is big endian, convert the start bit to the Intel-style start bit for further parsing
if(signal->isBigEndian())
{
// This will be the number of 8-bit rows above the message
uint8_t row_position = signal->startBit() >> 3;

// Bit position in current row (0-7)
uint8_t column_position = signal->startBit() & 0b111;

// Calcualte the normalized start bit position (bit index starting at 0)
uint8_t normalized_position = (row_position * 8) + (7 - column_position);

signal->setStartBit(normalized_position);
}

if (expectAndSkipToken(tokens, dbc_tok_plus)) {
signal->setUnsigned(true);
} else {
Expand Down