I want to use FIFO object to transfer array data from one thread to another but the data received wrong .
At first I have initialize the FIFO:
Code: Select all
#define FIFO_obj_available 2
union U_g_b{
GPS_b_msg GPS_b;
uint8_t data[sizeof(GPS_b_msg)];
}u_msg_send,u_msg_rec;
#define FIFO_OBJ_SIZE sizeof(u_msg_send)
static objects_fifo_t fifo_buffer;
static uint8_t data_buffer[FIFO_obj_available][FIFO_OBJ_SIZE];
static msg_t msg_buffer[FIFO_OBJ_SIZE];
initialize fifo
Code: Select all
chFifoObjectInit(&fifo_buffer, FIFO_OBJ_SIZE, FIFO_obj_available, data_buffer, msg_buffer);
IN send thread:
Code: Select all
u_msg_send.GPS_b.instance++;
chFifoSendObject(&fifo_buffer,u_msg_send.data);
IN rec thread:
Code: Select all
chFifoReceiveObjectTimeout(&fifo_buffer,(void *)u_msg_rec.data,TIME_INFINITE);
chprintf(debug_ch, "inst: %u . \n\r",u_msg_rec.GPS_b.instance);
why the data has received wrong?!.
is there any example ?
thanks for any help
asd.