Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By Aussie_Barry
#61958 Hi All,

I am also having difficulty using the LOAD command.
I have top level program (/Load_Program.bas) which calls a lower level program (/uploads/toggle_LED.bas)
Both programs are shown below:

Code: Select all'****************************************************************
'*  Name    : Load_Program.bas                                  *
'*  Author  : B. Phillips                                       *
'*  Notice  : Copyright (c) 2016                                *
'*          : All Rights Reserved                               *
'*  Date    : 03-02-17                                          *
'*  Version : 1.0                                               *
'*  Notes   : Test program to try methods of loading a basic    *
'*          : program on nodeMCU using ESP Basic (V3a65)        *
'****************************************************************

memclear
button "Load Toggle", [Toggle]
wait
[Toggle]
load "/uploads/toggle_LED.bas"
wait

end


Code: Select all '****************************************************************
'*  Name    : toggle_LED.bas                                    *
'*  Author  : B. Phillips                                       *
'*  Notice  : Copyright (c) 2016                                *
'*          : All Rights Reserved                               *
'*  Date    : 27/12/2016                                        *
'*  Version : 1.0                                               *
'*  Notes   : Simple program to toggle the blue LED on GPIO16   *
'*          : of nodeMCU using ESP Basic (V3a65)                *
'****************************************************************

let led_pin = 16                     ' Assign onboard blue gpio16 to led
let led_state = 1                    ' Create a variable for remembering on/off condition of led
timer 1000, [toggle_led]             ' Set timed interrupt to periodically toggle led
wait

[toggle_led]
if led_state = 1 then 
    led_state = 0
else
    led_state = 1
end if                               ' Toggles LED state
 
io(po, led_pin, led_state)
wait
end


All goes well when I run the "Load_Program" until I hit the "Load Toggle" button. The Debug screen shows that it is loading the "/uploads/toggle_LED.bas" program but the nodeMCE module reboots and I am back to square one!
Code: Select all 0 winsock connected 192.168.4.2
Loading . . . . /uploads/toggle_LED.bas

Exception (29):
epc1=0x4000c118 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont
sp: 3fff2fb0 end: 3fff34a0 offset: 01a0

>>>stack>>>
3fff3150:  00000010 3fff31c0 3fff15b8 4020ac01 
3fff3160:  00000000 00000000 00000000 4022bac5 
3fff3170:  3fff8c9c 00000000 3fff31c0 4022b8fb 
3fff3180:  3fff246c 00000853 00000000 4022c258 
3fff3190:  00000000 3fff15b8 3fff3214 4022b92d 
3fff31a0:  3fff1c0c 3fff15b8 3fff1540 00001379 
3fff31b0:  3fff1c0c 3fff15b8 3fff1540 4020e95d 
3fff31c0:  3fff819c 0000000f 0000000c 3fff246c 
3fff31d0:  00000000 00000000 3ffe9f28 00000000 
3fff31e0:  000003e8 000e0099 3fff84dc 3fff451c 
3fff31f0:  00000000 00000000 00000000 3fff3260 
3fff3200:  00000020 3fff32d8 3fff32d8 4022b8ac 
3fff3210:  3fff82e4 3fff8c9c 0000006f 0000000c 
3fff3220:  3fff8574 0000006f 0000000c 402203ac 
3fff3230:  00000000 00000000 3fff32d8 4022ba34 
3fff3240:  00000000 3fff08c8 00000000 3fff3260 
3fff3250:  00000000 3fff08c8 00000000 40219d7e 
3fff3260:  3fff854c 0000001f 00000019 3fff81b4 
3fff3270:  0000000f 00000000 3fff81cc 0000000f 
3fff3280:  00000000 3fff81e4 0000000f 00000000 
3fff3290:  3fff83fc 0000000f 00000000 3fff8414 
3fff32a0:  0000000f 00000000 3fff842c 0000000f 
3fff32b0:  00000000 3fff8444 0000000f 00000000 
3fff32c0:  3fff845c 0000000f 00000000 3fff8474 
3fff32d0:  0000000f 00000000 3fff848c 0000001f 
3fff32e0:  00000017 00000000 00000000 00000000 
3fff32f0:  00000000 00000000 00000000 3fff246c 
3fff3300:  00000010 3fff3390 00000000 4010053d 
3fff3310:  3fff572c 3fff3390 3fff3390 4022b8ac 
3fff3320:  00000010 00000001 3fff3390 3ffeff30 
3fff3330:  00000010 3fff3390 3fff3390 4022b8ac 
3fff3340:  3ffe8e2c 00000000 3fff3390 3fff246c 
3fff3350:  3fff8184 0000000f 00000000 3fff44e4 
3fff3360:  0000000f 00000000 3fff44cc 0000000f 
3fff3370:  00000000 3fff5374 0000000f 00000000 
3fff3380:  3fff8524 0000001f 00000017 3fff49cc 
3fff3390:  0000000f 00000004 3fff33ec 4022b8fb 
3fff33a0:  00000000 000000b9 00000000 00000000 
3fff33b0:  3fffdad0 3fff1340 3fff33e0 4010068c 
3fff33c0:  00000000 3fff1340 3fff1c10 3fff2478 
3fff33d0:  3fffdad0 3fff1340 3fff1c10 4021b91b 
3fff33e0:  00000000 00000000 00000000 00000000 
3fff33f0:  00000000 00000000 3fff0858 402082c8 
3fff3400:  00000001 000e0005 00000000 4021bb7b 
3fff3410:  00000000 3fff3430 3fff5dd0 4021ff7c 
3fff3420:  00000001 00000000 3fff2480 00000000 
3fff3430:  3fffdad0 3fff2478 40229628 3fff2480 
3fff3440:  00000000 00000000 00000000 3fff2478 
3fff3450:  3fffdad0 00000000 3fff2470 4021bc0b 
3fff3460:  00000000 feefeffe feefeffe feefeffe 
3fff3470:  00000000 00000000 00000001 40229649 
3fff3480:  3fffdad0 00000000 3fff2470 40229674 
3fff3490:  feefeffe feefeffe 3fff2480 40100718 
<<<stack<<<
º¡rþŽ$þHTTP Port: 80
ESP Basic 3.0.Alpha 65
MAC: A2:20:A6:00:73:B3
1
2
3
4
5
6
7
8
9
10

