Changeset 678

Show
Ignore:
Timestamp:
07/15/09 19:49:46 (4 years ago)
Author:
atorf
Message:

Fighting bugs in MotorControl:

  • Added MATLAB remote debug logging server
  • GUI needed (no multitasking in MATLAB )
  • Bug doesn't occur with remote logging :-(
Location:
branches/atorf/NXC/MotorControl2
Files:
3 added
3 modified

Legend:

Unmodified
Added
Removed
  • branches/atorf/NXC/MotorControl2/Controller.nxc

    r664 r678  
    107107//#define ENABLEDEBUGGING_LCD 
    108108//#define ENABLEDEBUGGING_WAITAFTERLCD 
    109 #define ENABLEDEBUGGING_LCD_SLOW_ANTIBUG 
     109//#define ENABLEDEBUGGING_LCD_SLOW_ANTIBUG 
    110110//#define ENABLEDEBUGGING_REMOTE 
    111111//#define ENABLEDEBUGGING_ACOUSTIC 
    112112//#define ENABLEDEBUGGING_ACOUSTICPROTOCOL 
    113113//#define ENABLEDEBUGGING_OLDLCDTIMING 
     114//#define ENABLEDEBUGGING_REMOTELOGGING 
    114115// --------------------------------- 
    115116 
     
    121122#endif 
    122123 
     124 
     125#ifdef ENABLEDEBUGGING_REMOTELOGGING 
     126    //long debugStartTick = CurrentTick(); 
     127    long remoteDebugMsgCounter = 0; 
     128    safecall void SendDebugMessage(const byte &port, const string msg) { 
     129        //string time = NumToStr(CurrentTick() - FirstTick()); 
     130        string p    = NumToStr(port); 
     131        string n    = NumToStr(remoteDebugMsgCounter); 
     132        //string data = StrCat(time, "|", n, "|", p, ":", msg); 
     133        string data = StrCat(n, "|", p, ":", msg); 
     134        remoteDebugMsgCounter++; 
     135 
     136        SendMessage(DEBUG_OUTBOX, data); 
     137    }//end void 
     138#endif 
    123139 
    124140 
  • branches/atorf/NXC/MotorControl2/ControllerCore.nxc

    r664 r678  
    247247#ifdef ENABLEDEBUGGING_ACOUSTIC 
    248248    PlayTone(300,100); 
     249#endif 
     250 
     251#ifdef ENABLEDEBUGGING_REMOTELOGGING 
     252    SendDebugMessage(port, "Entering main loop"); 
    249253#endif 
    250254 
     
    452456                TextOut(0, DebugLinePos[port], "BRAKING:top        "); 
    453457            #endif 
     458            #ifdef ENABLEDEBUGGING_REMOTELOGGING 
     459                SendDebugMessage(port, "Braking: Beginning"); 
     460            #endif 
    454461 
    455462            #ifdef ENABLEDEBUGGING_REMOTE 
     
    471478                TextOut(0, DebugLinePos[port], "BRAKING:speed/err        "); 
    472479            #endif 
     480            //#ifdef ENABLEDEBUGGING_REMOTELOGGING 
     481            //    SendDebugMessage(port, "Braking: IdealSpeed / error calced"); 
     482            //#endif 
    473483 
    474484 
     
    502512            #endif 
    503513 
     514            //#ifdef ENABLEDEBUGGING_REMOTELOGGING 
     515            //    SendDebugMessage(port, "Braking: PID calc done, clipping power"); 
     516            //#endif 
     517 
    504518 
    505519            // downscaling 
     
    516530                TextOut(0, DebugLinePos[port], "BRAKING:PwrCalced        "); 
    517531            #endif 
     532            #ifdef ENABLEDEBUGGING_REMOTELOGGING 
     533                SendDebugMessage(port, "Braking: Setting new power"); 
     534            #endif 
     535 
    518536 
    519537             
     
    604622            TextOut(0, DebugLinePos2[port], "              "); 
    605623        #endif 
     624        #ifdef ENABLEDEBUGGING_REMOTELOGGING 
     625            SendDebugMessage(port, "Wait-loop done"); 
     626        #endif 
    606627 
    607628//    * if SPECIAL ENDGAME BRAKING 
     
    616637                SendMessage(OUTBOX, "-300|0|0"); 
    617638            #endif// - - - - - - - - - - 
     639            #ifdef ENABLEDEBUGGING_REMOTELOGGING 
     640                SendDebugMessage(port, "Endgame begins"); 
     641            #endif 
    618642 
    619643 
     
    676700            #endif 
    677701             
     702            #ifdef ENABLEDEBUGGING_REMOTELOGGING 
     703                if (endgameSuccessful) { 
     704                    SendDebugMessage(port, "Endgame successful"); 
     705                } else { 
     706                    SendDebugMessage(port, "Endgame timed out"); 
     707                }//end if 
     708            #endif 
     709             
    678710            // and this control process is finally over! 
    679711            break; 
     
    701733    // mess up our current motor state, maybe that's not too bad... 
    702734 
     735    #ifdef ENABLEDEBUGGING_REMOTELOGGING 
     736        SendDebugMessage(port, "Waiting for Motorstop"); 
     737    #endif 
    703738 
    704739    WaitUntilMotorStopped(port); 
     
    716751    Wait(3); 
    717752     
     753     
     754    #ifdef ENABLEDEBUGGING_REMOTELOGGING 
     755        SendDebugMessage(port, "Finished!"); 
     756    #endif 
     757 
    718758    #ifdef ENABLEDEBUGGING_REMOTE 
    719759        SendMessage(OUTBOX, "-480|0|0"); 
    720760    #endif// - - - - - - - - - - 
    721      
    722      
     761 
    723762     
    724763// --- Display Debug Info if necessary 
  • branches/atorf/NXC/MotorControl2/MotorControl20.nxc

    r664 r678  
    3636#define PROGRAM_VERSION "2.0" 
    3737 
    38 #define INBOX 1 
    39 #define OUTBOX 0 
     38#define INBOX           1 
     39#define OUTBOX          0 
     40#define DEBUG_OUTBOX    2 
    4041 
    4142// Protocol constants 
     
    134135     
    135136    #ifdef ENABLEDEBUGGING_LCD_SLOW_ANTIBUG 
    136         TextOut(0, LCD_LINE8, "SLOW ANTIBUG ON  ", true); 
     137      TextOut(0, LCD_LINE8, "SLOW ANTIBUG ON  ", true); 
    137138    #endif// - - - - - - - 
    138139     
    139140}//end void 
    140  
    141  
    142  
    143141 
    144142 
     
    413411        ReceiveRemoteString(OUTBOX, true, in); 
    414412    }//end while 
    415  
    416  
     413    #ifdef ENABLEDEBUGGING_REMOTELOGGING 
     414        in = "..."; 
     415        while(StrLen(in) > 0) { 
     416            ReceiveRemoteString(DEBUG_OUTBOX, true, in); 
     417        }//end while 
     418    #endif 
     419 
     420    in = ""; 
     421 
     422 
     423    #ifdef ENABLEDEBUGGING_REMOTELOGGING 
     424        SendDebugMessage(99, "Remote logging enabled!"); 
     425    #endif 
    417426 
    418427    while(true){