Récupération de trame NMEA

Dependencies:   C12832-font

Committer:
gr91
Date:
Mon Nov 23 22:19:13 2020 +0000
Revision:
10:8895b56c630c
Parent:
9:a9dfb95b5d8a
Child:
11:983e4b214c0c
Echo buffer circulaire

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gr91 0:3aa4ba0ada56 1 #include "mbed.h"
gr91 10:8895b56c630c 2 // Echo avec buffer circulaire
gr91 8:23fca4edc6b9 3 // lien serie via USB avec Terarerm
gr91 6:a58f18b765cd 4 // Universite Paris-Saclay - IUT Cachan
gr91 8:23fca4edc6b9 5 RawSerial pc_raw(USBTX, USBRX); // ou SERIAL-TX, SERIAL_RX ou PA_2,PA_3
gr91 10:8895b56c630c 6 CircularBuffer < char, 1024> mon_buffer; // buffer circulaire de 1024 char
gr91 8:23fca4edc6b9 7 DigitalOut ledB(D8);
gr91 8:23fca4edc6b9 8 void reception_symbole(void);
gr91 0:3aa4ba0ada56 9 int main()
gr91 0:3aa4ba0ada56 10 {
gr91 10:8895b56c630c 11 char symbole;
gr91 8:23fca4edc6b9 12 pc_raw.baud(115200);
gr91 8:23fca4edc6b9 13 pc_raw.attach(&reception_symbole);
gr91 10:8895b56c630c 14 pc_raw.printf("Echo test buffer circulaire\r\n");
gr91 8:23fca4edc6b9 15 ledB=0;
gr91 10:8895b56c630c 16 mon_buffer.reset();
gr91 0:3aa4ba0ada56 17 while(1) {
gr91 10:8895b56c630c 18 while(!mon_buffer.empty()) {
gr91 10:8895b56c630c 19 mon_buffer.pop(symbole);
gr91 10:8895b56c630c 20 pc_raw.putc(symbole);
gr91 10:8895b56c630c 21 }
gr91 8:23fca4edc6b9 22 }
gr91 8:23fca4edc6b9 23 }
gr91 8:23fca4edc6b9 24 void reception_symbole(void)
gr91 8:23fca4edc6b9 25 {
gr91 10:8895b56c630c 26 char symbole;
gr91 8:23fca4edc6b9 27 if(pc_raw.readable()) {
gr91 8:23fca4edc6b9 28 ledB=!ledB;
gr91 10:8895b56c630c 29 symbole=pc_raw.getc();
gr91 10:8895b56c630c 30 mon_buffer.push(symbole);
gr91 0:3aa4ba0ada56 31 }
gr91 0:3aa4ba0ada56 32 }
gr91 7:37ea12f2b18f 33
gr91 8:23fca4edc6b9 34