I want to send data from the ddr3 to PC using ethernet when given a GPIO interrupt, now I've finished transfer data using UDP, but to further improve the data rate, I have
the following question.
My task is as follows:
void udp_test()
{
SOCKET send = INVALID_SOCKET; // Sender socket.
struct sockaddr_in sout1; // Sender socket address structure
int i=0,count=0;
char* senddata;
int sentCnt;
senddata=(char *)DDR3BASEADDRESS;
// Allocate the file environment for this task
fdOpenSession( TaskSelf() );
// Create the send socket
send = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if( send == INVALID_SOCKET )
goto leave;
// Send socket: set Port = 5000, IP destination address = ANY
bzero( &sout1, sizeof(struct sockaddr_in) );
sout1.sin_family = AF_INET;
sout1.sin_len = sizeof( sout1 );
sout1.sin_port = htons(5000);
// Bind send socket
if ( bind( send, (PSA) &sout1, sizeof(sout1) ) < 0 )
{
printf("Send: %d",fdError());
goto leave;
}
//strcpy( sendBuffer, "Are you there?" );
for(i=0; i<1500; i++)
{
sendBuffer[i]=(char)i%(0xFF);
}
sout1.sin_addr.s_addr = inet_addr(UnicastAddr); // PC address is the destination
sout1.sin_port = htons(7); // Echo port (7) is where we want to send data
for(;;)
{
if(Ethernetswtich)
{
while(count++<1600)
{
do
{
//cycleDelay(5000);
TaskSleep(1);// this is a must,it means n ms send a packet ,it control the data rate
//0x040D2F65-0x03FFDCFA
sentCnt = sendto( send, senddata, 1024, 0, (PSA)&sout1, sizeof(sout1) );
}
while (sentCnt < 0);
senddata+=1024;// need to be direct back while finished
//printf (" Message sent to ethernet \n");
}
Ethernetswtich=0;
}
}
leave:
// We only get here on a fatal error - close the sockets
if( send != INVALID_SOCKET )
fdClose( send );
printf("Fatal Error\n");
// This task is killed by the system - here, we block
TaskBlock( TaskSelf() );
}
as I see the function TaskSleep(1); is essential in the packet sending. for TaskSleep(1), the data rate can be 1MB/s. but I can't make it higher.
without the TaskSleep function or replace it with the cycleDelay(5000) function, i can't recieve any packet in wireshark on PC.
the cycleDelay() is as follows:
void cycleDelay (uint32_t count)
{
uint32_t sat;
if (count <= 0)
return;
sat = TSCL + count;
while (TSCL < sat);
}
Why would i have to suspend the Task to send UDP packet? is the speed has some limitation, so i can only reach 1MB/s?
do any one have some suggustions?
Thanks!!!