Enzo Grimeau
/
buffertest
test pour buffer
Diff: main.cpp
- Revision:
- 11:f6ca29fae30c
- Parent:
- 10:8895b56c630c
diff -r 8895b56c630c -r f6ca29fae30c main.cpp --- a/main.cpp Mon Nov 23 22:19:13 2020 +0000 +++ b/main.cpp Tue Dec 08 07:08:48 2020 +0000 @@ -3,32 +3,42 @@ // lien serie via USB avec Terarerm // Universite Paris-Saclay - IUT Cachan RawSerial pc_raw(USBTX, USBRX); // ou SERIAL-TX, SERIAL_RX ou PA_2,PA_3 -CircularBuffer < char, 1024> mon_buffer; // buffer circulaire de 1024 char +CircularBuffer < char, 10> mon_buffer; // buffer circulaire de 1024 char DigitalOut ledB(D8); void reception_symbole(void); + static char test[100]; int main() { char symbole; pc_raw.baud(115200); pc_raw.attach(&reception_symbole); pc_raw.printf("Echo test buffer circulaire\r\n"); - ledB=0; + ledB=1; mon_buffer.reset(); while(1) { - while(!mon_buffer.empty()) { + while(mon_buffer.full()) { + ledB=1; mon_buffer.pop(symbole); pc_raw.putc(symbole); + pc_raw.printf("pop=%c\r\n",symbole); + + } + + } } void reception_symbole(void) { + + static int i; char symbole; - if(pc_raw.readable()) { - ledB=!ledB; - symbole=pc_raw.getc(); - mon_buffer.push(symbole); - } + ledB=0; + symbole=pc_raw.getc(); + mon_buffer.push(symbole); + pc_raw.printf("push=%c\r\n",symbole); + + }