This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Question about uart transfer buffer

So, I am developing an application where I will use uart to transmit some data from the PC to the nrf board. The issue is that the data I am transferring is quite large (64KB). I have written a code that would work in terms of communication, but I seriously suspect that not all data has been transmitted. Please see the attached as an example:

#define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 256 /**< UART RX buffer size. */

// allocate space for the binary data
char bin_data[65536];

// function that handles receiving message from PC: as noted, I will basically pass my bin_data to the below function for getting data from the PC

bool receiveMessage(char * buffer, int start_index, bool cmd_flag) {

    while (app_uart_get(&cr) != NRF_SUCCESS);
    buffer[start_index] = cr;

    . ..

}

I am wondering what's the solution to receive full 65536 bytes from the PC? I have tested my code such that I know the message are all correct when they are less than the buffer size.

Thanks,

Jinyue

  • As a follow up, the baudrate I am using is 115200. On the PC end, the pyserial library is used to communicate with nRF through uart. Specifically, I am loading the data as a byte array (of size 64KB) and that gets send through uart by the function pyserial.write().

    I am wondering what's the maximum buffer size allowed for Rx and Tx. Or should I slow down the baud rate? For now, it seems like when I am transmitting large sized data, the board cannot handle them in time and thus data were lost in the process. Thanks

  • The only thing limiting the buffer sizes are the available RAM in your device, but usually 256 is sufficient for both TX and RX buffers. You say that you have a suspicion that some data is lost, are you not able to see what you send and receive and make sure that these match in content and size?

    Best regards,

    Simon

Related