harlequin-tech / WiFlyHQ

WiFly RN-XV Arduino Library
Other
110 stars 68 forks source link

::open hangs sometimes #6

Closed tacoe closed 12 years ago

tacoe commented 12 years ago

Sometimes, calls to open - like wifly.open("api.cosm.com", 80) - hang and never return. I'll try using non-blocking and openComplete, but the blocking version could perhaps use a timeout?

tacoe commented 12 years ago

BTW, great library otherwise — right level of abstraction, too

tacoe commented 12 years ago

Bummer. Nonblocking has the same problem, so no way to circumvent.

Fragment below; Sometimes, last line never gets executed, effectively stopping everything without a way to intervene.

Serial.println("Opening server call (nonblocking)"); wifly.open("api.cosm.com", 80, false); Serial.println("Entering wait loop");

harlequin-tech commented 12 years ago

Hi tacoe,

that's a strange problem. The open() command should timeout after 10 seconds. I wonder if you're getting hit by the 2.32 firmware bug where the WiFly reboots? Depending on your shield, the WiFly reboot may reboot your Arduino. If it doesn't then I would expect the open() call to still fail with a timeout after 10 seconds.

I'll see if I can reproduce the behaviour you're seeing. If you have a small sketch that demonstrates the problem that would help. Are you using software serial for the WiFly interface?

Cheers.

tacoe commented 12 years ago

Hi, thanks for getting back!

Sketch (shortened to the essence) is here: https://gist.github.com/2900840

When ran, after anywhere from 5 minutes to 6 hours, the Arduino hangs. When I hook up a terminal, it looks like consistently, the hanging is in the ::open (which I deduce by putting logging commands immediately before and after it).

Since the terminal remains, it doesn't seem to be a reboot. That would actually be fine — some testing showed that WiFly reboots reboot the Arduino in the process, so no problems there. I'll verify my firmware version.

tacoe commented 12 years ago

Hmm. If I screen into the tty, the command prompt says 2.31 which I assume is the firmware version. Is the behavior described a known 2.31 issue? This is really not a question for you as it is for Roving Networks, I realize. Having looked at the WiFlyHQ code, my gut feeling is you can close this issue anway.

BTW, how do I enable/see the debug messages in your code?

tacoe commented 12 years ago

Gr. Still happening.

Serial.print("...connecting"); if(wifly.open(server,5000)){ Serial.println("...opened");

... hangs on .open; 'opened' never happens.

WiFly's D1 led is slow blinking during hanging. Can't find what that LED is -- it could mean either "Associated, no Internet" or "IP address OK" going on the WiFLy module manual, but that's a guess.

harlequin-tech commented 12 years ago

BTW, how do I enable/see the debug messages in your code?

Change line 37 in WiFlyHQ.cpp to "#define DEBUG". You may get timeouts due to too much debugging.

harlequin-tech commented 12 years ago

Could you try printing out the amount of free memory before each open attempt? I'm wondering if there is a low memory issue.

E.g.

Serial.print(F("Free memory: ")); Serial.println(wifly.getFreeMemory(),DEC);

tacoe commented 12 years ago

Will do and report back, thanks!

harlequin-tech commented 12 years ago

Are you still seeing this problem?

harlequin-tech commented 12 years ago

Very quiet. I'm going to assume the you tracked the problem down to an out-of-memory issue. Re-open the ticked if that's not the case.

tacoe commented 12 years ago

Fair enough, thanks for bearing with me.

ghost commented 11 years ago

Hi I also have this problem. It happen in Random like 24h-48h or 3 days after consecutive usage. I have firmware 2.36

Any ideas?

harlequin-tech commented 11 years ago

Hi vrgomes, have you checked your memory usage over 24 hours?

ghost commented 11 years ago

I didn't did that but the problem occurred somehow in random days. Maibe I have to make a log file with wifi working.

harlequin-tech commented 11 years ago

It might be a memory leak or out-of-memory problem. So checking the sketches memory use would be a good step.

ghost commented 11 years ago

Hi, I mesured memory just before it hanged and it was ok: freeRam() 3526

In the code I have: Serial.println("1"); if (wifly.open(site, 80)) { Serial.print("Connected to "); //more code...... } else { Serial.println("Failed to connect"); }

And in the console showed: 1

And it hanged there on wifly.open and stopped completely the arduino loop cycle.

I watched the code: boolean WiFly::open(const char *addr, int port, boolean block)

And it has: if (!getPrompt()) { debug.println(F("Failed to get prompt")); debug.println(F("WiFly has crashed and will reboot...")); while (1); /* wait for the reboot */ return false; }

That: while (1); /* wait for the reboot */

Isn't going to hang the code there for ever?

EDIT: I did some digging and the last debug print was: send_P: getPrompt "<2.36> " match: <2.36> readTimeout - timed out match: false Failed to get prompt WiFly has crashed and will reboot...

rodri16 commented 10 years ago

I am with the same problem, I think there is a problem with while (1) boolean WiFly::open(const char *addr, int port, boolean block)

if (!getPrompt()) { debug.println(F("Failed to get prompt")); debug.println(F("WiFly has crashed and will reboot...")); while (1); /* wait for the reboot */ return false; }

quique123 commented 8 years ago

Does upgrading the firmware solve the issue?