I am wondering if there is a cleaner way to place strctured data into a buffer. Mainly since the buffer is an address on a cPCI card and just wants the data.
This just looks sloppy to me any better way of doing this?
Code:
typedef struct header{
int h;
int t ;
} HEAD;
typedef struct secondary{
int ms;
int us;
} SECOND;
void output ( unsigned int * data, int bytes)
{
HEAD newHead;
HEAD * buffer1;
SECOND newSecond;
SECOND * buffer2;
unsigned int * buffer;
int i;
newHead.h = 1;
newHead.t = 55;
newSecond.ms = 102;
newSecond.us = 9;
buffer1 = (HEAD *)(bar0 + 0x900);
buffer2 = (SECOND *)(bar0 + 0x900 + sizeof(newHead));
buffer = (unsigned int *)(bar0 + 0x900 + sizeof(newhead) + sizeof(newSecond));
*buffer1 = newHead;
*buffer2 = newSecond;
for (i = 0; i < bytes; i++)
{
*buffer++ = *data++;
}
}
This just looks sloppy to me any better way of doing this?