Hello guys!
I am trying to connect for Nucleo a some device.
Device send and read command like [0xaa, 0x70, 0x00, 0xcc, 0x33, 0xc3, 0x3c].
I managed to send the commands, but I do not have to read it.
I would like to read them and display them on the USB for the analysis of these commands.
Unfortunately I can not understand what exactly I am doing wrong.
my code
#include "mbed.h"
Serial USB_SP(USBTX,USBRX,NULL,115200); // tx, rx
Serial STONE_SP(PC_10,PC_11,NULL,115200); // tx, rx
DigitalOut myled(LED1);
DigitalIn mybutton(USER_BUTTON);
void LoadFirstScreen(void)
{
char s[] = {0xaa, 0x70, 0x00, 0xcc, 0x33, 0xc3, 0x3c};
STONE_SP.puts(s);
}
void LoadLogo(void)
{
char s[] = {0xaa, 0x70, 0x00, 0xcc, 0x33, 0xc3, 0x3c};
char temp;
STONE_SP.puts(s);
for (int i=0; i<250; i++) { //Load Logo
temp = s[2];
temp = temp++;
s[2] = temp;
STONE_SP.puts(s);
wait(0.01);
}
}
int main()
{
LoadFirstScreen();
while(1) {
myled = 1;
wait(0.5);
USB_SP.printf("The commands received are\n");
if (mybutton == 0) { // Button is pressed
LoadLogo();
}
//------------------------------------------------------
USB_SP.printf("%d,", STONE_SP.readable());
while (STONE_SP.readable()>0){
USB_SP.putc(STONE_SP.getc());
wait_ms(2);
}
wait_ms(10);
myled = 0;
wait(0.5);
}
}
Hello guys!
I am trying to connect for Nucleo a some device. Device send and read command like [0xaa, 0x70, 0x00, 0xcc, 0x33, 0xc3, 0x3c].
I managed to send the commands, but I do not have to read it.
I would like to read them and display them on the USB for the analysis of these commands. Unfortunately I can not understand what exactly I am doing wrong.
my code