xR3b0rn / dbcppp

C/C++ DBC file parser/tool
MIT License
223 stars 72 forks source link

motorola byte order in dbc file makes layout dispaly incorrectly #143

Open Jimmy-drod opened 8 months ago

Jimmy-drod commented 8 months ago

when use this command :dbcppp dbc2 --dbc=file.dbc --format=human, and the signals is motorola byte order in file.dbc, the layout does not display correctly, It no longer plots the signal position.

Jimmy-drod commented 8 months ago

another problem is : it seems in function _bool bit_is_inbetween(const ISignal& sig, std::size_t i_bit, uint64_t switchvalue = -1) (called by auto iter = std::find_if(beg, end, [&](const ISignal& sig) { return bit_is_inbetween(sig, i_bit, mux_value); });)

case ISignal::EByteOrder::BigEndian:
    {
        std::size_t start = sig.StartBit();
        std::size_t n = sig.BitSize();
        while (n)
        {
            if (start == i_bit)
            {
                return true;
            }
            if (start % 8 == 0)
            {
                start += 15;
            }
            else
            {
                start--;
            }
            n--;
        }
        return true;
    }

No matter what the value of i_bit is, it will always return true on this branch, resulting in only the first signal being parsed.

Jimmy-drod commented 8 months ago

I made a PR,please confirm.

BR