Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years ago.
UART communication in FRDM k64F
Hi,
My code:
#include "mbed.h" #include "math.h" #include <string.h> Serial pc(USBTX, USBRX); Serial sendingData(PTC17, PTC16); Serial receivingData(PTD3,PTD2); char message[] = "coap CON GET fd61:7409:e1d2:56f2:587f:c682:5d9c:6951 /temp\n"; char data[2]; char command[80]; int main() { pc.baud(115200); sendingData.baud(115200); receivingData.baud(115200); while(1) { sendingData.printf("%s", message); if (sendingData.readable()) { sendingData.gets(command, 80); } uint8_t i = command[64]; uint8_t j = command[65]; printf("%c" , i); printf("%c" , j); for(int k = 0; k < 1 ; k++) { data[k]=command[64]; k++; data[k]=command[65]; } receivingData.puts(data); //FormatToSend wait(30.0); } }
In the above code sendingData.printf("%s", message) does send the command to KW41Z board. I understand this while(1) works on a continuous loop but the problem is
<<code>>
uint8_t i = command[64];
uint8_t j = command[65];
printf("%c" , i);
printf("%c" , j);
<</code>
the commands are not able to read the data when I add the wait time inside while(1) or when I add this sendingData.printf("%s", message) inside while(1) loop.
I want to send command [message] every 5 minutes from K64F board and receive the data back in every 5 minutes. Any ideas on how to do it?