![](/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.orig
- Branch:
- jpa
- Revision:
- 10:41aff2b7acc6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ManageBufferJPA.cpp.orig Tue Sep 15 19:11:11 2020 +0000 @@ -0,0 +1,127 @@ +#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 +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()); + idxSerialIntUSB++; + if (idxSerialIntUSB >= kMaxBufferSize) {idxSerialIntUSB = 0;} + bufferSerialUSB[idxSerialIntUSB]= 0; + 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(&serial7_int_recv, Serial::RxIrq); + bufferSerialUSB[0] = '\0'; + bufferSerial2[0] = '\0'; + bufferSerial7[0] = '\0'; + } +// ---------------------------------------------------- +void sendSerialUSB(char * str) + { + serialUSB.printf(str); + } +// ------------------------------------------------------------- +void receiveSerialUSB() + { + while(idxSerialIntUSB != idxSerialUserUSB) + { + x=bufferSerialUSB[idxSerialUserUSB]; + printf("%c",x); + idxSerialUserUSB = idxSerialUserUSB + 1; + if (idxSerialUserUSB >= kMaxBufferSize) {idxSerialUserUSB = 0;} + } + msgSerialUSB = 0; + } +// ------------------------------------- +void sendSerial2(char * str) + { + 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;} + } + msgSerial7 = 0; + } \ No newline at end of file