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

Branch:
Metric
Revision:
104:5a19101aaac5
Parent:
102:fd19f777a0b4
Child:
106:f016912a03db
--- a/utility.cpp	Thu Jun 20 23:07:27 2013 +0000
+++ b/utility.cpp	Fri Jun 28 00:11:41 2013 +0000
@@ -149,30 +149,32 @@
         }
     }else{ // not debugMode - keep code short
         if(logOpen){
-            NVIC_DisableIRQ(CAN_IRQn); // Block interrupts until write pointer assigned
-            int localWritePointer = writePointer++; // create local copy to make logCan reentrant
-            // note that the static variables do not prevent safe reentry
-            // since they are only used for msgId<0x800 which will never interrupt
-            // another msgId<0x800 (both CANbusses are same priority)
-            if (writePointer >= maxBufLen) {
-                writePointer = 0;
-                led3 = !led3;
-            }
-            NVIC_EnableIRQ(CAN_IRQn); // Unblock interrupts once local pointer set and global pointer incremented
-            ts=getTimeStamp();
-            writeBuffer[localWritePointer][0]=mType;
-            writeBuffer[localWritePointer][1]=(ts&0xff00)>>8;
-            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?)
-                writeBuffer[localWritePointer][i]=canRXmsg.data[i-5];
-            }
-            if (writePointer==readPointer) {
-                // Just caught up to read pointer
-                sprintf(sTemp,"Write buffer overrun.\n");
-                printMsg(sTemp); // write buffer overrun
-                spkr.beep(500,0.25);
+            if(canRXmsg.id>0) {
+                NVIC_DisableIRQ(CAN_IRQn); // Block interrupts until write pointer assigned
+                int localWritePointer = writePointer++; // create local copy to make logCan reentrant
+                // note that the static variables do not prevent safe reentry
+                // since they are only used for msgId<0x800 which will never interrupt
+                // another msgId<0x800 (both CANbusses are same priority)
+                if (writePointer >= maxBufLen) {
+                    writePointer = 0;
+                    led3 = !led3;
+                }
+                NVIC_EnableIRQ(CAN_IRQn); // Unblock interrupts once local pointer set and global pointer incremented
+                ts=getTimeStamp();
+                writeBuffer[localWritePointer][0]=mType;
+                writeBuffer[localWritePointer][1]=(ts&0xff00)>>8;
+                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?)
+                    writeBuffer[localWritePointer][i]=canRXmsg.data[i-5];
+                }
+                if (writePointer==readPointer) {
+                    // Just caught up to read pointer
+                    sprintf(sTemp,"Write buffer overrun.\n");
+                    printMsg(sTemp); // write buffer overrun
+                    spkr.beep(500,0.25);
+                }
             }
         }
     }