Ethernet Library hangs

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
Dominic75
Posts: 87
Joined: 05 Oct 2012 23:37
Location: Quebec, Canada

Ethernet Library hangs

#1 Post by Dominic75 » 29 Oct 2021 14:55

Hi,

Hardware:
mikromedia Plus for PIC32MX7 --> https://www.mikroe.com/mikromedia-4-pic32mx7
mikromedia Plus for PIC32MX7 Shield --> https://www.mikroe.com/mikromedia-4-pic32mx7-shield

Software:
MikroC PRO for PIC32 v.4.0.0
Library: Ethernet --> https://libstock.mikroe.com/projects/vi ... et-library

After playing a couple of hours with this library, I managed to make it work. (Well work when there is a network connection). But there is a showstopper in this library and I was wondering if somebody ever figured out how to workaround it.

No ethernet cable connected issue
I have searched this forum, and there are mainly two types of answer from mikroE:
- Library was made with the assumption that there was always a connection available
- Try to send a packet and check to see if there's a reply

Library was made with the assumption that there was always a connection available
Why, I mean on what world does this ever happens? Do you think I bought a mikromedia to do "just" networking?
-If there is no connection available, the library just makes the microcontroller hang, you totally lose control of it. Only way to fix this is to reset the microcontroller. (If you search the forum, it's everywhere)
-So this renders the device unusable because there is no connection available? (It's a good thing mikroE doesn't make computers, no connection, you can't use your PC :mrgreen: )

Try to send a packet and check to see if there's a reply
That actually is a good way, but to do that I would need to be able to have control over the microcontroller. But since the library just hangs, how am I supposed to do this?

Repro steps
It is pretty easy to make it hang. Just un-connect the cable and try to init. Just run this line:

Code: Select all

Net_Ethernet_Intern_Init(myMacAddr, myIpAddr, Net_Eth_Int_AUTO_NEGOTIATION & Net_Eth_Int_DEFAULT_MAC);
I have a led that flashes every second through a timer interrupt (It's in the same interrupt as I update Net_Ethernet_Intern_UserTimerSec). If you run this command, the led will stop flashing and the microcontroller is hanged. (I also have some serial output after this command and it never gets outputted)
Why is there no time-out for this???
If there was then I could at least regain the control of my microcontroller and handle the "no connection" state. Now I can't.

So while the library is useful when you have a connection, it renders your device totally useless if you ever lose it.

Does anyone ever figured out how to handle this? Am I missing something? Or if you faced similar issue, what was your solution? (Changing hardware/library is an option if someone has a working solution)

Note: I also have mikroC AI for PIC32 but wasn't able to find any ethernet library...

Thanks
Dominic

Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Re: Ethernet Library hangs

#2 Post by Thomas.Pahl@t-online.de » 30 Oct 2021 14:09

Net_Ethernet_Intern_UserTimerSec IS A VARIABLE that has to be increased (counted up) every second?

Dominic75
Posts: 87
Joined: 05 Oct 2012 23:37
Location: Quebec, Canada

Re: Ethernet Library hangs

#3 Post by Dominic75 » 30 Oct 2021 14:12

Has stated in my post:
I have a led that flashes every second through a timer interrupt (It's in the same interrupt as I update Net_Ethernet_Intern_UserTimerSec).
So this is already done. My code does work when the connection is valid so my code should be "good". Issue is when there is no connection

Post Reply

Return to “mikroC PRO for PIC32 General”