From 3d3873235bc8e49c2841f6a2dbfe0df711960c80 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Thu, 13 Apr 2023 02:51:26 -0400 Subject: [PATCH] mk60 byte order wrong (cherry picked from commit 9a6a53c9fad43333e29688a73e74ae0fdebb72f0) --- firmware/controllers/can/can_vss.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/firmware/controllers/can/can_vss.cpp b/firmware/controllers/can/can_vss.cpp index 17a52f5e72..d8c80ce548 100644 --- a/firmware/controllers/can/can_vss.cpp +++ b/firmware/controllers/can/can_vss.cpp @@ -34,9 +34,9 @@ expected look_up_can_id(can_vss_nbc_e type) { /* Module specitifc processing functions */ /* source: http://z4evconversion.blogspot.com/2016/07/completely-forgot-but-it-does-live-on.html */ float processBMW_e46(const CANRxFrame& frame) { - /* left front wheel speed is used here */ - uint16_t tmp = ((frame.data8[1] & 0x0f) << 8 ); - tmp |= frame.data8[0]; + // average the rear wheels since those are the driven ones (more accurate gear detection!) + uint16_t left = (((frame.data8[5] & 0x0f) << 8) | frame.data8[4]); + uint16_t right = (((frame.data8[7] & 0x0f) << 8) | frame.data8[6]); return tmp / 16.0f; } @@ -109,4 +109,4 @@ void setCanVss(int type) { canVssInfo(); } -#endif // EFI_CAN_SUPPORT \ No newline at end of file +#endif // EFI_CAN_SUPPORT