فهرست منبع

使用单独的can指令设置log等级

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 2 سال پیش
والد
کامیت
9b896cc94f
5فایلهای تغییر یافته به همراه15 افزوده شده و 13 حذف شده
  1. 1 0
      Applications/app/app.c
  2. 13 1
      Applications/foc/commands.c
  3. 1 0
      Applications/foc/commands.h
  4. 0 11
      Applications/prot/can_message.c
  5. 0 1
      Applications/prot/can_message.h

+ 1 - 0
Applications/app/app.c

@@ -34,6 +34,7 @@ extern void encoder_log(void);
 extern void sample_log(void);
 extern void thro_torque_log(void);
 extern void eCtrl_debug_log(void);
+extern bool can_is_connect_pc(void);
 extern measure_time_t g_meas_hall;
 extern measure_time_t g_meas_foc;
 extern measure_time_t g_meas_MCTask;

+ 13 - 1
Applications/foc/commands.c

@@ -24,6 +24,12 @@ static void process_foc_command(foc_cmd_body_t *command);
 
 static co_queue_t _cmd_queue;
 
+static bool _pc_connect = false;
+
+bool can_is_connect_pc(void) {
+	return _pc_connect;
+}
+
 void foc_command_init(void) {
 	_cmd_queue = queue_create(16, sizeof(foc_cmd_body_t));
 	shark_task_create(foc_command_task, NULL);
@@ -615,7 +621,13 @@ static void process_foc_command(foc_cmd_body_t *command) {
 			len += mc_err_runtime_get(offset, response+3, sizeof(response) - 3);
 			break;
 		}
-
+		case Foc_Set_LogLevel:
+		{
+			u8 level = decode_u8((u8 *)command->data);
+			_pc_connect = (level != 0)?true:false;
+			set_log_level(MOD_SYSTEM, (level != 0)?L_debug:L_disable);
+			break;
+		}
 		default:
 		{
 			erroCode = FOC_Unknow_Cmd;

+ 1 - 0
Applications/foc/commands.h

@@ -61,6 +61,7 @@ typedef enum {
 	Foc_Report_MTPA_DQ_Angle,
 	Foc_Report_Plot,
 	Foc_Report_Temp,
+	Foc_Set_LogLevel,
 	Foc_Cmd_Max = 0xDF
 }foc_cmd_t;
 #define CMD_2_CAN_KEY(cmd) ((u16)(((u16)cmd) | (CAN_MY_ADDRESS<<8)))

+ 0 - 11
Applications/prot/can_message.c

@@ -121,19 +121,8 @@ void handle_can_frame(can_id_t id, uint8_t *data, int len){
 	}
 }
 
-static bool _pc_connect = false;
-bool can_is_connect_pc(void) {
-	return _pc_connect;
-}
-
 static void can_process_message(can_message_t *message){
 	//sys_debug("can %x [%x -> %x], len = %d\n", message->key, message->src, message->dest, message->len);
-	if (message->src == 0x45) {
-		if (!_pc_connect) {
-			set_log_level(MOD_SYSTEM, L_debug);
-		}
-		_pc_connect = true;
-	}
 	if ((message->key & 0xFF) >= 0xF0) {
 		can_process_iap_message(message);
 	}else if ((message->key & 0xFF) >= 0xE0) { //工厂测试

+ 0 - 1
Applications/prot/can_message.h

@@ -57,6 +57,5 @@ extern void can_send_ack(uint8_t can_addr, uint16_t key, uint8_t data);
 extern void can_send_response(uint8_t can_add, uint8_t *data, int len);
 extern void can_send_indicator(uint8_t can_add, uint8_t *data, int len);
 extern void can_send_request(uint8_t can_add, uint8_t *data, int len);
-extern bool can_is_connect_pc(void);
 #endif /* _CAN_MESSAGE_H__ */