Hi,
I work with unions, to send some float data over serial port.
Now I made these unions:
typedef union {
uint8_t cmd_u8[2];
unsigned int cmd_u16;
}tProtocolCmd;
typedef union {
uint8_t u8[4];
unsigned int u16[2];
float f;
}tProtocolData;
typedef struct{
uint8_t start;
tProtocolCmd command;
tProtocolData data;
uint8_t crc;
uint8_t end;
}tProtocol;
tProtocol* UART0Protocol;
As I fill these parameters:
UART0Protocol->command.cmd_u8[0] = 0x01;
UART0Protocol->command.cmd_u8[1] = 0x02;
UART0Protocol->data.u8[0] = 0x01;
UART0Protocol->data.u8[1] = 0x02;
UART0Protocol->data.u8[2] = 0x03;
UART0Protocol->data.u8[3] = 0x04;
On the UART I get the next:
6F 22 53 0F 00 00
As I put these values in a simple variables, these are works fine.
Best regards,
Sandor