11
12

Failed Wifi Connect
Creating WIFI access point
ESPA2:20:A6:00:73:B3
APname
APpass


Any clues as to what might be going wrong?
The application of the LOAD command is the stepping stone to a much larger program configuration - without it I am really screwed :(

Cheers
Barry
VK2XBP
User avatar
By Electroguard
#61963 As I recall, as well as filenames being case-sensitive they can be too long.
I don't know how long is 'too long' because I subsequently assumed the old DOS 8.3 filename limitation... which I notice yours do exceed, so it would be a simple enough potential trouble-maker to rule out.
User avatar
By Oldbod
#61989 This does work. (I took your two programs, modded the second to reload the first after a set number of flashes, classic stuff)...
I created both "menu" and "blink" programs using the same naming format as default.bas.

I'm not sure what the filename limitations are either but I remember when I first came across espbasic I couldn't get it to work to begin with. Part of the clue is that spiffs (the file system) is a very simple, low memory usage one, It has no concept of folders - everything is in the same directory, if you like. the use of slashes is just to make names more readable. The problem I had was trying to use one basic program to write another-first thing I tried - it can be done, but beware of how the interpreter creates spiffs filenames when it saves things...,

If still having issues, may be worth checking that if you uploaded a file rather than doing an "edit paste save" to create your basic program it has the right terminators
User avatar
By Aussie_Barry
#61993 Thanks for the return comments.

I stripped back both programs and renamed them "load.bas" and "toggle.bas" and made sure they were saved in the same directory. The "load" program now looks like this:

Code: Select allmemclear
button "Load Toggle", [Toggle]
wait
[Toggle]
load "/toggle.bas"
wait

end


and the toggle code looks like this:

Code: Select all let led_pin = 16
let led_state = 1
timer 1000, [toggle_led]
wait

[toggle_led]
if led_state = 1 then 
    led_state = 0
else
    led_state = 1
end if
 
io(po, led_pin, led_state)
wait
end


When I run the load program from debug I can see that it finds the toggle.bas program and tries to load it

Code: Select all Loading . . . . /toggle.bas


but then the nodeMCU module reboots:

Code: Select all Loading . . . . /toggle.bas

Exception (29):
epc1=0x4000c118 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont
sp: 3fff2fb0 end: 3fff34a0 offset: 01a0

>>>stack>>>
3fff3150:  00000010 3fff31c0 3fff15b8 4020ac01 
3fff3160:  00000000 00000000 00000000 4022bac5 
3fff3170:  3fff5dfc 00000000 3fff31c0 4022b8fb 
3fff3180:  3fff246c 000008a3 00000000 4022c258 
3fff3190:  00000000 3fff15b8 3fff3214 4022b92d 
3fff31a0:  3fff1c0c 3fff15b8 3fff1540 00001384 
3fff31b0:  3fff1c0c 3fff15b8 3fff1540 4020e95d 
3fff31c0:  3fff841c 0000000f 0000000c 3fff246c 
3fff31d0:  00000000 00000000 3ffe9f28 00000000 
3fff31e0:  000003e8 0006f72e 3fff8434 3fff5dac 
3fff31f0:  00000000 00000000 00000000 3fff3260 
3fff3200:  00000010 3fff32d8 3fff32d8 4022b8ac 
3fff3210:  3fff5374 3fff5dfc 0000001f 0000000c 
3fff3220:  3fff8474 0000001f 0000000c 40220047 
3fff3230:  00000000 00000000 3fff32d8 4022ba34 
3fff3240:  00000000 3fff08c8 00000000 3fff3260 
3fff3250:  00000000 3fff08c8 00000000 40219d7e 
3fff3260:  3fff7824 0000000f 0000000d 3fff783c 
3fff3270:  0000000f 00000000 3fff778c 0000000f 
3fff3280:  00000000 3fff77a4 0000000f 00000000 
3fff3290:  3fff77bc 0000000f 00000000 3fff77d4 
3fff32a0:  0000000f 00000000 3fff77ec 0000000f 
3fff32b0:  00000000 3fff83bc 0000000f 00000000 
3fff32c0:  3fff83d4 0000000f 00000000 3fff83ec 
3fff32d0:  0000000f 00000000 3fff8404 0000000f 
3fff32e0:  0000000b 00000000 00000000 00000000 
3fff32f0:  00000000 00000000 00000000 3fff246c 
3fff3300:  00000010 3fff3390 00000000 4010053d 
3fff3310:  3fff572c 3fff3390 3fff3390 4022b8ac 
3fff3320:  00000010 00000001 3fff3390 3ffeff30 
3fff3330:  00000010 3fff3390 3fff3390 4022b8ac 
3fff3340:  3ffe8e2c 00000000 3fff3390 3fff246c 
3fff3350:  3fff849c 0000000f 00000000 3fff44bc 
3fff3360:  0000000f 00000000 3fff6b94 0000000f 
3fff3370:  00000000 3fff6c24 0000000f 00000000 
3fff3380:  3fff6bdc 0000000f 0000000b 3fff49cc 
3fff3390:  0000000f 00000004 3fff33ec 4022b8fb 
3fff33a0:  00000000 00000724 00000000 00000000 
3fff33b0:  3fffdad0 3fff1340 3fff33e0 4010068c 
3fff33c0:  00000000 3fff1340 3fff1c10 3fff2478 
3fff33d0:  3fffdad0 3fff1340 3fff1c10 4021b91b 
3fff33e0:  00000000 00000000 00000000 00000000 
3fff33f0:  00000000 00000000 3fff0858 402082c8 
3fff3400:  00000001 0006f6ab 00000000 4021bb7b 
3fff3410:  00000000 3fff3430 3fff5e50 4021ff7c 
3fff3420:  00000001 00000000 3fff2480 00000000 
3fff3430:  3fffdad0 3fff2478 40229628 3fff2480 
3fff3440:  00000000 00000000 00000000 3fff2478 
3fff3450:  3fffdad0 00000000 3fff2470 4021bc0b 
3fff3460:  00000000 feefeffe feefeffe feefeffe 
3fff3470:  00000000 00000000 00000001 40229649 
3fff3480:  3fffdad0 00000000 3fff2470 40229674 
3fff3490:  feefeffe feefeffe 3fff2480 40100718 
<<<stack<<<
«âÀšz9òHTTP Port: 80
ESP Basic 3.0.Alpha 65
MAC: A2:20:A6:00:73:B3
1
2
3
4
5
6
7
8
9
10
11
12

Failed Wifi Connect
Creating WIFI access point
ESPA2:20:A6:00:73:B3
APname
APpass
0 winsock connected 192.168.4.2


Can anyone shed some light on "Exception (29):...", what it means and how to avoid the issue?

Oldbod, would you please post your two working files so that I can try to emulate your success?
Also, what hardware are you using? I have a nodeMCU flashed at 4M with ESP Basic 3.0.Alpha 65

Cheers
Barry
VK2XBP