|
|
@@ -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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|