B4R Question ESP8266 strange results on the log when listing files on flash

max123

Well-Known Member
Licensed User
Longtime User
Hi all,

I started to use ESP8266 with SPIFFS File System B4R library following Erel tutorial
https://www.b4x.com/android/forum/threads/resp8266filesystem-spiffs.76487/#post-512263

Initially I had problems and ESP8266 crashed any time when listing files, after Erel's suggest me to increase a buffer size and it magically started to work.

I just increased the StackBufferSize to 2000 bytes.

Now I've a new problem, I count files with this code, it count 118 files and this is ok, but the log show a strange result as count of files...

See on the log a number inside a first square bracket, as you can see, very strange results. I use a local UInt variable to count all files, if I declare it (fileCount) as Global do not work at all.

This sometime works, sometime do not works....

This is the code:
B4X:
Sub ListFiles
    Dim fileCount As UInt = 0
    For Each f As File In fs.ListFiles("/")
        fileCount = fileCount + 1
        Log("[", fileCount, "]   [ ", f.Name, " ]    ", f.Size, " bytes     StackBufferUsage: ", StackBufferUsage)
        astream.Write(f.Name).Write(Array As Byte(10))
    Next
    astream.Write(Array As Byte(0xff, 0xff, 0xff))
    Log("Found ", fileCount, " files")
End Sub

And this is the log:
AppStart
Connecting to Telecom-59027407
Connected!
My IP Address: 192.168.1.4
FS Initialize result: 1
Total size: 2880 KB
Used size: 1938 KB

