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.
8 years, 12 months ago.
Asynchronous serial read buffer size
Hi, I'm writing a software for the board STM32 Nucleo-F207ZG. I use the asynchronous read method to call a method when the board receive the char '\n'. Everything works great but only if the board receive an amount of data wich is less than 256 bytes, but I have declared a length of 2048! There is a limit set somewhere? Thanks!
#include "mbed.h"
Serial pc(USBTX, USBRX, 115200);
event_callback_t serialEventCb;
uint8_t* rx_buf;
static void received_n(int events) {
// do stuff
pc.read(rx_buf, 2048, serialEventCb, SERIAL_EVENT_RX_ALL, '\n');
}
int main(){
rx_buf = (uint8_t*) malloc(2048*sizeof(uint8_t));
serialEventCb.attach(received_n());
pc.read(rx_buf, 2048, serialEventCb, SERIAL_EVENT_RX_ALL, '\n');
while(true){
sleep();
}
return 0;
}
2 Answers
7 years, 11 months ago.
See line 33:
https://github.com/ARMmbed/mbed-os/blob/master/drivers/UARTSerial.h
7 years, 11 months ago.
Here is some information about how you can override config settings - https://os.mbed.com/docs/v5.6/tools/configuring-tools.html
This is the lib file used by the Serial object - https://github.com/ARMmbed/mbed-os/blob/master/drivers/mbed_lib.json
Alternatively, you can call recv many times until you have received all data.