Tool/software:
Hello,
I am modifying the TI-RTOS tcpEcho function. In short, I have two tasks: a tcp task, and a UART task. This is the same tcp task that is originally with the tcpEcho example.
In summary, I want to echo whatever the tcp socket receives out of both the tcp socket, and the UART. Please note that these are separate tasks, and UART is at a lower priority.
The problem I have encountering is that the "send" function, which calls NDK_send, does not appear to be blocking. Because of this, the tcp task is put to sleep before the send function has finished. This is creating timing issues, or appears to be.
Questions: 1) can I make the send function blocking? 2) Is there a status or callback that indicates when the send function is done?
Below is my current code. I've commented out the mailbox related items.
Thank you!
//=============================================================================
/**
@return
- Void
Task to handle TCP connection. Can be multiple Tasks running
this function.
*/
Void tcpWorker
(
UArg arg0, ///< task argument 0
UArg arg1 ///< task argument 1
)
{
int32_t clientfd = (int32_t)arg0;
int32_t bytesRcvd;
int32_t bytesSent;
bool loopError = false;
volatile bool mailboxPostSuccess = false;
System_printf("tcpWorker: start clientfd = 0x%x\n", clientfd);
/* SysMin will only print to the console when you call flush or exit */
System_flush();
while ((!loopError) && ((bytesRcvd = recv(clientfd, tcpTaskSys.buffer.x, TCPPACKETSIZE, 0))) > 0)
{
/* TCP Echo Functionality */
bytesSent = send(clientfd, tcpTaskSys.buffer.x, bytesRcvd, 0);
if ((bytesSent < 0) || (bytesSent != bytesRcvd))
{
System_printf("Error: send failed.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();
break;
//loopError = true;
}
//else
//{
/* EGSE Code */
//mailboxPostSuccess = Mailbox_post(*(tcpTaskSys.rs422Handle), tcpTaskSys.buffer.x, BIOS_NO_WAIT);//sizeof(buffer)); //TODO double check the sizeof(buffer) statement.
//if (true == mailboxPostSuccess)
//{
//System_printf("Mailbox post to RS422 successful.\n");
/* SysMin will only print to the console when you call flush or exit */
//System_flush();
//Task_sleep(GetSleepTickCount());
//}
//else
//{
//TODO if the mailbox is full, add push to FIFO here
//System_printf("Mailbox error!\n");
/* SysMin will only print to the console when you call flush or exit */
//System_flush();
//}
// }
}
System_printf("tcpWorker stop clientfd = 0x%x\n", clientfd);
close(clientfd);
}