I tried to put the Ptr at the end of the frame in C.
void myFunction(uint8_t * Ptr)
{
uint8_t frame[] = {0x1, 0x2, 0x3, *Ptr}
}
int _main()
{
myFunction("Hello");
}
in this solution I put only the H of "Hello" into frame[4] because of the 8 bit.
After that I tried
strcat((char*)frame, (char*) StateTxtPtr);
but it didn't work.
The solution should look like this: frame = {0x1, 0x2, 0x3, "H", "E", "L", "L", "O"}
Thanks for your help!
SOLUTION **
void myFunction(uint8_t * Ptr, uint32_t TxtSize)
{
uint8_t frame[25] = {0x1, 0x2, 0x3, *Ptr}
memcpy(&frame[3], Ptr, TxtSize);
}
int _main()
{
uint32_t TxtSize = strlen((char *)&txt[i][0]);
myFunction("Hello", TxtSize);
}
{0x1, 0x2, 0x3, *Ptr}instead of{0x1, 0x2, 0x3, Ptr}?frameis an array whose length is determined at compile time. As yourself how the compiler can do that, and meet your needs.char *, what is going to happen trying to pick it up as auint8_t *in the function? Do you pass in a pointer to a long enough space to hold all the data? (a single 64 bit integer should be enough, but what are you doing with an array?) I'm concerned about the { } constant array -- will it be updated with Ptr or *Ptr at run time?