Click here to Skip to main content
15,918,267 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Writing binary data to a floppy Pin
Nish Nishant16-Sep-03 3:50
sitebuilderNish Nishant16-Sep-03 3:50 
GeneralRe: Writing binary data to a floppy Pin
David Crow16-Sep-03 4:17
David Crow16-Sep-03 4:17 
Generalimpersonation Pin
Arik Poznanski16-Sep-03 3:35
Arik Poznanski16-Sep-03 3:35 
GeneralRe: impersonation Pin
Graham Bradshaw16-Sep-03 4:33
Graham Bradshaw16-Sep-03 4:33 
GeneralRe: impersonation Pin
Steve S16-Sep-03 4:36
Steve S16-Sep-03 4:36 
GeneralPicture Control + Jpeg Pin
KKR16-Sep-03 3:27
KKR16-Sep-03 3:27 
GeneralRe: Picture Control + Jpeg Pin
David Crow16-Sep-03 6:52
David Crow16-Sep-03 6:52 
GeneralStructure Problem Pin
TheFox16-Sep-03 2:52
TheFox16-Sep-03 2:52 
I am writing a piece of code to read in data a piece of hardware at a byte at a time.
I have a structure which is made up as follows:

typedef struct  {<br />
       unsigned short int  U16_DemandedDeflection; <br />
       unsigned short int  U16_DemandedToolface;<br />
       unsigned short int  U16_Beta; <br />
       char U8_Toolface_K; <br />
       unsigned short int  U16_PumpBackThreshold;<br />
       unsigned short int  U16_RpmAveragingFactor;<br />
       unsigned short int  U16_WalkAroundAngle;<br />
       char U8_WalkAroundDwellTime;<br />
       unsigned short int  U16_DemandedMagneticToolface<br />
       unsigned short int  U16_MagneticBeta;<br />
       char U8_ToolfaceControlMode;     // (Default Value = 0)<br />
       unsigned short int  U16_NeutralThreshold;<br />
       char U8_Spare[3];<br />
        }SCB_ControlSystem;


I have set up a pointer to point to the start of the structure

	unsigned char * pSCB_Byte_Pointer;<br />
<br />
	pSCB_Byte_Pointer = (unsigned char *)&SCB_ControlSystem;


The visual C++ program does the following:

Repeat

Read in the char
Put the char into the memory pointed to by pSCB_Byte_Pointer
If it is a two byte number reverse the contents of memory

Until

The read in and the poke part of the program works fine, but when I look at the structure the value for U16_PumpBackThreshold is incorrect. (
After single stepping and looking at the Microsoft website I have found that short int’s are setup on the even boundary.

I want to force the compiler to be able to put short int’s on an odd or even boundary.
Or
Come up with an efficient way of writing the code (The structure of the data has not been finalised yet)



The Fox
GeneralRe: Structure Problem Pin
Graham Bradshaw16-Sep-03 3:09
Graham Bradshaw16-Sep-03 3:09 
GeneralArray of Structures Pin
cberam16-Sep-03 2:32
cberam16-Sep-03 2:32 
GeneralRe: Array of Structures Pin
Jagadeesh VN16-Sep-03 2:47
Jagadeesh VN16-Sep-03 2:47 
GeneralTLB Error - Pin
fadee16-Sep-03 2:30
fadee16-Sep-03 2:30 
GeneralRe: TLB Error - Pin
Jagadeesh VN16-Sep-03 2:52
Jagadeesh VN16-Sep-03 2:52 
GeneralTermiating an MFC app from a separate thread Pin
BigBen00716-Sep-03 2:24
BigBen00716-Sep-03 2:24 
GeneralRe: Termiating an MFC app from a separate thread Pin
Jagadeesh VN16-Sep-03 2:39
Jagadeesh VN16-Sep-03 2:39 
GeneralRe: Termiating an MFC app from a separate thread Pin
Jagadeesh VN16-Sep-03 2:43
Jagadeesh VN16-Sep-03 2:43 
GeneralRe: Termiating an MFC app from a separate thread Pin
BigBen00716-Sep-03 4:04
BigBen00716-Sep-03 4:04 
GeneralRe: Termiating an MFC app from a separate thread Pin
Jagadeesh VN16-Sep-03 7:15
Jagadeesh VN16-Sep-03 7:15 
GeneralScreensaver with Mpeg problem Pin
Mortis16-Sep-03 2:08
Mortis16-Sep-03 2:08 
GeneralCMemDC help Pin
Zizilamoroso16-Sep-03 1:28
Zizilamoroso16-Sep-03 1:28 
GeneralRe: CMemDC help Pin
dan o16-Sep-03 3:38
dan o16-Sep-03 3:38 
GeneralRe: CMemDC help Pin
Zizilamoroso16-Sep-03 6:55
Zizilamoroso16-Sep-03 6:55 
GeneralRe: CMemDC help Pin
Jagadeesh VN16-Sep-03 7:29
Jagadeesh VN16-Sep-03 7:29 
GeneralRe: CMemDC help Pin
Zizilamoroso16-Sep-03 11:18
Zizilamoroso16-Sep-03 11:18 
GeneralRe: CMemDC help Pin
KaЯl17-Sep-03 0:15
KaЯl17-Sep-03 0:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.