I’m trying to write code using MBED, but, there are some problem.
The thing is that I want to get “character arry”.
If I send MBED board “abcde” , board will get “abcde” and do something.
there is my code.
#include <mbed.h>
char message[200];
void Rx_interrupt() ;
int i;
Serial pc(PA_2,PA_3);
int main() {
pc.baud(115200);
pc.attach(&Rx_interrupt, Serial::RxIrq);
while(1)
{
}
return 0;
}
void Rx_interrupt() {
char a1[6]="abcde";
memset(message,0, sizeof(message));
i=0;
while(pc.readable()){
message[i]=pc.getc();
i++;
}
if(!strcmp(a1,message))
{
pc.printf(message);
}
else
{
pc.printf("FAIL");
}
}
============================================
this code is that I made.
if I send “abcde”, board should print “abcde” . <—my purpose
but, board print “FAIL” only 1time. what should I do?
I think that there have some problem in “pc.getc()”