Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of CRAC-Strat_2017_homologation_gros_rob by
debug.cpp
00001 #include "debug.h" 00002 00003 void debug_Instruction(struct S_Instruction instruction) 00004 { 00005 printf("\n********* Debug instruction *********\n"); 00006 00007 printf("* Line => %d\n", instruction.lineNumber); 00008 printf("* Type => %s\n", InstructionTypeToString(instruction.order)); 00009 printf("* Direction => %s\n", InstructionDirectionToString(instruction.direction)); 00010 00011 printf("* Arg1 => %d\n", instruction.arg1); 00012 printf("* Arg2 => %d\n", instruction.arg2); 00013 printf("* Arg3 => %d\n", instruction.arg3); 00014 00015 printf("* Recalage => %s\n", InstructionPrecisionOuRecalageToString(instruction.precision)); 00016 printf("* NextAction=> %s\n", InstructionNextActionTypeToString(instruction.nextActionType)); 00017 printf("* JumpAction=> %s\n", InstructionNextActionJumpTypeToString(instruction.jumpAction)); 00018 00019 printf("* JumpTimeOrX => %d\n", instruction.JumpTimeOrX); 00020 printf("* JumpY => %d\n", instruction.JumpY); 00021 printf("* nextLineOK => %d\n", instruction.nextLineOK); 00022 printf("* nextLineError => %d\n", instruction.nextLineError); 00023 00024 printf("*************************************\n"); 00025 } 00026 00027 char* InstructionTypeToString(enum E_InstructionType type) 00028 { 00029 switch(type) 00030 { 00031 case MV_COURBURE: return "Courbure"; 00032 case MV_LINE: return "Ligne"; 00033 case MV_TURN: return "Rotation"; 00034 case MV_XYT: return "Position XYT"; 00035 case MV_RECALAGE: return "Recalage"; 00036 case ACTION: return "Action"; 00037 default: return "Inconnue"; 00038 } 00039 } 00040 char* InstructionDirectionToString(enum E_InstructionDirection type) 00041 { 00042 switch(type) 00043 { 00044 case BACKWARD: return "en arriere"; 00045 case FORWARD: return "en avant"; 00046 case RELATIVE: return "relatif"; 00047 case ABSOLUTE: return "absolu"; 00048 default: return "absent"; 00049 } 00050 } 00051 char* InstructionPrecisionOuRecalageToString(enum E_InstructionPrecisionOuRecalage type) 00052 { 00053 switch(type) 00054 { 00055 case PRECISION: return "correction position en fin de mouvement"; 00056 case RECALAGE_X: return "recalage en X"; 00057 case RECALAGE_Y: return "recalage en Y"; 00058 default: return "absent"; 00059 } 00060 } 00061 char* InstructionNextActionTypeToString(enum E_InstructionNextActionType type) 00062 { 00063 switch(type) 00064 { 00065 case JUMP: return "jump"; 00066 case WAIT: return "attente fin instruction"; 00067 case ENCHAINEMENT: return "enchainement"; 00068 default: return "absent"; 00069 } 00070 } 00071 char* InstructionNextActionJumpTypeToString(enum E_InstructionNextActionJumpType type) 00072 { 00073 switch(type) 00074 { 00075 case JUMP_TIME: return "attente temps"; 00076 case JUMP_POSITION: return "attente position"; 00077 default: return "absent"; 00078 } 00079 } 00080 00081 void errorLoop(void) { 00082 while(true) { 00083 led1 = 1; 00084 wait(0.2); 00085 led1 = 0; 00086 wait(0.2); 00087 } 00088 } 00089 00090 void errorInstructionLoop(void) { 00091 while(true) { 00092 led2 = 1; 00093 wait(0.2); 00094 led2 = 0; 00095 wait(0.2); 00096 } 00097 } 00098 00099 /****************************************************************************************/ 00100 /* FUNCTION NAME: sendStratEtat */ 00101 /* DESCRIPTION : permet le debug de l'etat de l'automate de stratégie */ 00102 /****************************************************************************************/ 00103 void sendStratEtat(unsigned char etat, unsigned char currentInstruction) { 00104 00105 CANMessage msgTx=CANMessage(); 00106 msgTx.id=DEBUG_STRATEGIE_AUTOMATE; // tx nouvelle position en (x,y,theta) 00107 msgTx.len=1; 00108 msgTx.format=CANStandard; 00109 msgTx.type=CANData; 00110 // x sur 2 octets 00111 msgTx.data[0]=(unsigned char)etat; 00112 msgTx.data[1]=(unsigned char)currentInstruction; 00113 00114 can1.write(msgTx); 00115 }
Generated on Tue Jul 12 2022 19:28:47 by
