1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

B4R Question ObjectCopy - Esp32

Discussion in 'B4R Questions' started by janderkan, Jun 15, 2019.

  1. janderkan

    janderkan Active Member Licensed User

    I am using this code in Esp8266 to copy from Eeprom to a string :

    Code:
    Dim DynMqttServer As String = BC.StringFromBytes(EE.ReadBytes(ptrMqttserver+Offset,32))
        BC.ObjectCopy(DynMqttServer, MqttServer, DynMqttServer.Length + 
    1)
    but on my Esp32 it restarts continously :

    Code:
    AppStart
    Guru Meditation Error: Core  
    1 panic'ed (LoadStoreError). Exception was unhandled.
    Core 1 register dump:
    PC      : 
    0x4000c3f5  PS      : 0x00060330  A0      : 0x800d2960  A1      : 0x3ffb1ee0
    A2      : 
    0x3f401148  A3      : 0x3ffb8208  A4      : 0x00000001  A5      : 0x0000ff00
    A6      : 
    0x00ff0000  A7      : 0xff000000  A8      : 0x00000000  A9      : 0x3f401148
    A10     : 
    0x00000000  A11     : 0x3ffb8859  A12     : 0x3ffb860c  A13     : 0x00000000
    A14     : 
    0x00000000  A15     : 0xff000000  SAR     : 0x0000001c  EXCCAUSE: 0x00000003
    EXCVADDR: 
    0x3f401148  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff
    Backtrace: 
    0x4000c3f5:0x3ffb1ee0 0x400d295d:0x3ffb1f00 0x400d385e:0x3ffb1f20 0x400d3177:0x3ffb1f70 0x400d3f0a:0x3ffb1f90 0x400d6f57:0x3ffb1fb0 0x40088f1d:0x3ffb1fd0
    Rebooting...
     
  2. janderkan

    janderkan Active Member Licensed User


    SOLVED !
    It helps to check if the length of the string is not zero. :)
     
  3. janderkan

    janderkan Active Member Licensed User

    Hi again

    The error still persists.

    This code will compile, but the Esp32 restarts continuously, see error in first post.

    Code:
    #Region Project Attributes
        
    #AutoFlushLogs: True
        
    #CheckArrayBounds: True
        
    #StackBufferSize: 300
    #End Region

    Sub Process_Globals
        
    Public Serial1 As Serial
        
        
    Public BC As ByteConverter
        
        
    Public MyString As String = "00000"
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
        
        
    Dim DynString As String = "hi"
        
    If DynString.Length>0 Then BC.ObjectCopy(DynString, MyString, MyString.Length)

        
    Log(MyString)
    End Sub
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Constant strings can be optimized and stored in read-only memory.

    Change your code to:
    Code:
    Sub Process_Globals
       
    Public Serial1 As Serial
       
    Public BC As ByteConverter
       
    Public MyString(10As Byte
    End Sub

    Private Sub AppStart
       Serial1.Initialize(
    115200)
       
    Log("AppStart")
       
    Dim DynString() As Byte = "hi"
       
    If DynString.Length>0 Then BC.ObjectCopy(DynString, MyString, MyString.Length)
       
    Log(MyString)
    End Sub
    Though I would have used GlobalStore instead.
    https://www.b4x.com/android/forum/threads/73863/#content
     
    Johan Hormaza likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice