Dual CANbus monitor and instrumentation cluster supporting ILI9341 display controller

Dependencies:   SPI_TFTx2_ILI9341 TOUCH_TFTx2_ILI9341 TFT_fonts mbed

Fork of CANary by Tick Tock

Revision:
161:71ac85d11f03
Parent:
160:905fe45ed54b
Child:
169:84d790ac18a2
--- a/utility.cpp	Wed Nov 20 13:13:54 2013 +0000
+++ b/utility.cpp	Thu Nov 21 14:17:35 2013 +0000
@@ -47,7 +47,6 @@
 
 void logCan (char mType, CANMessage canRXmsg) {
 
-   // re-arranged to put static first
     static unsigned char ii = 0;
     static unsigned char lasti = 0; // indexindex
     static unsigned char bdi=0;
@@ -63,7 +62,7 @@
     unsigned short ts;
 
     if(debugMode||(skin==ggSkin)){ 
-        // code to insert actual number of dropped frames for overrun debug - skiped in normal mode to keep logcan short
+        // code to insert actual number of dropped frames for overrun debug - skipped in normal mode to keep logcan short
         if(logOpen){
             // check to see if buffer is already full (read - write) = 1
             // actually the last buffer location cannot be used because then 
@@ -168,7 +167,7 @@
             writeBuffer[localWritePointer][2]=(ts&0x00ff);
             writeBuffer[localWritePointer][3]=canRXmsg.id&0xff;
             writeBuffer[localWritePointer][4]=(canRXmsg.id>>8)+(canRXmsg.len<<4);
-            for(i=5;i<13;i++){ // Is there a better way to do this? (writeBuffer[localWritePointer][5]=canRXmsg.data?)
+            for(i=5;i<13;i++){ // Is there a better way to do this?
                 writeBuffer[localWritePointer][i]=canRXmsg.data[i-5];
             }
             if (writePointer==readPointer) {
@@ -181,19 +180,19 @@
 
     if(canRXmsg.id<0x800){ // Block FFE and FFF messages
         if(indexLastMsg[canRXmsg.id]==0) { //Check if no entry
-            //ii=ii<99?ii+1:0; // Should never wrap - less than 100 different messages ever used
             if(ii<99) {
-                //indexLastMsg[canRXmsg.id]=ii; //Create entry if first message
                 indexLastMsg[canRXmsg.id]=++ii; //Create entry for first MsgID occurance
                 // ii max is 99 here
             } else {
                 // the ii array is full, more than 100 MsgIDs found
                 if(ii==99) {
                     ii++; // step to 100 to log only one error
-                    printMsg("MsgID buffer overrun.\n"); // write buffer overrun
+                    printMsg("msgID buffer overrun.\n");
+                    beep3(500,0.25,1000,0.5,500,0.25); //Alert driver to check log
                 }
             }
         }
+        lastMsg[indexLastMsg[canRXmsg.id]]=canRXmsg; //Store data in table at assigned index
         
         //----------------
         if(dMode[0]==changedScreen||dMode[1]==changedScreen){// Skip if not using (for execution speed)
@@ -206,8 +205,6 @@
             }
             msgChanged[indexLastMsg[canRXmsg.id]]=changed;
         }
-    
-        lastMsg[indexLastMsg[canRXmsg.id]]=canRXmsg; //Store in table
         
         //-------------------
         //Miscellaneous on-recieve operations below