Hello
with serial bluetooth connection I try to transfer information to a microcontroller. Best would be to have same structure of data to work on both sides.
For ex. I have following struct programmed in C language at microcontroller side:
typedef struct
{
unsigned int ID;
unsigned char len;
union
{
unsigned char B[8];
unsigned int W[4];
} Data;
} CANMessageDef;
Inside b4a I try following structure:
How can I send this via blue to have a byte stream with only valid bytes to copy direct at receiving side into the stucture?
Data may have length from 0 to 8 bytes. All data should be byte aligned. I thought ConvertObjectToBytes will work for this, but wrong way!
Is there any method to create union like data structures?
with serial bluetooth connection I try to transfer information to a microcontroller. Best would be to have same structure of data to work on both sides.
For ex. I have following struct programmed in C language at microcontroller side:
typedef struct
{
unsigned int ID;
unsigned char len;
union
{
unsigned char B[8];
unsigned int W[4];
} Data;
} CANMessageDef;
Inside b4a I try following structure:
B4X:
Type CanMsgType (ID As Short, len, Data(8) As Byte)
Dim myTypeVar As myType
How can I send this via blue to have a byte stream with only valid bytes to copy direct at receiving side into the stucture?
Data may have length from 0 to 8 bytes. All data should be byte aligned. I thought ConvertObjectToBytes will work for this, but wrong way!
Is there any method to create union like data structures?