MCF52235 - Call to socket() fails

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MCF52235 - Call to socket() fails

跳至解决方案
1,678 次查看
ArtyCF
Contributor II

Hello everyone,

I've been stuck for a while now on a problem trying to create a socket.
I have an application consisting of two tasks (lets call them Task A and Task B).  Task A is the main task, automatically  started by MQX.  Task A initializes RTCS, sets up the Ethernet device, obtains an IP address using DHCP and creates and starts Task B.  Task B is supposed to create a socket and then listen for incoming remote connections.  One of the first things it does is attempt to create the listening socket by calling the RTCS socket() function.  However, this call never returns and worse, no other tasks appear to run after that.  If I break the execution and step through the code I can see that the program seems to be looping inside the MQX dispatcher.  Even the RTCS task is no longer running because I can't even ping my board.

If I try calling socket() in Task A there is no problem at all and a handle to a new socket is returned.

Am I missing something fundamental here?  I've run out of things to try and I can't find an example where a socket is created on a task that is not the same one that initialized RTCS.

Any help or suggestions would be greatly appreciated.

Thank you.

标签 (1)
标记 (1)
0 项奖励
1 解答
607 次查看
madifazio
Contributor III

Hi, 

How do you call the socket() function? Did you check the stack size of the task B?.

When you break the execution, can you see the status of Task B?

The priorities of the tasks seems to be ok.

在原帖中查看解决方案

0 项奖励
4 回复数
607 次查看
madifazio
Contributor III

Hi,

Check if the priority of the Task B is lower than the priority of the RTCS task.

Marcos

0 项奖励
607 次查看
ArtyCF
Contributor II

Thanks Marcos.  I had wondered about that too because it looked like some form of deadlock.  I tried lowering the priorities of my two tasks but that didn't help.  In module "rtcsglob.c" the global parameter _RTCSTASK_priority is set to 6 so I assume that is the priority that the RTCS task is using.  My Task A and Task B have lower priorities of 10 and 9 respectively.

0 项奖励
608 次查看
madifazio
Contributor III

Hi, 

How do you call the socket() function? Did you check the stack size of the task B?.

When you break the execution, can you see the status of Task B?

The priorities of the tasks seems to be ok.

0 项奖励
607 次查看
ArtyCF
Contributor II

Apparently my Task B stack was too small at 500 bytes (in comparison Task A stack was 3000 bytes).  I increased the size of the Task B stack to 3000 bytes and now it works.  Somehow when I was looking for differences between the two tasks I missed that glaringly obvious fact :smileyhappy:.   I'm surprised that a call to socket() consumes so much of the stack but my background has mostly been with 8-bit microcontrollers where only a few hundred bytes are available.  I guess I've learned the hard way.

 

In any case, I'm finally moving forward again.  Thank you for your interest and suggestions Marcos, I'm grateful for all your help with this.

 

 

0 项奖励