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.
Revision 11:f6ca29fae30c, committed 2020-12-08
- Comitter:
- grimwald
- Date:
- Tue Dec 08 07:08:48 2020 +0000
- Parent:
- 10:8895b56c630c
- Commit message:
- Buffer test;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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); + + }