ETHERNET Library Connection Status

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

ETHERNET Library Connection Status

#1 Post by nealet » 15 May 2018 13:17

Hi
I am using the "ETHERNET" library in the mikroelektronika MikroC PRO for PIC32 dev environment. My code is up and running but I am looking for a way, by looking at a status flag somewhere, to tell whether the TCP Socket that i may have opened, is still in fact open, Or to see if a I have received a FIN/ACK sequence from the Client to see if he closed the socket from his side?

I have used the Net_Ethernet_Internal library before but only for UDP, I found it had some wierd bug that when i tried using it for TCP, it would give out of sequence ACK responses. Anyway that is is another subject.

How can I tell by looking at local variables etc, whether a TCP socket that was opened with me (I am a MODBUS TCP Server in this context) is still open?

Is there some way to see if a cable is even still connected to the the Ethernet port?
(in another project, i monitored the status LEDs from the RJ45 Ethernet connector and could therefore tell if the cable had been pulled out. Unfortunately I cant do that in this project.

REgards
Nealet

nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

Re: ETHERNET Library Connection Status

#2 Post by nealet » 17 May 2018 13:15

Hello?

nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

Re: ETHERNET Library Connection Status

#3 Post by nealet » 22 May 2018 12:42

Hellooo?

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

Re: ETHERNET Library Connection Status

#4 Post by filip » 24 May 2018 11:10

Hi,

I apologize for the delayed reply, we are investigating this.

As soon as we have some information, we will post it here.

Regards,
Filip.

nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

Re: ETHERNET Library Connection Status

#5 Post by nealet » 24 May 2018 12:17

Thankyou
I will await the reply
Regards
Nealet

User avatar
marko.stankovic
mikroElektronika team
Posts: 108
Joined: 18 Dec 2017 15:44

Re: ETHERNET Library Connection Status

#6 Post by marko.stankovic » 24 May 2018 15:31

Hi,

When you install the Network Ethernet Library,
https://libstock.mikroe.com/projects/vi ... et-library
you have Socket structure definition, where they are defined whether the socket is open, ACK status, ...
In the help file Network_Internal_PIC32, you can find an explanation for this structure.

Also, in the example of HTTP_Demo_Internal, you can find a part of the code where it is checked whether the socket is open

Code: Select all

if(socket_Intern[i].open == 0)
      pos[i] = 0;
Unfortunately, we haven't nothing in our library that would help you detect whether the cable is still connected to an Ethernet port.

Best regards,
Marko Stankovic.

nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

Re: ETHERNET Library Connection Status

#7 Post by nealet » 24 May 2018 16:24

Hi Marko
Thankyou for your reply. Unfortunately the solution you suggest is not available to me for the following reasons:
I am not using the "Net_Ethernet_Internal" library,
Net_Eth.PNG
Net_Eth.PNG (5.41 KiB) Viewed 3618 times
I am using the "Ethernet" library;
ETHElib.PNG
ETHElib.PNG (6.21 KiB) Viewed 3618 times
I have used the Internal library previously for a project which had an SNMP interface which uses the TCPIP/UDP protocol. The library worked well and in fact I started using it for for my present project which uses the TCPIP/TCP protocol for a MODBUS TCP interface. Unfortunatley I found that when doing TCP, the INternal_library would give the wrong ACK sequence number when responding to a message sent to it. This surprised me since it worked so well when doing UDP!? I could see the wrong ACK response when viewing the message interaction using Wireshark. The result of an incorrect ACK sequence is that the sender expecting the ACK response thinks it did not get one and then resends the message 3 times and then finally closes the socket. Not very useful in my scenario.

Anyway a colleauge suggested that I try the "ETHERNET" library, and when the simple HTTP demo was run (which uses TCPIP/TCP) it worked well and wireshark showed that the correct ACK sequence was returned. So thats why I said in my opening request, that I am using the ETHERNET library not the INTERNAL_ETHERNET_LIBRARY.
I have tried searching for the equivalent socket_intern parameter but it does not seem to exist for this library.

So now I have the connection working quite well, but I cant tell when the sender has closed the socket. So if one could be added that would be great. Or if you could point me to the variable name, that would also be great?

While I am on the subject, I have found that if when using EITHER of these libraries, I reset the cpu with a hard reset (or using the reset() function) and then init the Ethernet link and do the ARP request etc, etc. The link works quite well. But for both libraries, I have found that if in a TFT menu, I change the IP parameters while the system is running, such as the own or remote_host IP, and then go through the whole identical Ethernet initialisation procedure as i did on cold reset or reset() function, The Ethernet link still works and initialises correctly, but works MUCH, MUCH SLOWER!!! It times out continuesly where it did not before after a reset. If you have seen this same behaviour, can you tell me what it is that happens after a cold reset that does not happen without a cold reset to make it work so much better?
Regards
Nealet

nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

Re: ETHERNET Library Connection Status

#8 Post by nealet » 30 May 2018 13:14

Hello...?

arpatel
Posts: 3
Joined: 01 Jun 2018 04:19

Re: ETHERNET Library Connection Status

#9 Post by arpatel » 29 Jun 2018 08:27

I have got the similar issue with Ethernet Library.
I want to put my logo with ethernet_demo example on browser.
But not able to do so.
Example using Net_Ethernet_Library given but not with the Ethernet Library.

Please keep in mind that I am using Ethernet Library.
Is there anyone who can help?
thanks

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: ETHERNET Library Connection Status

#10 Post by petar.suknjaja » 02 Jul 2018 09:43

Hi,
I believe we talked on help-desk about this issue.
Kind regards,
Petar

nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

Re: ETHERNET Library Connection Status

#11 Post by nealet » 02 Jul 2018 09:48

Hi Petar
Could you direct us to the link please, and do you have an answer to my first question asked as while ago on this thread, namely
"... I am looking for a way, by looking at a status flag somewhere, to tell whether the TCP Socket that i may have opened, is still in fact open, Or to see if a I have received a FIN/ACK sequence from the Client to see if he closed the socket from his side?"
Thanks and Regards
Nealet

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: ETHERNET Library Connection Status

#12 Post by petar.suknjaja » 03 Jul 2018 10:19

Hi,
Unfortunately ticket system is private -
but when we find the solution for question arpatel posted, we will share it here.
As it is basically the minor change in demo example which is bundled in compiler.

Regarding the status flag, I'll ask around.
Usually those things if they haven't incorporated in compiler as part of the library or routine, could be accessed by reading specific registry bits.
I don't know if this could be done - its basically an idea, but I'll readout the documentation and datasheet and let you know if i find something.

Kind regards,
Petar

nealet
Posts: 142
Joined: 28 May 2013 12:07
Location: South Africa

Re: ETHERNET Library Connection Status

#13 Post by nealet » 03 Jul 2018 10:24

Thank you

Post Reply

Return to “mikroC PRO for PIC32 General”