![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
updated version with parameters loaded from sdcard
Dependencies: F7_Ethernet mbed MbedJSONValue LCD_DISCO_F746NG mbed-rtos BSP_DISCO_F746NG CANMsg NetworkAPI SDFileSystem_Warning_Fixed GroveStreamsmodified LcdDiscoF746NgTracer JSON
Diff: ManageBufferJPA.cpp
- Branch:
- jpa
- Revision:
- 8:275ae4382788
- Parent:
- 6:55fdfef6dfa9
- Child:
- 10:41aff2b7acc6
--- a/ManageBufferJPA.cpp Fri Sep 04 09:48:07 2020 +0000 +++ b/ManageBufferJPA.cpp Tue Sep 08 15:00:05 2020 +0000 @@ -6,22 +6,30 @@ volatile int idxSerialIntUSB = 0; int idxSerialUserUSB = 0; volatile int msgSerialUSB = 0; +char stringSerialUSB[kMaxBufferSize+3]; +int stringSerialUSBok = 0; // si ==1 alors trame dispo (fin de trame == LF ou 10 +int idxSerialStringUSB = 0; volatile char bufferSerial2[kMaxBufferSize+3]; volatile int idxSerialInt2 = 0; int idxSerialUser2 = 0; volatile int msgSerial2 = 0; +char stringSerial2[kMaxBufferSize+3]; +int stringSerial2ok = 0; // si ==1 alors trame dispo (fin de trame == LF ou 10 +int idxSerialString2 = 0; volatile char bufferSerial7[kMaxBufferSize+3]; volatile int idxSerialInt7 = 0; int idxSerialUser7 = 0; volatile int msgSerial7 = 0; +char stringSerial7[kMaxBufferSize+3]; +int stringSerial7ok = 0; // si ==1 alors trame dispo (fin de trame == LF ou 10 +int idxSerialString7 = 0; //RawSerial RawSerial serialUSB(USBTX, USBRX); // serial PC RawSerial serial2(PC_6, PC_7); // TX, RX for udp bridge RawSerial serial7(PF_7, PF_6); // TX, RX for extension -volatile char x; // --------------------------------------------------- void serialUSB_int_recv() { @@ -84,14 +92,24 @@ } void receiveSerialUSB() { - while(idxSerialIntUSB != idxSerialUserUSB) + char x; + if (stringSerialUSBok == 0) // string user dispo flag a mettre a 0 par user a chaque lecture de string { - x=bufferSerialUSB[idxSerialUserUSB]; - printf("%c",x); - idxSerialUserUSB = idxSerialUserUSB + 1; - if (idxSerialUserUSB >= kMaxBufferSize) {idxSerialUserUSB = 0;} + while(idxSerialIntUSB != idxSerialUserUSB) + { + x=bufferSerialUSB[idxSerialUserUSB]; + //printf("%c",x); + idxSerialUserUSB = idxSerialUserUSB + 1; + if (idxSerialUserUSB >= kMaxBufferSize) {idxSerialUserUSB = 0;} + + stringSerialUSB[idxSerialStringUSB] = x; + idxSerialStringUSB = idxSerialStringUSB + 1;stringSerialUSB[idxSerialStringUSB] = 0; + if (idxSerialStringUSB >= kMaxBufferSize) + {stringSerialUSB[idxSerialStringUSB-1] = 10;idxSerialStringUSB = 0;stringSerialUSBok = 1;} + if (x == 10) {idxSerialStringUSB = 0;stringSerialUSBok = 1;} + } + msgSerialUSB = 0; } - msgSerialUSB = 0; } void sendSerial2(char * str) @@ -100,14 +118,24 @@ } void receiveSerial2() { - while(idxSerialInt2 != idxSerialUser2) + char x; + if (stringSerial2ok == 0) // string user dispo flag a mettre a 0 par user a chaque lecture de string { - x=bufferSerial2[idxSerialUser2]; - printf("%c",x); - idxSerialUser2 = idxSerialUser2 + 1; - if (idxSerialUser2 >= kMaxBufferSize) {idxSerialUser2 = 0;} + while(idxSerialInt2 != idxSerialUser2) + { + x=bufferSerial2[idxSerialUser2]; + //printf("%c",x); + idxSerialUser2 = idxSerialUser2 + 1; + if (idxSerialUser2 >= kMaxBufferSize) {idxSerialUser2 = 0;} + + stringSerial2[idxSerialString2] = x; + idxSerialString2 = idxSerialString2 + 1;stringSerial2[idxSerialString2] = 0; + if (idxSerialString2 >= kMaxBufferSize) + {stringSerial2[idxSerialString2-1] = 10;idxSerialString2 = 0;stringSerial2ok = 1;} + if (x == 10) {idxSerialString2 = 0;stringSerial2ok = 1;} + } + msgSerial2 = 0; } - msgSerial2 = 0; } void sendSerial7(char * str) @@ -116,12 +144,22 @@ } void receiveSerial7() { - while(idxSerialInt7 != idxSerialUser7) + char x; + if (stringSerial7 == 0) // string user dispo flag a mettre a 0 par user a chaque lecture de string { - x=bufferSerial7[idxSerialUser7]; - printf("%c",x); - idxSerialUser7 = idxSerialUser7 + 1; - if (idxSerialUser7 >= kMaxBufferSize) {idxSerialUser7 = 0;} + while(idxSerialInt7 != idxSerialUser7) + { + x=bufferSerial7[idxSerialUser7]; + printf("%c",x); + idxSerialUser7 = idxSerialUser7 + 1; + if (idxSerialUser7 >= kMaxBufferSize) {idxSerialUser7 = 0;} + + stringSerial7[idxSerialString7] = x; + idxSerialString7 = idxSerialString7 + 1;stringSerial2[idxSerialString7] = 0; + if (idxSerialString7 >= kMaxBufferSize) + {stringSerial7[idxSerialString7-1] = 10;idxSerialString7 = 0;stringSerial7ok = 1;} + if (x == 10) {idxSerialString7 = 0;stringSerial7ok = 1;} + } + msgSerial2 = 0; } - msgSerial2 = 0; } \ No newline at end of file