Dear Friends, I am trying to create a simple TCP server using STM32F107RCt6 microcontroller and DP83848C PHY. I use CMSIS RTXv4 and Keil uVision5 pro and Keil Network component version 7.7.0. In RTX_Conf_CM.c configuration wizard, I've done the following configuration: Default Thread Stack size: 512 Main Thread Stack size: 800 Number of Threads with user-provided stack size: 2(netETH_Thread and netCore_Thread) Total stack size for user-provided stack size: 1536(512+1024) and user timers are enable. The Stack size and Heap size are respectively 1024 and 512 bytes. In RTE.h file I've enabled Ethernet RMII mode. The AHB clock and system clock are 72MHz. I've added the TCP_Socket_Server.c template file and uncomment lines 18 and 42 and delete IPv6 code and change the client IP address to my computer IP. The code is as follows:
#include "rl_net.h" // Notify the user application about TCP socket events. uint32_t tcp_cb_server (int32_t socket, netTCP_Event event, const NET_ADDR *addr, const uint8_t *buf, uint32_t len) { switch (event) { case netTCP_EventConnect: // Connect request received if (addr->addr_type == NET_ADDR_IP4) { // IPv4 client if (addr->addr[0] == 192 && addr->addr[1] == 168 && addr->addr[2] == 0 && addr->addr[3] == 101) { // Accept connection from client at 192.168.0.101 return (1); } } // Deny connection. return (0); case netTCP_EventEstablished: // Connection established break; case netTCP_EventClosed: // Connection was properly closed break; case netTCP_EventAborted: // Connection is for some reason aborted break; case netTCP_EventACK: // Previously sent data acknowledged break; case netTCP_EventData: // Data received /* Example if ((buf[0] == 0x01) && (len == 2)) { // Switch LEDs on and off // LED_out (buf[1]); } */ break; } return (0); } // Allocate and initialize the socket. int main (void) { int32_t tcp_sock; netInitialize (); // Initialize TCP Socket and start listening on port 2000 tcp_sock = netTCP_GetSocket (tcp_cb_server); if (tcp_sock > 0) { netTCP_Listen (tcp_sock, 2000); } } //! [code_TCP_Socket_Server]
Unfortunately, the code is not working and I have no idea how to solve it. Any helps would be greatly appreciated.
Your program is terminated - you need to add an infinite loop to your main and poll the networking library.
Dear Tamir Michael,
Thank you for your reply.
Could you please tell me what you mean by saying poll the networking library in your infinite loop in main? Is there any especial function that I should call?
You mentioned you were using RTX but the code excerpt you provided show no evidence of that. Still, that does not essentially change the situation - your program must include an infinite loop
int main() { while (1) { // look at the TCP library's documentation and examples; There must be a function to call regularly to make sure it services its buffers and queue and generally works at all ... } }
http://www.keil.com/appnotes/files/apnt_268.pdf
Dear Mujtaba Hossaini,
I am also facing the same issue. Is you have resolved the issue? Please reply asap.
Thanks in advance.
Then you should also follow the same advice that Tamir Michael has already posted.
In particular, did you read the App Note ?
Is there any plan for ARM to release a mobile client for Keil?
thanks for the reply.
The app note is not relevant to my query. I have followed the suggestion given in earlier post but thats not resolved the problem