修正调试相关错误

This commit is contained in:
lxbpxylps@126.com 2021-03-25 15:02:10 +08:00
parent 14c19baf73
commit 41fa2736f6

View File

@ -183,6 +183,7 @@ void HandleMessage(char * message);
#include "MemoryUsage.h" #include "MemoryUsage.h"
#define NeoSerialDebug NeoSerial
#define DEBUG_BAUT_RATE 115200 #define DEBUG_BAUT_RATE 115200
int loop_time = 0; int loop_time = 0;
@ -190,14 +191,14 @@ int loop_time = 0;
//错误消息函数,用于在出现致命错误后结束程序 //错误消息函数,用于在出现致命错误后结束程序
void DebugCanNotContinue(char* message) void DebugCanNotContinue(char* message)
{ {
NeoSerial.print(F("#TAICHI: CAN NOT CONTINUE WHEN ")); NeoSerial.println(message); NeoSerialDebug.print(F("#TAICHI: CAN NOT CONTINUE WHEN ")); NeoSerialDebug.println(message);
NeoSerial.print(F("#TAICHI: loop_time: ")); NeoSerial.println(loop_time); NeoSerialDebug.print(F("#TAICHI: loop_time: ")); NeoSerialDebug.println(loop_time);
NeoSerial.print(F("#TAICHI: pass: [")); NeoSerial.print(passed_point.x); NeoSerial.print(F(", ")); NeoSerial.print(passed_point.y); NeoSerial.print(F("]")); NeoSerialDebug.print(F("#TAICHI: pass: [")); NeoSerialDebug.print(passed_point.x); NeoSerialDebug.print(F(", ")); NeoSerialDebug.print(passed_point.y); NeoSerialDebug.print(F("]"));
NeoSerial.print(F(" TYPE: ")); NeoSerial.println((int)passed_point.type); NeoSerialDebug.print(F(" TYPE: ")); NeoSerialDebug.println((int)passed_point.type);
NeoSerial.print(F("#TAICHI: next: [")); NeoSerial.print(next_point.x); NeoSerial.print(F(", ")); NeoSerial.print(next_point.y); NeoSerial.print(F("]")); NeoSerialDebug.print(F("#TAICHI: next: [")); NeoSerialDebug.print(next_point.x); NeoSerialDebug.print(F(", ")); NeoSerialDebug.print(next_point.y); NeoSerialDebug.print(F("]"));
NeoSerial.print(F(" next_position: ")); NeoSerial.print((int)next_position); NeoSerialDebug.print(F(" next_position: ")); NeoSerialDebug.print((int)next_position);
NeoSerial.print(F(" TYPE: ")); NeoSerial.println((int)next_point.type); NeoSerialDebug.print(F(" TYPE: ")); NeoSerialDebug.println((int)next_point.type);
NeoSerial.print(F("#TAICHI: is_claw_catch: ")); NeoSerial.print((int)is_claw_catch); NeoSerial.print(F(" is_claw_ok: ")); NeoSerial.println((int)is_claw_ok); NeoSerialDebug.print(F("#TAICHI: is_claw_catch: ")); NeoSerialDebug.print((int)is_claw_catch); NeoSerialDebug.print(F(" is_claw_ok: ")); NeoSerialDebug.println((int)is_claw_ok);
SRamDisplay(); SRamDisplay();
while (1) {} while (1) {}
@ -209,8 +210,8 @@ void DebugCanNotContinue(char* message)
void setup() void setup()
{ {
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
NeoSerial.begin(DEBUG_BAUT_RATE); NeoSerialDebug.begin(DEBUG_BAUT_RATE);
NeoSerial.println(F("#TAICHI: ======================setup()=====================")); NeoSerialDebug.println(F("#TAICHI: ======================setup()====================="));
SRamDisplay(); SRamDisplay();
#endif #endif
@ -248,14 +249,14 @@ void loop()
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
loop_time++; loop_time++;
NeoSerial.println(F("#TAICHI: ====================New loop()====================")); NeoSerialDebug.println(F("#TAICHI: ====================New loop()===================="));
NeoSerial.print(F("#TAICHI: loop_time: ")); NeoSerial.println(loop_time); NeoSerialDebug.print(F("#TAICHI: loop_time: ")); NeoSerialDebug.println(loop_time);
NeoSerial.print(F("#TAICHI: pass: [")); NeoSerial.print(passed_point.x); NeoSerial.print(F(", ")); NeoSerial.print(passed_point.y); NeoSerial.print(F("]")); NeoSerialDebug.print(F("#TAICHI: pass: [")); NeoSerialDebug.print(passed_point.x); NeoSerialDebug.print(F(", ")); NeoSerialDebug.print(passed_point.y); NeoSerialDebug.print(F("]"));
NeoSerial.print(F(" TYPE: ")); NeoSerial.println((int)passed_point.type); NeoSerialDebug.print(F(" TYPE: ")); NeoSerialDebug.println((int)passed_point.type);
NeoSerial.print(F("#TAICHI: next: [")); NeoSerial.print(next_point.x); NeoSerial.print(F(", ")); NeoSerial.print(next_point.y); NeoSerial.print(F("]")); NeoSerialDebug.print(F("#TAICHI: next: [")); NeoSerialDebug.print(next_point.x); NeoSerialDebug.print(F(", ")); NeoSerialDebug.print(next_point.y); NeoSerialDebug.print(F("]"));
NeoSerial.print(F(" next_position: ")); NeoSerial.print((int)next_position); NeoSerialDebug.print(F(" next_position: ")); NeoSerialDebug.print((int)next_position);
NeoSerial.print(F(" TYPE: ")); NeoSerial.println((int)next_point.type); NeoSerialDebug.print(F(" TYPE: ")); NeoSerialDebug.println((int)next_point.type);
NeoSerial.print(F("#TAICHI: is_claw_catch: ")); NeoSerial.print((int)is_claw_catch); NeoSerial.print(F(" is_claw_ok: ")); NeoSerial.println((int)is_claw_ok); NeoSerialDebug.print(F("#TAICHI: is_claw_catch: ")); NeoSerialDebug.print((int)is_claw_catch); NeoSerialDebug.print(F(" is_claw_ok: ")); NeoSerialDebug.println((int)is_claw_ok);
SRamDisplay(); SRamDisplay();
#endif #endif
@ -488,7 +489,7 @@ void loop()
route.UpdatePosition(); route.UpdatePosition();
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
NeoSerial.println(F("#TAICHI: ====================End loop()====================")); NeoSerialDebug.println(F("#TAICHI: ====================End loop()===================="));
#endif #endif
} }
@ -529,17 +530,17 @@ void ReadFromEEPROM(void)
delay_time_after_turn = stroage_info.delay_time_after_turn; delay_time_after_turn = stroage_info.delay_time_after_turn;
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
NeoSerial.println(F("#TAICHI: Data based on EEPROM : ")); NeoSerialDebug.println(F("#TAICHI: Data based on EEPROM : "));
NeoSerial.print(F("north_left_angle: ")); NeoSerial.println(north_left_angle); NeoSerialDebug.print(F("north_left_angle: ")); NeoSerialDebug.println(north_left_angle);
NeoSerial.print(F("north_right_angle: ")); NeoSerial.println(north_right_angle); NeoSerialDebug.print(F("north_right_angle: ")); NeoSerialDebug.println(north_right_angle);
NeoSerial.print(F("west_left_angle: ")); NeoSerial.println(west_left_angle); NeoSerialDebug.print(F("west_left_angle: ")); NeoSerialDebug.println(west_left_angle);
NeoSerial.print(F("west_right_angle: ")); NeoSerial.println(west_right_angle); NeoSerialDebug.print(F("west_right_angle: ")); NeoSerialDebug.println(west_right_angle);
NeoSerial.print(F("south_left_angle: ")); NeoSerial.println(south_left_angle); NeoSerialDebug.print(F("south_left_angle: ")); NeoSerialDebug.println(south_left_angle);
NeoSerial.print(F("south_right_angle: ")); NeoSerial.println(south_right_angle); NeoSerialDebug.print(F("south_right_angle: ")); NeoSerialDebug.println(south_right_angle);
NeoSerial.print(F("east_left_angle: ")); NeoSerial.println(east_left_angle); NeoSerialDebug.print(F("east_left_angle: ")); NeoSerialDebug.println(east_left_angle);
NeoSerial.print(F("east_right_angle: ")); NeoSerial.println(east_right_angle); NeoSerialDebug.print(F("east_right_angle: ")); NeoSerialDebug.println(east_right_angle);
NeoSerial.print(F("gray_7_gate: ")); NeoSerial.println(stroage_info.gray_7_gate); NeoSerialDebug.print(F("gray_7_gate: ")); NeoSerialDebug.println(stroage_info.gray_7_gate);
NeoSerial.print(F("delay_time_after_turn: ")); NeoSerial.println(delay_time_after_turn); NeoSerialDebug.print(F("delay_time_after_turn: ")); NeoSerialDebug.println(delay_time_after_turn);
#endif #endif
} }
@ -571,7 +572,7 @@ void CheckGrayStatus(void)
} }
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
NeoSerial.println(F("#TAICHI: Gray Sensor Status OK!")); NeoSerialDebug.println(F("#TAICHI: Gray Sensor Status OK!"));
#endif #endif
} }
@ -618,7 +619,9 @@ uint8_t CalcDirection(void)
rx = -ry0; rx = -ry0;
ry = rx0; ry = rx0;
} }
#ifdef TAICHI_DEBUG
else DebugCanNotContinue("CALC DIRECTION <1>"); //调试用 else DebugCanNotContinue("CALC DIRECTION <1>"); //调试用
#endif
//判断行进方向 //判断行进方向
if (rx == 0 && ry == 2) if (rx == 0 && ry == 2)
@ -669,7 +672,9 @@ uint8_t CalcDirection(void)
return BACKRIGHTWARD; return BACKRIGHTWARD;
} }
} }
#ifdef TAICHI_DEBUG
else DebugCanNotContinue("CALC DIRECTION <2>"); //调试用 else DebugCanNotContinue("CALC DIRECTION <2>"); //调试用
#endif
} }
@ -685,9 +690,9 @@ void LineForward(uint8_t end_position, float speed_rate)
{ {
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出沿线直行状态 //调试输出沿线直行状态
NeoSerial.print(F("#TAICHI: Line Forward")); NeoSerialDebug.print(F("#TAICHI: Line Forward"));
NeoSerial.print(F(" end_position: ")); NeoSerialDebug.print(F(" end_position: "));
NeoSerial.println((int)end_position); NeoSerialDebug.println((int)end_position);
#endif #endif
//记录开始时间 //记录开始时间
@ -749,7 +754,7 @@ void LineForward(uint8_t end_position, float speed_rate)
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出沿线直行结束 //调试输出沿线直行结束
NeoSerial.println(F("#TAICHI: End Line Forward")); NeoSerialDebug.println(F("#TAICHI: End Line Forward"));
#endif #endif
} }
@ -759,9 +764,9 @@ void LineBackward(uint8_t end_position, float speed_rate)
{ {
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出沿线后退状态 //调试输出沿线后退状态
NeoSerial.print(F("#TAICHI: Line Backward")); NeoSerialDebug.print(F("#TAICHI: Line Backward"));
NeoSerial.print(F(" end_position: ")); NeoSerialDebug.print(F(" end_position: "));
NeoSerial.println((int)end_position); NeoSerialDebug.println((int)end_position);
#endif #endif
//记录灰度传感器匹配情况 //记录灰度传感器匹配情况
@ -811,7 +816,7 @@ void LineBackward(uint8_t end_position, float speed_rate)
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出沿线后退结束 //调试输出沿线后退结束
NeoSerial.println(F("#TAICHI: End Line Backward")); NeoSerialDebug.println(F("#TAICHI: End Line Backward"));
#endif #endif
} }
@ -830,7 +835,7 @@ void TurnDirection(float speed_rate)
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出直行或后退或转向状态 //调试输出直行或后退或转向状态
NeoSerial.println(F("#TAICHI: JUMP THE RELEASE/GETOUT/GAIN POINT FOR STATUS REASON")); NeoSerialDebug.println(F("#TAICHI: JUMP THE RELEASE/GETOUT/GAIN POINT FOR STATUS REASON"));
#endif #endif
} }
@ -838,9 +843,9 @@ void TurnDirection(float speed_rate)
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出直行或后退或转向状态 //调试输出直行或后退或转向状态
NeoSerial.print(F("#TAICHI: Turn Direction")); NeoSerialDebug.print(F("#TAICHI: Turn Direction"));
NeoSerial.print(F(" direction: ")); NeoSerialDebug.print(F(" direction: "));
NeoSerial.println((int)direction); NeoSerialDebug.println((int)direction);
#endif #endif
if (direction == FORWARD) //继续直行 if (direction == FORWARD) //继续直行
@ -918,7 +923,7 @@ void TurnDirection(float speed_rate)
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出直行或后退或转向结束 //调试输出直行或后退或转向结束
NeoSerial.println(F("#TAICHI: End Turn Direction")); NeoSerialDebug.println(F("#TAICHI: End Turn Direction"));
#endif #endif
} }
@ -953,8 +958,8 @@ bool CatchAndCheck(uint8_t type, float speed)
{ {
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出失败信息 //调试输出失败信息
NeoSerial.print(F("#TAICHI: **********FAIL CATCH!**********")); NeoSerialDebug.print(F("#TAICHI: **********FAIL CATCH!**********"));
NeoSerial.print(F(" catch_times: ")); NeoSerial.println((int)catch_times); NeoSerialDebug.print(F(" catch_times: ")); NeoSerialDebug.println((int)catch_times);
#endif #endif
if (type == CATCH_TYPE_GAIN) if (type == CATCH_TYPE_GAIN)
@ -988,14 +993,14 @@ bool CatchAndCheck(uint8_t type, float speed)
#ifndef DISABLE_CLAW_CHECK #ifndef DISABLE_CLAW_CHECK
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出成功信息 //调试输出成功信息
NeoSerial.println(F("#TAICHI: SUCCESS CATCH!")); NeoSerialDebug.println(F("#TAICHI: SUCCESS CATCH!"));
#endif #endif
#endif #endif
#ifdef DISABLE_CLAW_CHECK #ifdef DISABLE_CLAW_CHECK
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出结束信息 //调试输出结束信息
NeoSerial.println(F("#TAICHI: CATCH WITHOUT CHECK!")); NeoSerialDebug.println(F("#TAICHI: CATCH WITHOUT CHECK!"));
#endif #endif
#endif #endif
@ -1010,7 +1015,7 @@ bool OpenClawAndCheck(void)
#ifdef DISABLE_CLAW_CHECK #ifdef DISABLE_CLAW_CHECK
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出信息 //调试输出信息
NeoSerial.println(F("#TAICHI: DISABLE CLAW CHECK!")); NeoSerialDebug.println(F("#TAICHI: DISABLE CLAW CHECK!"));
#endif #endif
is_claw_ok = true; is_claw_ok = true;
@ -1030,7 +1035,7 @@ bool OpenClawAndCheck(void)
{ {
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出成功信息 //调试输出成功信息
NeoSerial.println(F("#TAICHI: SUCCESS OPEN CLAW!")); NeoSerialDebug.println(F("#TAICHI: SUCCESS OPEN CLAW!"));
#endif #endif
is_claw_ok = true; is_claw_ok = true;
@ -1040,7 +1045,7 @@ bool OpenClawAndCheck(void)
#ifdef TAICHI_DEBUG #ifdef TAICHI_DEBUG
//调试输出失败信息 //调试输出失败信息
NeoSerial.println(F("#TAICHI: $$$$$$$$$$FAIL CLAW!$$$$$$$$$$")); NeoSerialDebug.println(F("#TAICHI: $$$$$$$$$$FAIL CLAW!$$$$$$$$$$"));
#endif #endif
is_claw_ok = false; is_claw_ok = false;