- Mon Apr 11, 2016 12:05 pm
#45303
The esp reset seems to cause some other less obvious problems, presumably from memory corruption of some sort.
Looking at the enclosed code, it basically just prints out a test IP address then waits for an incoming udp msg to handle.
A few errors later though, and the same code bombs out straight away to done... without getting far enough to print the ip address - it just says done... without showing any errors.
The esp can remain connected, and acknowledges saves ok, but either the saved script is not being saved correctly, or the 'system' itself is corrupted, because the newly saved script still bombs before getting to the print instruction.
If the script is copied and pasted to file, the esp reformatted and reflashed, then the script pasted back into the edit window and saved, it runs as it should and prints out the ip address.
So the problem is not in the script, it's in the bowels of the wee beastie.
The real 'sticky' problem is that once there's been any errors, any subsequent edits
may not even be recognised by the beastie, so there's no way of telling if any edits might fix things, cos the wee beastie may just keep following its own error-corrupted path from then on.
From a laymans viewpoint, it seems like the error-handling routines may be bleeding somewhere they shouldn't, perhaps somewhere 'systemy' rather than the user script or variables areas.
Another clue I've just noticed is that since erroring without resetting a while ago, when I now do a save, the count clocks up in the edit page lower window, and the saved ok window pops up after, but there is no esp blue led activity during any of this, suggesting that the actual 'save' code on the beastie that receives the saved script is not actually doing anything because maybe it too is corrupted. That could explain why saving and edited script after an error doesn't make any difference.
Code: Select allmemclear
'let localname = "default" ' Default node name must be changed to something unique
let localname = "MP3" ' Unique node name (currently not case sensitive) eg: "MP3 blink"
let globalname = "ALL" ' Allows addressing different system clusters of nodes separately if wished, eg: "All blink"
let groupname = "Group" ' Allows addressing different groups of nodes if required. eg: "PIR blink"
' let localIP = ip() ' Doesnt work in AP mode, so using the follwing manually assigned test alternative
let localIP = "192.168.4.123"
print "Local IP=" & localIP
let ledpin = 1 ' Onboard blue GPIO01 led
po ledpin 1 ' Ensure led is off
udpbegin 5001
udpbranch [udpmain]
'print "Need to try to do a network time sync if possible"
wait
[udpmain]
msg = udpread()
udpreply "MAIN UDP msg received: " & msg ' For test purposes only
if left(upper(msg), len(localname)) == upper(localname) then goto [local_commands] ' handle localname commands
if instr(upper(msg), upper(localname)) <> 0 then goto [partial_name_commands] ' handle partial localname commands
if (len(groupname) <> 0) and left(upper(msg), len(groupname)) == upper(groupname) then goto [group_commands]
if (len(globalname) <> 0) and left(upper(msg), len(globalname)) == upper(globalname) then goto [global_commands]
udpreply "Main dropped through Error. " & localname & " ERROR: unrecognised name in msg: " & msg
wait