Hi All,
Here I met with a problem of ENOBUFS when sending . So I want to share my project structure to comfirm wether I use NDK in a right way.Thanks!
My software envirement:
XDCtools version: 3.25.0.48
SYSBIOS version: 6.35.1.29
NDK Core versison:2.22.3.20
am3359 ind sdk version : 1.1.0.3
Actrually what I want to achieve is two tasks call same send and receive function to send and receive raw ethernet packages. I achieve this by this way:
1. create one parent task ,in this task , I open one fd session and create two socket. socket_send for sending function and socket_rcv for receive function.
2.after creating the sockets.I create two child tasks.
3.In child tasks, fd session is opened in each task. Then these two tasks will call sendframe and receiveframe function when they need.
4.In sendframe function, at the begging it will call fdShare(socket_send), then call send function to send buffer out. fdClose will be called at the end of this function.
5.In receiveframe function, at the begging it will call fdShare(socket_rcv), then call recvnc function to receive from buffer in NDK. fdClose will be called at the end of this function.
Now when the application run for some time.I met with two problems:
1.The send funciton will meet with the ENOBUFS error and fail.
2.I dont know wether I need to free buffer after I call recvnc function. Cause when I try to recvncfree after recvnc, The NDK looks not able to receive at the next loop.
Code is like this:
void Task_Parent()
{
fdOpensession(TaskSelf());
socket_send = socket(AF_RAWETH, SOCK_RAWETH, rawether_type);
socket_rcv = socket(AF_RAWETH, SOCK_RAWETH, rawether_type);
... ...
Create child task 1;
Create child task 2:
}
void child task1()
{
fdOpensession(TaskSelf());
while(1)
{
... ...
SendFrame();
..
..
ReceiveFrame();
...
. .
}
}
void child task2()
{
fdOpensession(TaskSelf());
while(1)
{
... ...
SendFrame();
..
..
ReceiveFrame();
...
. .
}
}
void SendFrame()
{
fdShare(socket_send);
send(socket_send, buff, size, 0);
... ...
fdClose(socket_send);
}
void ReceiveFrame()
{
fdShare(socket_rcv);
recvnc(socket_rcv, (void**)&(pkt_data), MSG_WAITALL, &hBuffer );
... ...
fdClose(socket_rcv);
}