4.1 - NativeEthernet - Ethernet.begin hangs program

Status
Not open for further replies.

MartinJR

Member
I am wondering whether anyone can help please. Using NativeEthernet on a 4.1 results in 'Ethernet.begin()' hanging the program. Using Ethernet.Begin in DHCP or full IP mode makes no difference. I haven't got a 'shield' or live socket attached, it's just the Teensy on its own. I am also using an SD card but whether present or not has no effect.

Code:
Ethernet.begin(m_serverMacc, m_serverip, m_dnsserver, m_gateway, m_subnet);

I am getting the MAC from the Teensy using https://forum.pjrc.com/threads/57595-Serial-amp-MAC-Address-Teensy-4-0 and that seems to be functioning fine. Can anyone suggest things I need to research, or indeed, has anyone else had this problem?

It only happens when using the NativeEthernet library, not the standard Ethernet one.

Thanks.
 
Last edited:
It's normal. If you do not have a cable connected it will hang forever.

You can see it on line 293. I believe it was left that way to be consistent with the original Ethernet library but you can comment it out which is the solution I used in my project.
https://github.com/vjmuzik/NativeEthernet/blob/master/src/NativeEthernet.cpp#L293

Here is vjmuzik's explanation. I do wish there was a better solution as I do not like modifying libraries and having to worry about updates.
https://forum.pjrc.com/threads/65653-non-blocking-Ethernet-begin()-with-cable-disconnected-amp-static-IP?p=265000&viewfull=1#post265000
 
Last edited:
Thanks for that. What a gotcha!

Yeah, editing libraries is never a good idea but I have a similar issue to K7MDL - the application needs to keep running regardless of a connection. Interestingly, the oridinary ethernet library doesn't have this problem, although maybe something else is happening instead!
 
Status
Not open for further replies.
Back
Top