[1] [ /frame10.bmp ] 16438 bytes StackBufferUsage: 68
[2] [ /frame100.bmp ] 16438 bytes StackBufferUsage: 76
[3] [ /frame73.bmp ] 16438 bytes StackBufferUsage: 84
[4] [ /frame101.bmp ] 16438 bytes StackBufferUsage: 92
[5] [ /frame89.bmp ] 16438 bytes StackBufferUsage: 100
[6] [ /frame102.bmp ] 16438 bytes StackBufferUsage: 108
[7] [ /frame103.bmp ] 16438 bytes StackBufferUsage: 116
[8] [ /frame104.bmp ] 16438 bytes StackBufferUsage: 124
[9] [ /frame105.bmp ] 16438 bytes StackBufferUsage: 132
[10] [ /frame9.bmp ] 16438 bytes StackBufferUsage: 140
[11] [ /frame106.bmp ] 16438 bytes StackBufferUsage: 148
[12] [ /frame74.bmp ] 16438 bytes StackBufferUsage: 156
[13] [ /frame107.bmp ] 16438 bytes StackBufferUsage: 164
[14] [ /frame108.bmp ] 16438 bytes StackBufferUsage: 172
[15] [ /frame109.bmp ] 16438 bytes StackBufferUsage: 180
[16] [ /frame90.bmp ] 16438 bytes StackBufferUsage: 188
[17] [ /frame11.bmp ] 16438 bytes StackBufferUsage: 196
[18] [ /frame110.bmp ] 16438 bytes StackBufferUsage: 204
[19] [ /frame75.bmp ] 16438 bytes StackBufferUsage: 212
[20] [ /frame111.bmp ] 16438 bytes StackBufferUsage: 220
[21] [ /frame91.bmp ] 16438 bytes StackBufferUsage: 228
[22] [ /frame112.bmp ] 16438 bytes StackBufferUsage: 236
[23] [ /frame113.bmp ] 16438 bytes StackBufferUsage: 244
[24] [ /frame114.bmp ] 16438 bytes StackBufferUsage: 252
[25] [ /frame115.bmp ] 16438 bytes StackBufferUsage: 260
[26] [ /frame92.bmp ] 16438 bytes StackBufferUsage: 268
[27] [ /frame116.bmp ] 16438 bytes StackBufferUsage: 276
[28] [ /frame76.bmp ] 16438 bytes StackBufferUsage: 284
[29] [ /frame117.bmp ] 16438 bytes StackBufferUsage: 292
[45] [ /frame20.bmp ] 16438 bytes StackBufferUsage: 420
[46] [ /frame21.bmp ] 16438 bytes StackBufferUsage: 428
[47] [ /frame22.bmp ] 16438 bytes StackBufferUsage: 436
[48] [ /frame96.bmp ] 16438 bytes StackBufferUsage: 444
[45] [ /frame20.bmp ] 16438 bytes StackBufferUsage: 420
[46] [ /frame21.bmp ] 16438 bytes StackBufferUsage: 428
[47] [ /frame22.bmp ] 16438 bytes StackBufferUsage: 436
[48] [ /frame96.bmp ] 16438 bytes StackBufferUsage: 444
[49] [ /frame23.bmp ] 16438 bytes StackBufferUsage: 452
[50] [ /frame24.bmp ] 16438 bytes StackBufferUsage: 460
[51] [ /frame79.bmp ] 16438 bytes StackBufferUsage: 468
[52] [ /frame25.bmp ] 16438 bytes StackBufferUsage: 476
[53] [ /frame26.bmp ] 16438 bytes StackBufferUsage: 484
[54] [ /frame97.bmp ] 16438 bytes StackBufferUsage: 492
[55] [ /frame27.bmp ] 16438 bytes StackBufferUsage: 500
[56] [ /frame28.bmp ] 16438 bytes StackBufferUsage: 508
[57] [ /frame29.bmp ] 16438 bytes StackBufferUsage: 516
[58] [ /frame98.bmp ] 16438 bytes StackBufferUsage: 524
[59] [ /frame8.bmp ] 16438 bytes StackBufferUsage: 532
[68] [ /frame36.bmp ] 16438 bytes StackBufferUsage: 604
[69] [ /frame80.bmp ] 16438 bytes StackBufferUsage: 612
[70] [ /frame37.bmp ] 16438 bytes StackBufferUsage: 620
[71] [ /frame38.bmp ] 16438 bytes StackBufferUsage: 628
[72] [ /frame39.bmp ] 16438 bytes StackBufferUsage: 636
[73] [ /frame4.bmp ] 16438 bytes StackBufferUsage: 644
[74] [ /frame81.bmp ] 16438 bytes StackBufferUsage: 652
[68] [ /frame36.bmp ] 16438 bytes StackBufferUsage: 604
[69] [ /frame80.bmp ] 16438 bytes StackBufferUsage: 612
[70] [ /frame37.bmp ] 16438 bytes StackBufferUsage: 620
[71] [ /frame38.bmp ] 16438 bytes StackBufferUsage: 628
[72] [ /frame39.bmp ] 16438 bytes StackBufferUsage: 636
[73] [ /frame4.bmp ] 16438 bytes StackBufferUsage: 644
[74] [ /frame81.bmp ] 16438 bytes StackBufferUsage: 652
[83] [ /frame47.bmp ] 16438 bytes StackBufferUsage: 724
[84] [ /frame48.bmp ] 16438 bytes StackBufferUsage: 732
[85] [ /frame49.bmp ] 16438 bytes StackBufferUsage: 740
[86] [ /frame5.bmp ] 16438 bytes StackBufferUsage: 748
[87] [ /frame83.bmp ] 16438 bytes StackBufferUsage: 756
[88] [ /frame50.bmp ] 16438 bytes StackBufferUsage: 764
[89] [ /frame51.bmp ] 16438 bytes StackBufferUsage: 772
[83] [ /frame47.bmp ] 16438 bytes StackBufferUsage: 724
[84] [ /frame48.bmp ] 16438 bytes StackBufferUsage: 732
[85] [ /frame49.bmp ] 16438 bytes StackBufferUsage: 740
[86] [ /frame5.bmp ] 16438 bytes StackBufferUsage: 748
[87] [ /frame83.bmp ] 16438 bytes StackBufferUsage: 756
[88] [ /frame50.bmp ] 16438 bytes StackBufferUsage: 764
[89] [ /frame51.bmp ] 16438 bytes StackBufferUsage: 772
[99] [ /frame6.bmp ] 16438 bytes StackBufferUsage: 852
[100] [ /frame85.bmp ] 16438 bytes StackBufferUsage: 860
[101] [ /frame60.bmp ] 16438 bytes StackBufferUsage: 868
[102] [ /frame61.bmp ] 16438 bytes StackBufferUsage: 876
[103] [ /frame62.bmp ] 16438 bytes StackBufferUsage: 884
[104] [ /frame63.bmp ] 16438 bytes StackBufferUsage: 892
[99] [ /frame6.bmp ] 16438 bytes StackBufferUsage: 852
[100] [ /frame85.bmp ] 16438 bytes StackBufferUsage: 860
[101] [ /frame60.bmp ] 16438 bytes StackBufferUsage: 868
[102] [ /frame61.bmp ] 16438 bytes StackBufferUsage: 876
[103] [ /frame62.bmp ] 16438 bytes StackBufferUsage: 884
[104] [ /frame63.bmp ] 16438 bytes StackBufferUsage: 892
[114] [ /frame70.bmp ] 16438 bytes StackBufferUsage: 972
[114] [ /frame70.bmp ] 16438 bytes StackBufferUsage: 972
[115] [ /frame71.bmp ] 16438 bytes StackBufferUsage: 980
[116] [ /frame72.bmp ] 16438 bytes StackBufferUsage: 988
[117] [ /frame1.bmp ] 16438 bytes StackBufferUsage: 996
[118] [ /frame88.bmp ] 16438 bytes StackBufferUsage: 1004
Found 118 files
Closed

