Bladeren bron

支持字符串cmd解析

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 5 jaren geleden
bovenliggende
commit
12ab090380
4 gewijzigde bestanden met toevoegingen van 37 en 6 verwijderingen
  1. 24 4
      Application/app/protocol_old.c
  2. 1 1
      Application/app/sox/health.c
  3. 7 1
      Application/app/sox/state.c
  4. 5 0
      Application/app/sox/state.h

+ 24 - 4
Application/app/protocol_old.c

@@ -108,16 +108,17 @@ static int get_response_data(uint8_t *data, uint8_t operate, uint8_t result){
 	return head->size;
 }
 
-void protocol_old_recv_frame(uart_enum_t uart_no, uint8_t *data, int len){
+
+static int protocol_old_process_binary(uart_enum_t uart_no, uint8_t *data, int len){
 	current_uart = uart_no;
 	comm_head_t *head = (comm_head_t *)data;
 	if (/*head->type != 0x30 || */head->dir != 0x16 || head->bStatus == 1 || head->size < sizeof(comm_head_t)){
-		return;
+		return -1;
 	}
 	uint16_t checksum = head->checksum;
 	head->checksum = 0;
 	if (checksum != _checksum(data, len)){
-		return;
+		return -1;
 	}
 
 	data = head->data;
@@ -139,8 +140,27 @@ void protocol_old_recv_frame(uart_enum_t uart_no, uint8_t *data, int len){
 	uint8_t response_data[256];
 	uint16_t response_len = get_response_data(response_data, operate, result);
 	if (response_len <= 0){
-		return;
+		return -1;
 	}
 	shark_uart_write_bytes(current_uart, response_data, response_len);
+	return 0;
+
+}
+
+void protocol_old_recv_frame(uart_enum_t uart_no, uint8_t *data, int len){
+	if (protocol_old_process_binary(uart_no, data, len) == 0){
+		return;
+	}
+	if (memcmp(data, "mode", 4) == 0){
+		if (memcmp(data + 4, "laohua", 6) == 0){
+			bms_work_mode_set(WORK_MODE_AGING_TEST, 1);
+			bms_state_get()->user_request = USER_REQUEST_PENDING | USER_REQUEST_SMALLCURRENT_OFF | USER_REQUEST_DISCHARGER_ON|USER_REQUEST_CHARGER_ON;
+		}else if (memcmp(data + 4, "tuichu", 6) == 0){
+			if (bms_work_is_aging_test()){
+				bms_work_mode_set(WORK_MODE_AGING_TEST, 1);
+				bms_state_get()->user_request = USER_REQUEST_PENDING | USER_REQUEST_SMALLCURRENT_ON | USER_REQUEST_DISCHARGER_OFF | USER_REQUEST_CHARGER_OFF;
+			}
+		}
+	}
 }
 

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

@@ -171,7 +171,7 @@ static int judge_debounce(int input, debounce_t *d){
 }
 
 static int _can_powerdown(void){
-	if (io_state()->charger_detect || bms_state_get()->charging){
+	if (io_state()->charger_detect || bms_state_get()->charging || !bms_work_is_normal()){
 		return 0;
 	}
 	if ((bms_state_get()->pack_voltage <= min_discharger_pdown_vol[_health.is_work_temp_normal] ||

+ 7 - 1
Application/app/sox/state.c

@@ -86,6 +86,7 @@ void bms_state_log(void){
 	state_debug("DMos: %d\n", ml5238_is_discharging());
 	state_debug("CMos: %d\n", ml5238_is_charging());
 	state_debug("AuxPower: %d\n", AUX_VOL_IS_OPEN());
+	state_debug("WorkMode:0x%x\n", _bms_state.work_mode);
 }
 static int _log_count = 0;
 static void _debug_timer_handler(shark_timer_t *t){
@@ -154,7 +155,9 @@ static s32 _process_unheath(void){
 		_bms_state.charging = 0;
 		unhealth = (Health_Discharger_Failt | Health_charger_Fault);
 	}
-
+	if (!bms_work_is_normal()){
+		return unhealth; //测试模式只关注短路保护
+	}
 	if (bms_health()->charger_over_current || bms_health()->charger_over_temp || bms_health()->charger_lower_temp ||
 				bms_health()->over_temp_deny_charger|| bms_health()->lower_temp_deny_charger ||
 				bms_health()->charger_over_voltage || bms_health()->sigle_cell_over_voltage){
@@ -263,6 +266,9 @@ static void _process_deepsleep(s32 health){
 		return;
 	}
 #endif
+	if (!bms_work_is_normal()){
+		return; //测试模式下不休眠
+	}
 	if (ml5238_is_charging() || ml5238_is_discharging() || io_state()->charger_detect_irq || _bms_state.charging){
 		return;
 	}

+ 5 - 0
Application/app/sox/state.h

@@ -84,6 +84,11 @@ typedef enum {
 void bms_state_init(void);
 bms_state_t * bms_state_get(void);
 int bms_work_mode_set(int mode, int start);
+int bms_work_is_normal(void);
+int bms_work_is_aging_test(void);
+int bms_work_is_pcba_test(void);
+int bms_work_is_pack_test(void);
+int bms_work_is_calibrating(void);
 
 #endif /* _BMS_STATE_H__ */