#include <stdio.h>
#include <string.h>

#define MAX_CAN_PORT 2
#define MAX_LECU_CNT 256
#define MAX_FRAME_NUMBER 256
#define CAN_DATA_LEN 8

enum
{
    FUNC_BRIEF_INFO = 0,     // CAN ID 2xx
    FUNC_DETAIL_INFO,        // CAN ID 3xx
    FUNC_CONF_INFO,          // CAN ID 4xx
    FUNC_CHARGE_CUR,         // 充电电流 CAN ID 5xx
    FUNC_BALANCE_STATUS_731, // CAN ID 731, 均衡模块状态信息
    FUNC_BALANCE_STATUS_732, // CAN ID 732, 均衡模块断线检测
    FUNC_BALANCE_STATUS_733, // CAN ID 733, 箱间均衡信息
    FUNC_BALANCE_STATUS_734, // CAN ID 734, 均衡模块门限信息
    FUNC_BALANCE_STATUS_735, // CAN ID 735, 均衡模块概要信息
    FUNC_BALANCE_STATUS_736, // CAN ID 736, 均衡模块电压信息
    FUNC_CTRL_720,           // CAN ID 720, 配置均衡板
    FUNC_CTRL_721,           // CAN ID 721, 配置均衡板返回
    FUNC_CTRL_7FA,           // CAN ID 7FA, DB协议 均衡配置
    FUNC_CTRL_7FF,           // CAN ID 7FF, DB协议 从控配置
    FUNC_MAX,                // MAX FUNCTION
};

unsigned char raw_data[MAX_CAN_PORT][MAX_LECU_CNT][FUNC_MAX][MAX_FRAME_NUMBER][CAN_DATA_LEN];

// $0 <port> <lecu> <func>
int main(int argc, char *argv[])
{
    int port = 0;
    int lecu_addr = 0;

    int func = FUNC_BALANCE_STATUS_735;
    int fn = 0;

    unsigned char *base_addr = &raw_data[port][lecu_addr];
    unsigned char *addr = &raw_data[port][lecu_addr][func][fn];

    printf("reg addr:%04lX\n", (addr - base_addr) / 2);
}