Просмотр исходного кода

新协议调试通过

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 5 лет назад
Родитель
Сommit
db6ab406ae

+ 11 - 6
Application/app/bms_message.c

@@ -63,7 +63,8 @@ void process_bms_message(can_frame_t *frame, int len){
 			bresp.cycle = soc_get_cycle();
 			bresp.calibrated = (get_soc()->flags & SOC_FLAG_CALIBRATED) != 0;
 			data = (uint8_t *)&bresp;
-			data_len = sizeof(bresp);			
+			data_len = sizeof(bresp);
+			protocol_send_bms_info(frame->head.can_addr, frame->key, data, data_len);
 			break;
 		}
 		case CAN_KEY_BMS_CHARG_INFO:{
@@ -71,7 +72,8 @@ void process_bms_message(can_frame_t *frame, int len){
 			cresp.charge_current = measure_value()->load_current;
 			cresp.charge_remain_time = soc_get_charger_remain_time();
 			data = (uint8_t *)&cresp;
-			data_len = sizeof(cresp);			
+			data_len = sizeof(cresp);
+			protocol_send_bms_info(frame->head.can_addr, frame->key, data, data_len);
 			break;
 		}
 		case CAN_KEY_BMS_CLEAR:
@@ -83,6 +85,7 @@ void process_bms_message(can_frame_t *frame, int len){
 			uint32_t time = shark_get_seconds();
 			data = (uint8_t *)&time;
 			data_len = sizeof(time);
+			protocol_send_bms_info(frame->head.can_addr, frame->key, data, data_len);
 			break;
 		}
 		case CAN_KEY_BMS_GET_STAT: {
@@ -97,6 +100,7 @@ void process_bms_message(can_frame_t *frame, int len){
 			sresp.health = (*h != 0);
 			data = (uint8_t *)&sresp;
 			data_len = sizeof(sresp);
+			protocol_send_bms_info(frame->head.can_addr, frame->key, data, data_len);
 			break;
 		}
 		case CAN_KEY_BMS_TEMPS: {
@@ -105,6 +109,7 @@ void process_bms_message(can_frame_t *frame, int len){
 			memcpy(temps+1, measure_value()->pack_temp, PACK_TEMPS_NUM * sizeof(int));
 			data = temps;
 			data_len = PACK_TEMPS_NUM * sizeof(int) + 1;
+			protocol_send_bms_info(frame->head.can_addr, frame->key, data, data_len);
 			break;
 		}	
 		case CAN_KEY_BMS_GET_CELLS: {
@@ -115,11 +120,13 @@ void process_bms_message(can_frame_t *frame, int len){
 			}
 			data = (uint8_t *)&cells;
 			data_len = sizeof(cells);
+			protocol_send_bms_info(frame->head.can_addr, frame->key, data, data_len);
 			break;
 		}
 		case CAN_KEY_BMS_GET_HEALTH_STAT:
 			data = (uint8_t *)bms_health();
 			data_len = sizeof(*bms_health());
+			protocol_send_bms_info(frame->head.can_addr, frame->key, data, data_len);
 			break;
 		case CAN_KEY_BMS_SET_WORK_MODE:
 			if (len != 2) {
@@ -135,11 +142,13 @@ void process_bms_message(can_frame_t *frame, int len){
 		case CAN_KEY_GET_SN: {
 			data = (u8 *)"SP730FL123223431";
 			data_len = strlen((char *)data);
+			protocol_send_bms_info(frame->head.can_addr, frame->key, data, data_len);
 			break;
 		}
 		case CAN_KEY_GET_VERSION: {
 			data = (u8*) "HSP730FL_V2_13032048";
 			data_len = strlen((char *)data);
+			protocol_send_bms_info(frame->head.can_addr, frame->key, data, data_len);
 			break;
 		}
 		case CAN_KEY_SET_LOGGER:
@@ -151,9 +160,5 @@ void process_bms_message(can_frame_t *frame, int len){
 			protocol_send_ack(frame->head.can_addr, frame->key, result);
 			break;
 	}
-	if (data != NULL && data_len > 0){
-		protocol_send_bms_info(frame->head.can_addr, frame->key, data, data_len);
-	}
-	
 }
 

+ 4 - 0
Application/app/protocol.h

@@ -86,16 +86,20 @@ typedef struct {
 #pragma pack(pop)
 
 #define CAN_KEY_BMS_CHARG_INFO 0xa1
+#pragma  pack (push,1)
 typedef struct {
 	uint32_t charge_current;
 	uint32_t charge_remain_time; //s
 }cinfo_cmd_resp_t;
+#pragma pack(pop)
 
 #define CAN_KEY_BMS_GET_CELLS   0x07
+#pragma  pack (push,1)
 typedef struct {
 	uint8_t cell_num;
 	uint16_t voltages[CELLS_NUM];
 }cell_cmd_resp_t;
+#pragma pack(pop)
 
 #define CAN_KEY_BMS_TEMPS 0x11 //return int[4]
 

+ 1 - 1
Application/app/sox/measure_task.c

@@ -98,7 +98,7 @@ static void init_temp_task(void){
 static u32 temp_task_handler(void){
 	_measure_value.pack_temp[_temp_task.index] = get_pack_temperature(_temp_task.index);
 	measure_debug("pack temp[%d]=%d\n", _temp_task.index, _measure_value.pack_temp[_temp_task.index]);
-	_temp_task.index = (_temp_task.index + 1) % (PACK_TEMPS_NUM + 1);
+	_temp_task.index = (_temp_task.index + 1) % (PACK_TEMPS_NUM);
 	_temperature_notify();//֪ͨbms state ÓÐеÄζÈÊý¾Ý
 	return _temp_task.delay;
 }

+ 2 - 2
Application/app/sox/state.c

@@ -12,8 +12,8 @@
 #include "state.h"
 #include "iostate.h"
 
-#define ALLOW_DEEP_SLEEP 1
-#define SLEEP_IGNORE_UNHEALTH 1
+#define ALLOW_DEEP_SLEEP 0
+#define SLEEP_IGNORE_UNHEALTH 0
 #define ALLOW_POWER_DOWN 0 //disable power down for debug
 #define ALLOW_5238_BALANCE 1
 

+ 1 - 0
Application/bsp/uart.c

@@ -93,6 +93,7 @@ static void shark_uart_rx(shark_uart_t *uart){
 				break;
 			case CH_END:
 				if (uart->rx_length > 2 && uart->rx_length != 0xFF){
+					uart->rx_length -= 2; //skip crc
 					shark_uart_on_rx_frame(uart);
 				}
 				uart->rx_length = 0xFF;