In article <FKWdnZko3KaPU7TVnZ2dnUVZ_rCtnZ2d@[EMAIL PROTECTED]
>,
Robbie Hatley <see.my.signature@[EMAIL PROTECTED]
> wrote:
>I use the 1600 structs in the PC software to hold data from both firmware
>types, but for communications, the correct struct MUST be used,
>because the firmware is expecting a data packet of a certain length, with
>the data members in a certain order.
>SO, i had to create "Expand" and "Extract" functions to convert between
>the two versions of the "setup_t" structure, like so:
>
>int ExpandSetupFrom1400 (setup1400_t const *in, setup_t *out)
>{
> if (!in || !out) return 666;
>
> memset(out, 0, sizeof(*out));
>
> out->CoolStages = in->CoolStages;
> out->HeatStages = in->HeatStages;
> out->StageWidth = in->StageWidth;
> out->TimePeriods = in->TimePeriods;
> (several hundred more lines of "out->foo = in->foo;")
If you create tables of corresponding structure offsets and element
lengths, then the function bodies could be coded compactly as a loop
doing memory copies.
--
"Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us." -- Ecclesiastes


|