Go Down

Topic: Ethernet begin variable allocation (Read 357 times) previous topic - next topic

LuisSoares

Hi,

I´m having some problems with the ethernet component of my project.

I do data submissions to a personal server.
Sometimes when my server is down, my program restarts, because of the sistematic trys to establish a connection with my server.

Every time the server doesn´t answer, i reset the ethernet module and recall the Ethernet Begin function and after i do a Client connect.
I think it is the consistent calling to the Ethernet Begin function that might be my problem.

Does someone has an opinion?
Does anyone has any idea if this might be a memory problem related with the Ethernet Begin re calling?

Regards

UKHeliBob

Read this http://arduino.cc/forum/index.php/topic,97455.0.html
Post your code otherwise nobody can help you.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

pylon

Yes, you should not call Ethernet.begin() more than once. It allocates a DhcpClass object which will never get released. This object uses more than 50 bytes of memory which will get lost the next time you call begin() again.

Show us your code we may help you to correct that error.

LuisSoares

I haven´t post the code because it is to dense, and i was trying to close in on the error.

Do you think it would be possible to release the previous DhcpClass object before calling Ethernet Begin again?

Another idea,

in case of using fixed ip, do you think this problem would persist?

Thank you for the input

PeterH


I haven´t post the code because it is to dense, and i was trying to close in on the error.


If you think the code is too complex, create a minimal test sketch that just demonstrates the problem. This will also enable you to confirm that you understand what the problem actually is, and subsequently that you have fixed it.

I'm sure you will have figured out by now that ethernet.begin() should only be called once.
I only provide help via the forum - please do not contact me for private consultancy.

pylon

Quote
Do you think it would be possible to release the previous DhcpClass object before calling Ethernet Begin again?


No, I think, Ethernet.begin() shouldn't be called more than once.

Quote
in case of using fixed ip, do you think this problem would persist?


That might remove the main symptom but your problem of wrong code persists. If you call Ethernet.begin() again in your code, your code is broken and you should fix that!

Go Up