Author Topic: Program works when reset from Arduino IDE, not from cold power-on  (Read 4439 times)

kevin

  • Newbie
  • *
  • Posts: 13
When I write a simple program to the DigiX using the Arduino IDE, then it runs fine, but when I then unplug it from my laptop and power it from a USB charger then it's not running for some reason.  Is there something different about the way the DigiX gets reset by the IDE?  The program is just reading two buttons and when they're pressed, sending a message over the wifi module.  I've removed all of the serial in/out, so it's not waiting on that.

I'm about to add an LED and start flashing it from various points in the program, but I just wondered if anyone has had this problem before and can point me in the right direction?  I suspect that it's not getting past the "wifi.ready()" check in setup(), but until I wire up an LED it's difficult to check.

Thanks!


kevin

  • Newbie
  • *
  • Posts: 13
Re: Program works when reset from Arduino IDE, not from cold power-on
« Reply #1 on: December 23, 2013, 08:34:57 am »
Indeed, some playing with the LED on pin 13 shows that it's not getting past the wifi.ready() check - in fact that call isn't returning, so I'm not even getting into the "while (wifi.ready() != 1) delay(1000);" loop.

Anyone else had this problem?

kevin

  • Newbie
  • *
  • Posts: 13
Re: Program works when reset from Arduino IDE, not from cold power-on
« Reply #2 on: December 23, 2013, 09:14:23 am »
Looking into it, I suspect that the problem is actually to do with the wifi module in TCP client mode trying to hold lots of outgoing connections open (a new connection every time it restarts) - I've seen up to 20 established on the server side.  I'm guessing that's confusing things.

kevin

  • Newbie
  • *
  • Posts: 13
Re: Program works when reset from Arduino IDE, not from cold power-on
« Reply #3 on: December 23, 2013, 09:46:33 am »
I may have two problems; I'm talking to a TCP server created by Node-RED, which seems to leave the TCP timeout at the default of 0 (ie "never time out") so there were lots of established connections.  Patching in a "setTimeout" call and handler into the Node-RED TCP code seems to make the whole thing hang together ok, although it's not ideal.

I'm not sure why this would have prevented the wifi.ready() call from working earlier, hence me possibly having 2 problems, but it generally seems to be ok now.

kevin

  • Newbie
  • *
  • Posts: 13
Re: Program works when reset from Arduino IDE, not from cold power-on
« Reply #4 on: December 23, 2013, 10:30:36 am »
I suspect it was reusing source port numbers across restarts, which is reasonable, but something somewhere wasn't handling that very well.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Program works when reset from Arduino IDE, not from cold power-on
« Reply #5 on: December 23, 2013, 05:54:23 pm »
That's very strange as we tell the WiFi module to turn of the TCP link before starting a new one - if you checkout the wiki page: http://digistump.com/wiki/digix for the WiFI there is a link to the full specs of the module that might help debugging. Perhaps we need to add some close routines before the next connection.