hey all,
im new to this programing stuff
consider a buffer of size 2048bytes. the data i need to send is more than 2048 bytesof the of buffer. i have a func SendDataReq (u8* pu8_TxBuffPtr,u16 u16_NoBytes);. how do i send this data using this func

Dani AI

Generated

For : with a fixed 2048-byte transmit buffer and the function signature SendDataReq(u8* pu8_TxBuffPtr, u16 u16_NoBytes), the practical approach is to transmit the payload in buffer-sized chunks while respecting the function's ownership and completion semantics. 's hints point to two broad choices; the following shows a safe chunking pattern and the checks needed before reusing the same memory.

size_t remaining = total_len;
u8 *ptr = data_start;

while (remaining) {
    u16 chunk = (remaining > 2048) ? 2048 : (u16)remaining;
    SendDataReq(ptr, chunk);
    ptr += chunk;
    remaining -= chunk;
    /* If SendDataReq is asynchronous, wait for its completion signal here
       before overwriting or reusing the memory that ptr points to. */
}

Important cautions and next steps: confirm whether SendDataReq copies the data or requires the caller to keep the buffer valid until a completion callback or status indicates transmission finished (this is common when DMA or interrupts are used). If the function is non-blocking, implement a completion check, a callback, or double-buffering so the next chunk does not clobber an in-flight buffer. If SendDataReq does not accept queued segments and offers no completion mechanism, the driver/application must be changed to add a transmit queue. Finally, test edge cases (what happens if a single u16 value larger than the hardware MTU is passed), check return codes, and avoid using stack-only buffers when hardware requires stable memory during transfer.

Recommended Answers

All 3 Replies

>how do i send this data using this func
Either change the size of your buffer, or call the function multiple times. It really depends on how SendDataReq works.

>how do i send this data using this func
Either change the size of your buffer, or call the function multiple times. It really depends on how SendDataReq works.

hi thanks for the reply,
but the buffer remain constant. how do i call it repeatedly the same func.

>how do i call it repeatedly the same func.
The documentation will tell you how to do it if that capability is supported. If it's not supported, you're SOL.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.