From: kyz Date: Wed, 29 Oct 2025 10:06:59 +0000 (+0800) Subject: can0 read X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=682f55f1d888e54eb2716143fdda3bd04e34577d;p=yn%2Fpcs.git can0 read --- diff --git a/src/main.c b/src/main.c index 9477a4b..fb96cee 100644 --- a/src/main.c +++ b/src/main.c @@ -15,7 +15,7 @@ int main(void) user_log_init(); printf("---PCS DTU, Version:1.0\n"); - +#if 0 // 启动PCS控制系统 if ( pcs_start()==0) { printf("PCS controller started successfully\n"); @@ -23,7 +23,8 @@ int main(void) fprintf(stderr, "main: Failed to start PCS controller\n"); return -1; } -#if 0 +#endif +#if 1 // 启动BMS控制系统 if (bms_start() == 0) { printf("BMS controller started successfully\n"); diff --git a/src/user_bms.c b/src/user_bms.c index cc37a75..d435c59 100644 --- a/src/user_bms.c +++ b/src/user_bms.c @@ -99,6 +99,11 @@ void user_bms_parse_frame1(const uint8_t *data) { // 解析总电流 (0.1A) g_bms.data.total_current_p1a = le16s_to_host(data + 6); + printf( "can recv frame 1: max_charge_current_p1a:%d, max_discharge_current_p1a:%d, total_voltage_p1v:%d, total_current_p1a:%d\n", + g_bms.data.max_charge_current_p1a, + g_bms.data.max_discharge_current_p1a, + g_bms.data.total_voltage_p1v, + g_bms.data.total_current_p1a ); } void user_bms_parse_frame2(const uint8_t *data) { @@ -113,6 +118,11 @@ void user_bms_parse_frame2(const uint8_t *data) { // 第7-8字节为预留,不处理 g_bms.data.reserve_2 = le16_to_host(data + 6); + printf( "can recv frame 2: total_soc_p1:%d, total_soh_p1:%d, max_charge_voltage_p1v:%d, reserve_2:%d\n", + g_bms.data.total_soc_p1, + g_bms.data.total_soh_p1, + g_bms.data.max_charge_voltage_p1v, + g_bms.data.reserve_2 ); } void user_bms_parse_frame3(const uint8_t *data) { @@ -167,16 +177,23 @@ void user_bms_receive_data(void) { perror("read"); return; } - + printf( "can read msg, size:%d\n", nbytes ); if (nbytes != sizeof(struct can_frame)) return; + printf( "read frame: id:%08X, dlc:%d, data:", frame.can_id, frame.can_dlc ); + for( int i=0; i 65535) heartbeat = 0; }