Hello, currently I am working on STM32-F746 discovery board which is receiving data from Bluepill over Uart port. The data is transferred properly but if i need to get size of buffer of internal queue it is returning -29. can someone help me to understand why size is not correct.
Hi there,
please be so kind and fill more information.
What a code/method return this value? How often you call that? How often you send data to this target?
BR, Jan
receiver side SMT32F746
#include "mbed.h"
#define MAXIMUM_BUFFER_SIZE 32
static DigitalOut led(LED1);
static BufferedSerial pc(USBTX, USBRX);
static BufferedSerial serial_port(TX7, RX7);
Thread buffsize;
void buffsizefunction(){
while(true){
printf("size of buffer %d\r\n", serial_port.size());
ThisThread::sleep_for(1000);
}
}
int main()
{
pc.set_baud(115200);
pc.set_format(
/* bits */ 8,
/* parity */ BufferedSerial::None,
/* stop bit */ 1
);
printf("Hello, Mbed!\n");
serial_port.set_baud(9600);
serial_port.set_format(
/* bits */ 8,
/* parity */ BufferedSerial::None,
/* stop bit */ 1
);
char buf[MAXIMUM_BUFFER_SIZE] = {0};
buffsize.start(buffsizefunction);
while (1) {
ThisThread::sleep_for(8000);
if (uint32_t num = serial_port.read(buf, sizeof(buf))) {
printf("Data: %s\r\n", buf);
led = !led;
}
}
return 0;
}
transmiter side BLUEPILL
#include "mbed.h"
#include "dev_trace.h"
static DigitalOut led(LED1);
static UnbufferedSerial serial_port(TX2, RX2);
uint8_t buf[] = "Don't Worry Be Happy.";
int main(void)
{
// Set desired properties (9600-8-N-1).
serial_port.baud(9600);
serial_port.format(
/* bits */ 8,
/* parity */ SerialBase::None,
/* stop bit */ 1
);
while(true){
serial_port.write(&buf, sizeof(buf));
ThisThread::sleep_for(5000);
}
} ```