B4R Question Globalstore not working as expected

kolbe

Active Member
Licensed User
Longtime User
I'm getting odd results with the GlobalStore code. I need to store several KB worth of data in a running program that arrives via Wifi. This is on ESP32 board.

In the code below 3 objects arrive with a total of 676 bytes of data. The first object is 333 bytes and I need to place it into an array of bytes for use elsewhere.

When I retrieve the array from the stream it is the correct size. I put it into GlobalStore but then on retreval it is only 77 bytes. Both StackBuffer and GlobalBuffer have been increased with no affect. In the GlobalStore code Value.length is correct too.

B4X:
Sub astream_NewData (Buffer() As Byte)
    Log("new data: ", Buffer.Length)
   
    Dim data() As Object = ser.ConvertBytesToArray(Buffer,ObjectsBuffer)
    Log(data.Length)
   
    Dim tmp() As Byte = data(0)
    Log(tmp.Length)
    GlobalStore.Put(0,tmp)
'   GlobalStore.Put(0,data(0))

    Dim tmp() As Byte = GlobalStore.Slot0
    Log(tmp.Length)
    Log(GlobalStore.Slot0.Length)
    Log(GlobalStore.Slot1.Length)
   
End Sub

The log for this code shows.

new data: 676
3
333
77
77
0​

Any ideas what is going wrong?
 
Last edited:
Top