NET_ETHERNET server mode. call back "Net_Ethernet_Intern_UserTCP"

General discussion on mikroC PRO for ARM.
Post Reply
Author
Message
engr.talha72
Posts: 15
Joined: 05 Sep 2018 08:48

NET_ETHERNET server mode. call back "Net_Ethernet_Intern_UserTCP"

#1 Post by engr.talha72 » 18 Feb 2022 05:45

Hi,
I am working on TCP server/client mode and I am using "Net_Ethernet" library from "libstock". I have successfully testes TCP client mode and it works perfectly fine. However, in TCP server mode I am unable to send TCP packet using "Net_Ethernet_Intern_startSendTCP" command, which aims to call back "Net_Ethernet_Intern_UserTCP" function. Also the "socket state" (sock->state) always shows '0' even the client is connected to TCP server. TCP server replies back correctly when Client sends request. My concern is that I WANT TO SEND DATA TO CLIENT WITHOUT GENERATING ANY REQUEST FROM CLIENT SIDE. In simple words, I wish to call back "Net_Ethernet_Intern_UserTCP" function in Server mode same as it is being called in Client mode. Is possible to do so? kindly help.

engr.talha72
Posts: 15
Joined: 05 Sep 2018 08:48

Re: NET_ETHERNET server mode. call back "Net_Ethernet_Intern_UserTCP"

#2 Post by engr.talha72 » 21 Feb 2022 10:11

Since NO ONE have replied to this post. I would like to add one more querry. In TCP server mode, server automatically closes the socket after some time is if "Net_Ethernet_Intern_disconnectTCP(socket);" function is not used. I wish to know if it is possible to prevent server from disconnecting the socket by itself. I wish to connect it permanently unless the client disconnects.

engr.talha72
Posts: 15
Joined: 05 Sep 2018 08:48

Re: NET_ETHERNET server mode. call back "Net_Ethernet_Intern_UserTCP"

#3 Post by engr.talha72 » 24 Feb 2022 03:14

ANYONE?????????????????????? :(

engr.talha72
Posts: 15
Joined: 05 Sep 2018 08:48

Re: NET_ETHERNET server mode. call back "Net_Ethernet_Intern_UserTCP"

#4 Post by engr.talha72 » 02 Mar 2022 01:45

more than a week and no support anywhere.... :(

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: NET_ETHERNET server mode. call back "Net_Ethernet_Intern_UserTCP"

#5 Post by filip » 02 Mar 2022 14:06

Hi,

I apologize for the late reply, can you please explain your issues in details ?
Which hardware, compiler, example and library are you using ? Please attach relevant screenshots, photos and schematics.

Regards,
Filip.

engr.talha72
Posts: 15
Joined: 05 Sep 2018 08:48

Re: NET_ETHERNET server mode. call back "Net_Ethernet_Intern_UserTCP"

#6 Post by engr.talha72 » 03 Mar 2022 02:50

Thank you so much for your response.

I using Mikroc pro for ARM compiler. I have a custom board that has the same circuit as EasyMX pro For STM32. I have used this circuit for several applications and it has no problem at all. I am using STM32F407 MCU and Net_Ethernet_Intern library from Libstock. I am making Modbus RTU to Modbus TCP converter (which is the same as receiving data from RS485 via UART and forwarding it to TCP port and vice-versa). In this application, sometimes my designed hardware has to act as Server and sometimes as a Client. I have tested Client mode for this, and it works perfectly since I can check socket state all the time "socket->state" and can callback "Net_Ethernet_Intern_userTCP()" Function via "Net_Ethernet_Intern_startSendTCP(socket);" once "socket->state == 3". So overall, In Client mode, I have NO PROBLEM in connecting server and send or receiving data from the server since I have full control on "Net_Ethernet_Intern_userTCP()" callback.

The problem happens when is make my hardware as a Server that waits for the client to connect. Client connection itself has no issue, but I am facing difficulties is sending and receiving data to/from the Client. Following are the issues in detail.

1. "socket->state" always stays '0' when checked outside "Net_Ethernet_Intern_userTCP()" Function and I have no option to send data to client until the client request for data. I understand that a TCP server is supposed to act like this, it should send data to client upon request. However, I wish to send data to client WITHOUT any request coming from client side. For exmaple, I want RX/TX data same as the UART port once TCP connection is established between STM32 based Server (My designed board) and external Client. Kindly guide me how I can send data to client without getting any request. I want to achieve something like "Net_Ethernet_Intern_startSendTCP(socket);" for callback "Net_Ethernet_Intern_userTCP()" in server mode.

2. Another strange problem I am facing is that "Net_Ethernet_Intern_userTCP()" stops receiving data suddenly after some time and again starts receiving after 7 8 seconds (data sending period 1sec). I am not closing the socket connection since my application needs continuous connection between server and client. But I think the server is automatically closing the socket after some timeout (I am not sure about it). This problem ends up in missing data packets. However, if data sending speed from the client-side is increased (200ms for instance), missing data packets are a lot less.

I am attaching the project file of my source code and circuit diagram as well. In the code (tcp_Server = 1) means serve mode. DONOT focus on the code under (if(tcp_Server ==0)) because that is for client mode.
Ethernet to RS232 - V2.0.zip
Project File
(758.46 KiB) Downloaded 52 times
Attachments
circuit
circuit
Schemtic.JPG (101.53 KiB) Viewed 1542 times


Post Reply

Return to “mikroC PRO for ARM General”