![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
version with updated libs
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:
- 4:fbbf5d1785e7
- Parent:
- 3:2de8e4771674
- Child:
- 6:55fdfef6dfa9
--- a/ManageBufferJPA.cpp Wed Sep 02 12:54:45 2020 +0000 +++ b/ManageBufferJPA.cpp Wed Sep 02 14:43:31 2020 +0000 @@ -1,19 +1,30 @@ #include "mbed.h" const int kMaxBufferSize = 125; + volatile char bufferSerialUSB[kMaxBufferSize+3]; volatile int idxSerialIntUSB = 0; int idxSerialUserUSB = 0; volatile int msgSerialUSB = 0; +volatile char bufferSerial2[kMaxBufferSize+3]; +volatile int idxSerialInt2 = 0; +int idxSerialUser2 = 0; +volatile int msgSerial2 = 0; + +volatile char bufferSerial7[kMaxBufferSize+3]; +volatile int idxSerialInt7 = 0; +int idxSerialUser7 = 0; +volatile int msgSerial7 = 0; + //RawSerial -RawSerial serialUSB(USBTX, USBRX); // serial PC -Serial serial2(PC_6, PC_7); // TX, RX for udp bridge -Serial serial7(PF_7, PF_6); // TX, RX for extension +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() -{ + { if(serialUSB.readable()) { bufferSerialUSB[idxSerialIntUSB]=(serialUSB.getc()); @@ -23,17 +34,47 @@ msgSerialUSB = 1; } return; -} + } +void serial2_int_recv() + { + if(serial2.readable()) + { + bufferSerial2[idxSerialInt2]=(serial2.getc()); + idxSerialInt2++; + if (idxSerialInt2 >= kMaxBufferSize) {idxSerialInt2 = 0;} + bufferSerial2[idxSerialInt2]= 0; + msgSerial2 = 1; + } + return; + } + +void serial7_int_recv() + { + if(serial7.readable()) + { + bufferSerial7[idxSerialInt7]=(serial7.getc()); + idxSerialInt7++; + if (idxSerialInt7 >= kMaxBufferSize) {idxSerialInt7 = 0;} + bufferSerial7[idxSerialInt7]= 0; + msgSerial7 = 1; + } + return; + } + void initSerial() { serialUSB.baud(115200); serialUSB.attach(&serialUSB_int_recv, Serial::RxIrq); serial2.baud(115200); // required for UDP bridge + serial2.attach(&serial2_int_recv, Serial::RxIrq); serial7.baud(115200); // required for tasmota - //serial7.attach(&pc_recv, Serial::RxIrq); + serial7.attach(&serial7_int_recv, Serial::RxIrq); + bufferSerialUSB[0] = '\0'; + bufferSerial2[0] = '\0'; + bufferSerial7[0] = '\0'; } @@ -41,7 +82,6 @@ { serialUSB.printf(str); } - void receiveSerialUSB() { while(idxSerialIntUSB != idxSerialUserUSB) @@ -58,8 +98,30 @@ { serial2.printf(str); } - +void receiveSerial2() + { + while(idxSerialInt2 != idxSerialUser2) + { + x=bufferSerial2[idxSerialUser2]; + printf("%c",x); + idxSerialUser2 = idxSerialUser2 + 1; + if (idxSerialUser2 >= kMaxBufferSize) {idxSerialUser2 = 0;} + } + msgSerial2 = 0; + } + void sendserial7(char * str) { serial7.printf(str); + } +void receiveSerial7() + { + while(idxSerialInt7 != idxSerialUser7) + { + x=bufferSerial7[idxSerialUser7]; + printf("%c",x); + idxSerialUser7 = idxSerialUser7 + 1; + if (idxSerialUser7 >= kMaxBufferSize) {idxSerialUser7 = 0;} + } + msgSerial2 = 0; } \ No newline at end of file