Tattu 3.0 Battery 18S is not dronecan compatible, how to decode CAN Messages?

My goodness. Glad that someone is happy decoding/reverse engineering :smiley:

Here is my summary of decoding Highlighted in yellow.
log of battery with serial number 17 with current.txt (361.8 KB)
.

Not able to identify the head and tail of a full-blown CAN message. Also it seems the battery-cell voltage for 18 Cells seems to be scattered across many 8-byte sub-message and the 8-byte messages are non-contiguous(inter-leaved with 2-byte messages).

Here is my rough-decoding of 8-byte sub-message
Channel:1 Extended ID:1109216 DLC: 8 buf: 0x1A 0x74 0xFF 0x17 0x0 0x37 0x0 0x21

Arduino Sketch for STM32 bluepill to conduit CAN messages received from TJA1050 transceiver to the laptop is attached here.

#include "stm32f1xx_hal_can.h"
#include <STM32_CAN.h>

/*
This example reads all data from CAN bus, prints it to serial,
and continuously blinks an LED independently of CAN messages.
*/

//STM32_CAN Can( CAN1, DEF );  //Use PA11/12 pins for CAN1.
STM32_CAN Can( CAN1, ALT );  //Use PB8/9 pins for CAN1.

static CAN_message_t CAN_RX_msg;

// LED pin (Blue Pill onboard LED)
#define LED_PIN PC13

// Timing variables for non-blocking LED
unsigned long previousMillis = 0;
const unsigned long interval = 5000; // 5 seconds
bool ledState = false;

void setup() {
  Serial.begin(9600);
  Can.begin();
  Can.setBaudRate(1000000);  //1000KBPS

  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);  //LED OFF initially
}

void loop() {
  unsigned long currentMillis = millis();

  // Handle LED blinking
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    ledState = !ledState;            // Toggle LED state
    //Serial.println("Blinking LED:");

    digitalWrite(LED_PIN, ledState ? HIGH : LOW);
  }

  // Check CAN messages
  if (Can.read(CAN_RX_msg)) {
    // Print CAN message
    Serial.print("Channel:");
    Serial.print(CAN_RX_msg.bus);
    if (CAN_RX_msg.flags.extended == false) {
      Serial.print(" Standard ID:");
    } else {
      Serial.print(" Extended ID:");
    }
    Serial.print(CAN_RX_msg.id, HEX);

    Serial.print(" DLC: ");
    Serial.print(CAN_RX_msg.len);
    if (CAN_RX_msg.flags.remote == false) {
      Serial.print(" buf: ");
      for (int i = 0; i < CAN_RX_msg.len; i++) {
        Serial.print("0x");
        Serial.print(CAN_RX_msg.buf[i], HEX);
        if (i != (CAN_RX_msg.len - 1)) Serial.print(" ");
      }
      Serial.println();
    } else {
      Serial.println(" Data: REMOTE REQUEST FRAME");
    }
  }
}

1 Like