Click here to Skip to main content
15,914,221 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Structure/Class member addresses Pin
Luc Pattyn5-Mar-10 4:50
sitebuilderLuc Pattyn5-Mar-10 4:50 
GeneralRe: Structure/Class member addresses Pin
CPallini5-Mar-10 5:26
mveCPallini5-Mar-10 5:26 
GeneralRe: Structure/Class member addresses Pin
Luc Pattyn5-Mar-10 5:32
sitebuilderLuc Pattyn5-Mar-10 5:32 
GeneralRe: Structure/Class member addresses Pin
CPallini5-Mar-10 5:59
mveCPallini5-Mar-10 5:59 
GeneralRe: Structure/Class member addresses Pin
Luc Pattyn5-Mar-10 6:05
sitebuilderLuc Pattyn5-Mar-10 6:05 
GeneralRe: Structure/Class member addresses Pin
CPallini5-Mar-10 6:24
mveCPallini5-Mar-10 6:24 
AnswerRe: Structure/Class member addresses Pin
Avi Berger5-Mar-10 5:11
Avi Berger5-Mar-10 5:11 
QuestionData Type Conversions Pin
Andy2025-Mar-10 2:06
Andy2025-Mar-10 2:06 
I have been trying to interface with a software program which uses a message made up of a 20 word array of unsigned shorts;

unsigned short messageData[20];

I have been trying to use data from a home GPS system which includes Lat and Long and heading.; these have been converted from strings to floats.

e.g.

float lat, long, heading;

My problem is that as I know the scaling factors and least Sig Bit (LSB) for the lat, long and heading in the messageData buffer;

e.g.
For lat and long
LSB = 8.377E-08; Twos complement - 32 bits Max/ Min -180 to +180

For Heading
LSB 0.00549306; Twos complement - 16 bits Max/ Min -180 to +180

Setting the heading:-
unsigned short heading = (unsigned short)(newHeading/0.00549306);
messageData[10] = heading;

Getting the heading:-

bool negative;
unsigned short currentField = messageData[10];
if(currentField & 0x8000) 
{
	// Set the negative flag
	negative = true;
}
else
	negative = false;
float heading = (currentField & 0x7FFF) * g_nScalings[wordPos];
if(negative)
	heading = -(180 - heading);

But this does not work as I expected; am I missing something?

As for the 32 bit latitude, I was going to this:-

Setting the Latitude:-
union
{
	int lat_long;
	unsigned short buff[2];
}convert;

unsigned short highWord, lowWord;
int newData = (int)(fEngValue/8.377E-08);

convert.lat_long = newData;
highWord = convert.buff[1];
lowWord = convert.buff[0];

I need to get and set data in the message that is of type unsigned short and use in my program as scaled floats.

Any suggestions please.
QuestionRe: Data Type Conversions Pin
CPallini5-Mar-10 3:28
mveCPallini5-Mar-10 3:28 
AnswerI'm not following the math you're doing, but maybe this will help.. Pin
Mike the Red5-Mar-10 3:33
Mike the Red5-Mar-10 3:33 
GeneralRe: I'm not following the math you're doing, but maybe this will help.. Pin
Andy2025-Mar-10 8:12
Andy2025-Mar-10 8:12 
AnswerRe: Data Type Conversions Pin
Luc Pattyn5-Mar-10 4:19
sitebuilderLuc Pattyn5-Mar-10 4:19 
GeneralRe: Data Type Conversions Pin
Andy2025-Mar-10 10:48
Andy2025-Mar-10 10:48 
AnswerRe: Data Type Conversions Pin
Luc Pattyn5-Mar-10 11:38
sitebuilderLuc Pattyn5-Mar-10 11:38 
GeneralRe: Data Type Conversions Pin
Andy2025-Mar-10 22:33
Andy2025-Mar-10 22:33 
QuestionHow to receive a file name under the link? Pin
Dima Filipiuk5-Mar-10 0:58
Dima Filipiuk5-Mar-10 0:58 
AnswerRe: How to receive a file name under the link? Pin
David Crow5-Mar-10 7:07
David Crow5-Mar-10 7:07 
QuestionOLE image drag and drop between Tree controls Pin
RakeshManohar5-Mar-10 0:51
RakeshManohar5-Mar-10 0:51 
AnswerRe: OLE image drag and drop between Tree controls Pin
Eugen Podsypalnikov5-Mar-10 1:12
Eugen Podsypalnikov5-Mar-10 1:12 
GeneralRe: OLE image drag and drop between Tree controls Pin
RakeshManohar5-Mar-10 1:18
RakeshManohar5-Mar-10 1:18 
GeneralRe: OLE image drag and drop between Tree controls Pin
Eugen Podsypalnikov5-Mar-10 1:29
Eugen Podsypalnikov5-Mar-10 1:29 
GeneralRe: OLE image drag and drop between Tree controls Pin
RakeshManohar5-Mar-10 2:17
RakeshManohar5-Mar-10 2:17 
QuestionCreateProcess failed Pin
john56325-Mar-10 0:39
john56325-Mar-10 0:39 
AnswerRe: CreateProcess failed Pin
Adam Roderick J5-Mar-10 0:50
Adam Roderick J5-Mar-10 0:50 
GeneralRe: CreateProcess failed Pin
john56325-Mar-10 1:19
john56325-Mar-10 1:19 

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.