I'm receiving byte buffer array and trying to copy it to a structure:
my structure is:
typedef struct mydata_block
{
uint8_t cmd;
uint32_t param;
char str_buf[10];
uint32_t crc32;
} mydata_t;
first, the program that sends the data as following:
blockTX.cmd = 2
blockTX.str_buf = "eee789"
blockTX.param = 1001
blockTX.crc32 = 3494074521
-
02-00-00-00-E9-03-00-00-65-65-65-37-38-39-00-00-00-00-00-00-99-58-43-D0
when the data is recieved im copying the data to the structure using the memcpy code below:
memcpy((uint8_t *)&blockRX,(uint8_t *)usbd_cdc_buffer,sizeof(blockRX));
everything looks fine, but not the cmd (its 1 byte but there is padding? in structure?) how do i fix this?