MySQL Forums :: Connector/Arduino :: I use MySQL connectorl and after some time it stops. PLEASE HELP


Advanced Search

Re: I use MySQL connectorl and after some time it stops. PLEASE HELP
Posted by: Daniel Wee ()
Date: February 04, 2017 04:48AM

Hi Chuck - I think I traced the problem and this might be useful for other users.

Basically, the problem comes down to two different issues:-

1. The use of delay(1000) in the connect function, and delay(100) in the wait_for_client function. While this works most of the time, there seems to be some incompatibilities with other interrupt functions with the ESP8266 system under Arduino.

I changed the delay(1000) to use:-

unsigned long sttime=millis();
while (millis()-sttime < 1000) yield();

*likewise for everywhere else delay() appears - especially in MySQL_Packet.cpp

and some other judicious placements of yield() - this completely resolved the apparently random resets and exceptions. After months of experimenting, this actually completely got rid of the problems.

2. There was still the occasional watchdog timeout which I tracked down to the wait_for_client function. This function is called by read_packet and is expected to return an integer.

The way the code is written, however, allows wait_for_client to timeout but without any indication to the read_packet that this has happened. As a result, you could potentially have a situation where the read_packet loops indefinitely while waiting for data that is not forthcoming and thus resulting in a watchdog timeout.

To fix this, I altered wait_for_packet to return a -1 in the event of a timeout, and to check for this result in read_packet so that it can abort in the event of a timeout. Basically, this looks like:-

int avail_bytes = wait_for_client();
if (avail_bytes < 0) return;

* this works after modifying wait_for_client to return a -1 if it timed out.

These two changes fixed all the problems I had been having with mysterious resets. There may be a need to check for timeouts with wait_for_data as well but I have not done that as yet. If I continue to experience problems I may do that.

Could you look at these changes to see if you could incorporate it into the official code. This way I won't have to make the changes manually when new code is released.

Options: ReplyQuote


Subject Views Written By Posted
I use MySQL connectorl and after some time it stops. PLEASE HELP 323 César Sebastián Silva Proaño 10/31/2016 03:42PM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 247 Chuck Bell 10/31/2016 05:58PM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 190 César Sebastián Silva Proaño 11/01/2016 05:57AM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 248 César Sebastián Silva Proaño 11/01/2016 07:27AM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 189 Chuck Bell 11/07/2016 08:21PM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 165 Chuck Bell 11/07/2016 08:18PM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 138 Daniel Wee 12/10/2016 10:25AM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 178 Chuck Bell 12/12/2016 12:51PM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 108 Daniel Wee 02/04/2017 04:48AM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 102 Daniel Wee 02/04/2017 05:26AM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 115 Chuck Bell 02/07/2017 09:02AM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 74 Daniel Wee 02/07/2017 11:01AM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 65 Daniel Wee 02/12/2017 05:11AM
Re: I use MySQL connectorl and after some time it stops. PLEASE HELP 13 Chuck Bell 04/20/2017 11:39AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.