Any suggestion?
Many thanks. :D
 
Last edited:

max123

Well-Known Member
Licensed User
Longtime User
Now I'm sure 100%.

The code posted on post #9 (and even all other) show bad lines on B4R, then if I disconnect B4R from serial, and open Arduino serial log, all it's ok and works, my B4R IDE is pretty slow and do not respond when receive from serial... Tried same with some my B4J apps that show a serial log and worked well...

Is not a baud rate issue, with my B4J apps I can receive and show a serial log at 921600 bps
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Tried 38400 bps, but not solved :(

Many thanks Erel for your patience ;)
You are fantastic person.;)

I know that this is not an IDE, but as you can see I can receive from ESP8266 programmed with B4R the serial data without any issues @ 921600 bps from this and other apps I wrote with B4J.
https://drive.google.com/open?id=0B_2FkqqAjcsEcFNSTk10SEwzR00
 
Last edited:
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Yes, the serial connector works well, but not the IDE serial log.

My pc is not last model, but it is an Intel Dualcore 2.8Ghz with 2GB of ram, I'm working on old XP SO but with other programs I don't have strange issues.
Even new B4A and B4J IDE works a bit slow.

I've tried to disable Autocompletition, but problem is not solved, so for now I think to use serial connector or my apps I've wrote with B4J Tool.

I see that serial connector support max 256000 bps, with my NodeMCU I can work at 921600 as well, it is possible to add 512000 and 921600 to the IDE Board Selector?

Many thanks.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Many thanks.

There are plains to add more baudrates on Serial Connector?
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Yes, I use Serial Connector, but the IDE only support max 256000 bps, with it I can arrive at 921600 as my others B4J apps.
https://drive.google.com/open?id=0B_2FkqqAjcsETkxlSm1lQ0ExWWM

I've wrote a serial plotter app that plots up 64 simultaneous tracks and Yes I can see a difference of speed between 115200 or 256000 and 921600 . I think to release it on MyCreations today or next week so can try yourself.

The problem still only on the IDE but B4J apps works well @ 921600. I stressed it, to test performances, on my old dualcore it has a big overead (around 60% of CPUs) but receive a lot of data from ESP8266, 115200 bytes per second, maybe less because any byte has start and stop bits. B4J serial library is a rock.
 
Last edited:
Upvote 0
Top