Modifying the string literals is problematic.
Solution based on global store, storing a null terminated string:
Code:
Sub Process_Globals
Public Serial1 As Serial
Private GlobalString As String
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Dim b() As Byte = "sdhfjksd hfksdhfjksd sdjkf sdjkf hsdjkf"
CopyBytesToGlobalString(b)
Log(GlobalString)
End Sub
Private Sub CopyBytesToGlobalString (b() As Byte)
Dim b2(b.Length + 1) As Byte
For i = 0 To b.Length - 1
b2(i) = b(i)
Next
b2(i) = 0
GlobalStore.Put(0, b2)
RunNative("SetStringFromZeroTermBytes", GlobalStore.Slot0)
End Sub
#if C
void SetStringFromZeroTermBytes (B4R::Object* o) {
b4r_main::_globalstring->data = (const char*)((B4R::Array*)o->data.PointerField)->data;
}
#End if
Note that GlobalStore.Slot0 is used to actually store the data.