From 2a78fd2a71cb941f463a67814be7520a6adcc13e Mon Sep 17 00:00:00 2001 From: kkkjtr Date: Tue, 13 Jan 2026 17:39:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=B5=E6=B1=A0=E5=AE=B9?= =?UTF-8?q?=E9=87=8F=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom/control_out/src/control_out.c | 61 ++++++++++---------------- custom/jt808/inc/jt808_set_TermParam.h | 10 +++-- custom/jt808/src/jt808_set_TermParam.c | 25 ++++++----- 3 files changed, 42 insertions(+), 54 deletions(-) diff --git a/custom/control_out/src/control_out.c b/custom/control_out/src/control_out.c index 72584fc..e6bac18 100644 --- a/custom/control_out/src/control_out.c +++ b/custom/control_out/src/control_out.c @@ -25,6 +25,21 @@ osThreadId_t control_out_TaskHandle = NULL; +const uint16_t coulomp_voltage_table[11] = { + BAT_LEVEL_0PERCENT_VOLT, + BAT_LEVEL_10PERCENT_VOLT, + BAT_LEVEL_20PERCENT_VOLT, + BAT_LEVEL_30PERCENT_VOLT, + BAT_LEVEL_40PERCENT_VOLT, + BAT_LEVEL_50PERCENT_VOLT, + BAT_LEVEL_60PERCENT_VOLT, + BAT_LEVEL_70PERCENT_VOLT, + BAT_LEVEL_80PERCENT_VOLT, + BAT_LEVEL_90PERCENT_VOLT, + BAT_LEVEL_100PERCENT_VOLT, +}; + + // SYS_CONF_t sys_conf ={ // .SW_version = 1, // .HW_version = 1, @@ -110,53 +125,20 @@ void set_out_acc_percent(uint8_t percent){//1000000设置频率为10KHz // } // } -const float coulomp_voltage_tablesSLA[3][21] = { - { // 4串 - 420.0f, 423.6f, 427.2f, 430.8f, 434.4f, 438.0f, 441.6f, 445.2f, 448.8f, 452.4f, - 456.0f, 459.6f, 463.2f, 466.8f, 470.4f, 474.0f, 477.6f, 481.2f, 484.8f, 488.4f, 492.0f - }, - { // 5串 - 525.0f, 529.5f, 534.0f, 538.5f, 543.0f, 547.5f, 552.0f, 556.5f, 561.0f, 565.5f, - 570.0f, 574.5f, 579.0f, 583.5f, 588.0f, 592.5f, 597.0f, 601.5f, 606.0f, 610.5f, 615.0f - }, - { // 6串 - 630.0f, 635.4f, 640.8f, 646.2f, 651.6f, 657.0f, 662.4f, 667.8f, 673.2f, 678.6f, - 684.0f, 689.4f, 694.8f, 700.2f, 705.6f, 711.0f, 716.4f, 721.8f, 727.2f, 732.6f, 738.0f - } -}; - -const float coulomp_voltage_tablesLi[3][21] = { - { // 4串 - - }, - { // 5串 - - }, - { // 6串 - - } -}; - - - uint8_t pmu_voltage_to_percent(uint32_t volt){//电压转百分比 uint8_t i, percent; float step, base; - uint32_t table_index; - table_index = jt808_term_param_item.set_term_param.BatPack_V; - const float* voltage_table = coulomp_voltage_tablesSLA[table_index]; - - if((volt < voltage_table[0])){ + if((volt < coulomp_voltage_table[0])){ return 0; } - if((volt >= voltage_table[20])){ + if((volt >= coulomp_voltage_table[10])){ return 100; } - for (i = 0; i < 20; i++) { - if((volt < voltage_table[i+1]) && (volt >= voltage_table[i])){ - step = (voltage_table[i+1] - voltage_table[i]) / 10.0; - base = voltage_table[i]; + for (i = 0; i < 10; i++) { + if((volt < coulomp_voltage_table[i+1]) && (volt >= coulomp_voltage_table[i])){ + step = (coulomp_voltage_table[i+1] - coulomp_voltage_table[i]) / 10.0; + base = coulomp_voltage_table[i]; percent = (10 * i) + (volt - base) / step; // DEBUG("\n\ni:%d,volt:%d,step:%02.2f,base:%02.2f,percent:%d\n\n",i,volt,step,base,percent); return (uint8_t)percent; @@ -165,6 +147,7 @@ uint8_t pmu_voltage_to_percent(uint32_t volt){//电压转百分比 return 0; } + #define _out_UPDETE_TIME 10 // static uint32_t back_timecount = 0; static uint8_t door_lock_last_status = 0; diff --git a/custom/jt808/inc/jt808_set_TermParam.h b/custom/jt808/inc/jt808_set_TermParam.h index d878252..9590fd9 100644 --- a/custom/jt808/inc/jt808_set_TermParam.h +++ b/custom/jt808/inc/jt808_set_TermParam.h @@ -39,8 +39,9 @@ typedef enum { ID_SpeedCutLimit_B = 0xF007, //WORD 后退自动减速刹车距离 ID_Ban_Fence_Polygon_Delay_OFF = 0xF008, //BYTE 禁止围栏延时关闭时间, 单位秒 ID_RadarEN = 0xF009, //BYTE 雷达使能位, 0 代表关闭, 1 代表开启 2代表临时关闭 - ID_BatType = 0xF00A, //BYTE 电池类型,0代表铅酸电池,1代表锂电池 - ID_BatPack = 0xF00B, //DWORD 电池包电压,可设置成48v,60v,72v,或其他需要的电压 + ID_BatType = 0xF00A, //BYTE 电池类型位,0 代表铅酸电池, 1 代表锂电池 + ID_VoltageType = 0xF00B, //DWORD 电池电压,可设置成48v 60v 72v 或其他电压 + ID_BatCap = 0xF00c, //DWORD 电池容量,可设置成52AH,58AH,或其他容量 }set_TermParamID_t; typedef struct{ uint32_t HeartBeatInterval;// DWORD, 终端心跳发送间隔(s) @@ -55,7 +56,6 @@ typedef struct{ uint8_t CarPlateColor;//车牌颜色,按照 JT/T415-2006 的 5.4.12 uint8_t RadarEN; // 雷达使能位, 0 代表关闭, 1 代表开启 - uint8_t BatType; // 电池类型,0代表铅酸电池,1代表锂电池 uint32_t ManagerACC; // 管理员模式油门0~100% uint32_t TouristACC; // 游客模式油门0~100% uint32_t SpeedCutACC; // 自动减速油门0~100% @@ -63,8 +63,10 @@ typedef struct{ uint32_t SpeedCutLimit; // 前进自动减速刹车距离 uint32_t BrakeLimit_B; // 后退刹车距离 uint32_t SpeedCutLimit_B; // 后退自动减速刹车距离 - uint32_t BatPack_V; // 电池包电压,可设置成48v,60v,72v,或其他需要的电压 uint8_t Ban_Fence_Polygon_Delay_OFF; // 禁止围栏延时关闭时间, 单位秒 + uint8_t BatType; //电池种类 + uint8_t VoltageType; //电池种类 + uint8_t BatCap; //电池种类 }set_TermParam_t; // 支持的附加消息ID diff --git a/custom/jt808/src/jt808_set_TermParam.c b/custom/jt808/src/jt808_set_TermParam.c index 80a747a..ad1bee9 100644 --- a/custom/jt808/src/jt808_set_TermParam.c +++ b/custom/jt808/src/jt808_set_TermParam.c @@ -51,8 +51,6 @@ static const ParamDescriptor param_descriptors[] = { {ID_BrakeLimit_B, offsetof(set_TermParam_t, BrakeLimit_B), sizeof(uint32_t), 1}, {ID_SpeedCutLimit_B, offsetof(set_TermParam_t, SpeedCutLimit_B), sizeof(uint32_t), 1}, {ID_Ban_Fence_Polygon_Delay_OFF, offsetof(set_TermParam_t, Ban_Fence_Polygon_Delay_OFF), sizeof(uint8_t), 0}, - {ID_BatType, offsetof(set_TermParam_t, BatType), sizeof(uint8_t), 0}, - {ID_BatPack, offsetof(set_TermParam_t, BatPack_V), sizeof(uint32_t), 0}, }; // 释放参数链表 @@ -499,16 +497,21 @@ int jt808_setTermParam(set_TermParamID_t param_id, void *param, uint8_t param_le jt808_term_param_item.set_term_param.RadarEN = param_val32 & 0xFF; break; } - case ID_BatType:{// TODO: 电池种类 - // JT808_DEBUG("RadarEN=%d", radar_en); - jt808_term_param_item.set_term_param.BatType = param_val32 & 0xFF; + case ID_BatType:{ + jt808_term_param_item.set_term_param.BatType = param_val32 & 0xFF; break; + + } + case ID_BatCap:{ + jt808_term_param_item.set_term_param.BatCap = param_val32 & 0xFF; + break; + + } + case ID_VoltageType:{ + jt808_term_param_item.set_term_param.VoltageType = param_val32 & 0xFF; + break; + } - case ID_BatPack:{// TODO: 电池电压 - // JT808_DEBUG("RadarEN=%d", radar_en); - jt808_term_param_item.set_term_param.BatPack_V = param_val32 ; - break; - } default:{ // TODO: 未知参数 return -1; @@ -973,7 +976,7 @@ void jt808_set_term_param_init(void){ // memcpy(jt808_term_param_item.big_term_attr_resp.term_ICCID+4, jt808_term_param_item.phone_BCDnum, 6); // 终端手机号码 但是你照这个来云端收到的iccid全是,因为BCDnum参数本身没有初始化 char str_hw_ver[] = "1.0.0"; // 硬件版本 - char str_fw_ver[] = "1.2.4"; // 固件版本 原本为1.0.0 + char str_fw_ver[] = "1.2.5"; // 固件版本 原本为1.0.0 jt808_term_param_item.big_term_attr_resp.hw_ver_len = strlen(str_hw_ver); // 硬件版本长度 jt808_term_param_item.big_term_attr_resp.fw_ver_len = strlen(str_fw_ver); // 固件版本长度 memcpy(jt808_term_param_item.big_term_attr_resp.str_hw_ver, str_hw_ver, strlen(str_hw_ver)); // 硬件版本