help: Guru needed please please please 
Author Message
 help: Guru needed please please please

Yes I am begging.
I remember when this group was useful.  Oh well

Here is my problem:

I have code wrote back in 90 (pre win16)
They made liberal use of pointer arithmetic.

I have structs which have unions which the code uses pointer arithemetic on.
I know this is bad.  For exactly the problem I see.

Is there a way to guarante the memory map of the struct.
I am sure I will figure it out but If anyone already knows the work around I
would aprreciate it.

If this is too incoherent to understand I can add more info including the
pointer math that gets the data into the struct.
Code Follows:
in the struct comm_packet (below) I should have:
7F 00
0C 00
00 00
00 00
00 00
66 F4
which is:
cmd:127 reason:12 card:(NULL string[6]) errno: -2202

the problem is I get:
7F 00
00 00  <-EXTRA JUNK
0C 00
00 00
00 00
00 00
66 F4

The Offending Struct:

typedef struct comm_packet
{
  Sword16 cmd;
  union
  {
      struct compak_swerr     com_swerr;
      struct compak_calib     com_calib;
      struct compak_selfprog  com_selfprg;
      struct compak_writeblk  com_writeblk;
      struct compak_stopb     com_stopb;
      struct compak_stopc     com_stopc;
      struct compak_delay     com_delay;
      struct compak_resultb   com_resultb;
      struct compak_jump      com_jump;
      struct compak_do        com_do;
      struct compak_bmode     com_bmode;
      struct compak_test      com_test;
      struct compak_selftest  com_selftst;
      struct compak_stresult  com_stresult;
      struct compak_ststop    com_ststop;
      struct compak_config   com_config;
  } info;

Quote:
}compak;

struct compak_swerr
{
   Sword16 reason;
   Sword16 errnum;

Quote:
};

struct compak_stresult
{
   Uword16  stresult;
   Ubyte    result;
   Ubyte    type;
   Uword32  from;
   Uword32  to;
   Uword16  dumint[2];
   Flt32    meas;
   Flt32    dumflt[8];

Quote:
};

struct compak_ststop
{
   Sword16 reason;
   Ubyte    result;
   Ubyte    type;
   Uword32  from;
   Uword32  to;
   Uword16  meas_type;
   Uword16  comp;
   Flt32    meas;
   Flt32    dumflt[8];
   Uword16  dumword[6];
   Flt32    t_base[8];       /* t_val in base units */
   Sword16 bits[5];
   Sword16 count[14];

Quote:
};

struct compak_config
{
   Sword16 config_num;
   Sword32 points;
   Sword16 workstation;
   Uword16 options;
   Flt32   sys_tare;
   Flt32   dmm_tare;

Quote:
};

struct compak_calib
{
   Sword16  caltype;
   Sword16  v_count;
   Sword16  vout_range;
   Sword16  i_count;
   Sword16  iout_range;
   Sword16  meas_range;
   Uword32  from;
   Uword32  to;

Quote:
};

struct compak_selftest
{
   Sword16  cont_type;
   Sword16  lkbk_type;
   Uword32  start_adr;
   Uword32  stop_adr;
   Uword16  wildcards;
   Sword16  offset;
   Uword16  selftesttype;
   Flt32    leak_res;
   Flt32    leak_volt;
   Flt32    cont_res;
   Flt32    cont_amp;

Quote:
};

struct compak_selfprog
{
   Sword16 subcmd;
   Flt32 vlim;
   Flt32 clim;
   Flt32 resis;

Quote:
};

struct compak_writeblk
{
  Sword16 cntrl;
  Sword32 offset;
//  Sbyte cardnum[6];

Quote:
};

struct compak_test
{                  
  Sword16 testgrp;
  Sword16 data;    

Quote:
};                

struct compak_stopb
{
   Sword16 reason;
   Sword16 errnum;

Quote:
};

struct compak_stopc
{
   Sword16 reason;
   Sbyte   cardnum[6];
   Sword16 errnum;

Quote:
};

struct compak_delay
{
   Flt32   delaytime;

Quote:
};

struct compak_resultb
{
   Sword16 result;
   Sbyte cardnum[6];
   union
   {
      Uword32 bcdadrs;
      Flt32   dvom;
   }xtra;

Quote:
};

struct compak_jump
{
   Uword32 offset;

Quote:
};

struct compak_do
{
   Sword16 docnt;

Quote:
};

struct compak_bmode
{
   Sword16 scancnt;
   Sword16 leakcnt;
   BOOL    soe;
Quote:
};



Fri, 30 Aug 2002 03:00:00 GMT  
 help: Guru needed please please please


Fri, 19 Jun 1992 00:00:00 GMT  
 help: Guru needed please please please
This probably has to do with structure packing.  Check out the "#pragma"
topic under MSDN, specifically under the "pack" subtopic.

Joe O'


Quote:
> Yes I am begging.
> I remember when this group was useful.  Oh well

> Here is my problem:

> I have code wrote back in 90 (pre win16)
> They made liberal use of pointer arithmetic.

> I have structs which have unions which the code uses pointer arithemetic
on.
> I know this is bad.  For exactly the problem I see.

> Is there a way to guarante the memory map of the struct.
> I am sure I will figure it out but If anyone already knows the work around
I
> would aprreciate it.



Fri, 30 Aug 2002 03:00:00 GMT  
 help: Guru needed please please please
Perfect Exactly what I needed
Thank You.



Quote:
> This probably has to do with structure packing.  Check out the "#pragma"
> topic under MSDN, specifically under the "pack" subtopic.

> Joe O'



> > Yes I am begging.
> > I remember when this group was useful.  Oh well

> > Here is my problem:

> > I have code wrote back in 90 (pre win16)
> > They made liberal use of pointer arithmetic.

> > I have structs which have unions which the code uses pointer arithemetic
> on.
> > I know this is bad.  For exactly the problem I see.

> > Is there a way to guarante the memory map of the struct.
> > I am sure I will figure it out but If anyone already knows the work
around
> I
> > would aprreciate it.



Fri, 30 Aug 2002 03:00:00 GMT  
 help: Guru needed please please please


Fri, 19 Jun 1992 00:00:00 GMT  
 help: Guru needed please please please

Quote:

>Is there a way to guarante the memory map of the struct.
>I am sure I will figure it out but If anyone already knows the work around I
>would aprreciate it.

It sounds to me like you want to pack the structure
aligned on byte boundaries. Look at the 'pack' #pragma and
see if that helps out.

 - Katy



Fri, 30 Aug 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!

2. Please help!!!!Please help!!!!Please help!!!!

3. NEED HELP WITH PRITING AN ARRAY, PLEASE PLEASE HELP

4. PLEASE PLEASE PLEASE PLEASE

5. HELP please on QUEUES!! please, please, please, please,please...

6. PLEASE HELP-I NEED LINKED LIST GURUS!

7. Complex TREEVIEW Design Issues, Need GURU Help Please

8. Complex TREEVIEW Design Issues, Need GURU Help Please

9. Complex TREEVIEW Design Issues, Need GURU Help Please

10. need help please please setting registry value

11. PLEASE PLEASE HELP HELP...question on interleaving C functions

12. RegExp guru's - help me please!

 

 
Powered by phpBB® Forum Software