Re: Reconnecting to mysql connector
Here's another update:
I ran into problems last night again. The arduino stopped suddenly when I went to look at it - perhaps it got a static zap when I discharged myself to a piece of metal connected to the common ground pin (on my breadboard). I might need a diode between the Arduino and the common ground, and then another tie between the common ground and a "good" ground (like the case of the PC).
I restarted the Arduino, and then tested unplugging the Ethernet cable. It went into a crazy loop where it kept printing "Be" over and over again (probably the start of one of my "Begin" debugging prints). I had to reset it again. I moved the network cable from my rotuer to my switch, and it ran for a a short while before hanging again (in the wait_for_client() function). I moved it back to the router, and it ran for the whole night (stopping mysteriously at about 10:00 this morning - but I won't know more until I get home tonight).
I can't test code on the Arduino today from work, but I can try to see if changes to the code and libraries will at least compile.
I found a suggestion to add the line "client.setTimeout(500);" after my "Ethernet.begin(mac....)" line, but that doesn't compile (it complains that "'client' wasn't declared in this scope"). I added the line "EthernetClient client;" between the two lines, and that compiled, but I'm wondering what will happen since mysql.h also contains the "EthernetClient client;" line.
I tried putting the "client.setTiemout(500);" into the mysql.h, right after the "EthernetClient client" line, but it doesn't want to compile there, complaining "ISO C++ forbids declaration of 'client' with no type".
Next, I tried putting it into mysql.cpp, right after "connected = client.connect(server, port);" This compiled without complaining, but I can't test if that helps anything until I get home this evening.
If this doesn't help, I don't know what else I can try.
The program cycles every 10 seconds (collecting the data, sending it over serial to two other slave units to display, and also sending to the DB). Ideally, I would like to check that it has an Ethernet connection and reconnect if it doesn't), and then that it can reach the MySQL server (and reconnect if it can't) before I try to write to the database. If either reconnect fails, I want it to just skip writing to the database, and try again on the net cycle. That way, the slave units will keep functioning, even if the logging part is broken.
The main unit doesn't get any confirmation from the slave units - the communication is one-way. That's really what I want for the database, too - but I don't that isn't easily done.
Subject
Views
Written By
Posted
14745
November 01, 2013 01:10AM
3885
November 01, 2013 10:22PM
3570
November 06, 2013 06:48AM
3065
November 06, 2013 09:35AM
3256
November 07, 2013 08:47AM
2811
November 11, 2013 02:03PM
4138
December 18, 2013 01:48PM
3094
December 18, 2013 03:48PM
3158
December 29, 2013 09:48AM
2657
December 30, 2013 03:15PM
Re: Reconnecting to mysql connector
2667
December 31, 2013 11:50AM
2866
January 06, 2014 01:59PM
2620
February 04, 2014 03:45PM
2573
February 04, 2014 04:20PM
2763
February 05, 2014 01:15PM
3560
February 05, 2014 02:36PM