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.
Dependencies: SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2_ILI9341 mbed
Fork of CANary_corrupt by
Revision 75:77bd26829dca, committed 2013-04-15
- Comitter:
- TickTock
- Date:
- Mon Apr 15 14:33:53 2013 +0000
- Parent:
- 74:e491e92b0bef
- Child:
- 76:fb6779d0963e
- Commit message:
- Fixed overrun reporting bug but has problem with mbed41 library
Changed in this revision
--- a/main.cpp Mon Apr 15 11:40:25 2013 +0000
+++ b/main.cpp Mon Apr 15 14:33:53 2013 +0000
@@ -64,9 +64,10 @@
unsigned char battData[256]={0};
unsigned char msgChanged[100]; // inidcates which bytes changed
char c;
-volatile int writePointer = 0;
-volatile int secsNoMsg = 0;
-volatile int secsNoTouch = 0;
+volatile unsigned short writePointer = 0;
+unsigned short readPointer=0;
+volatile unsigned short secsNoMsg = 0;
+volatile unsigned short secsNoTouch = 0;
volatile bool canIdle;
volatile bool userIdle;
bool touched=false; //flag to read touchscreen
@@ -119,7 +120,6 @@
unsigned short pointerSep;
int main() {
- int readPointer=0;
char sTemp[40];
unsigned long secs;
unsigned char i,j,display=0,lwt=0;
@@ -273,11 +273,12 @@
spkr.beep(1000,0.25);
logEn=false;
} else {
- if (pointerSep>(maxBufLen*7/8)) { // Hi-water mark
- sprintf(sTemp,"Write buffer overrun.\n");
- logMsg(sTemp); // write buffer overrun
- spkr.beep(1000,0.25);
- }
+ //moved overrun detection to the write code in utility.cpp
+ //if (pointerSep>(maxBufLen*7/8)) { // Hi-water mark
+ // sprintf(sTemp,"Write buffer overrun.\n");
+ // logMsg(sTemp); // write buffer overrun
+ // spkr.beep(1000,0.25);
+ //}
while (readPointer != writePointer) {
for (j = 0; j<13; j++){
fprintf(file,"%c",writeBuffer[readPointer][j]);
--- a/utility.cpp Mon Apr 15 11:40:25 2013 +0000
+++ b/utility.cpp Mon Apr 15 14:33:53 2013 +0000
@@ -60,6 +60,12 @@
for(i=5;i<13;i++){ // Is there a better way to do this? (writeBuffer[writePointer][i]=canRXmsg.data?)
writeBuffer[writePointer][i]=canRXmsg.data[i-5];
}
+ if (writePointer==readPointer) {
+ // Just overwrote an entry that hasn't been sent to thumbdrive
+ sprintf(sTemp,"Write buffer overrun.\n");
+ logMsg(sTemp); // write buffer overrun
+ spkr.beep(1000,0.25);
+ }
if (++writePointer >= maxBufLen) {
writePointer = 0;
led3 = !led3;
--- a/utility.h Mon Apr 15 11:40:25 2013 +0000 +++ b/utility.h Mon Apr 15 14:33:53 2013 +0000 @@ -6,8 +6,8 @@ #include "TOUCH_TFTx2.h" extern Timer timer; -extern volatile int secsNoMsg; -extern volatile int secsNoTouch; +extern volatile unsigned short secsNoMsg; +extern volatile unsigned short secsNoTouch; extern volatile bool canIdle; extern volatile bool userIdle; extern char displayLog[20][40]; @@ -19,6 +19,7 @@ extern bool showCP; extern char writeBuffer[maxBufLen][13]; extern volatile int writePointer; +extern unsigned short readPointer; extern DigitalOut led1,led2,led3,led4; extern char indexLastMsg[0x800]; extern unsigned char dMode[2];
