B4R Question Native C: How to return an array of unsigned chars?

KMatle

Expert
Licensed User
I have this C array:

B4X:
unsigned char output[100];
How do I return the array to a variable in Globals and what type must it be? I tried a byte array but that did not work.

B4X:
b4r_main.cpp:58: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]
 

Erel

Administrator
Staff member
Licensed User
B4X:
Sub Process_Globals
   Private Serial1 As Serial
   Private Output() As Byte
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   RunNative("Test", Null)
   Log(Output.Length)
   Log(Output(0))
   Log(Output(1))
End Sub

#if C
unsigned char output[100];
void Test (B4R::Object* o) {
   output[0] = 1;
   output[1] = 2;
   b4r_main::_output->data = output;
   b4r_main::_output->length = sizeof(output);
}
#End If
 
Top