Jump to content
The simFlight Network Forums
tcagri

hex value to string

Recommended Posts

hi,

i want to learn how can i read DME1 value given by FSUIPC offset 0C29. I can read it as a hex value or as a longint correctly but it doesnt make any sense.how can i convert this value to correct DME1 value.

thanks.

Share this post


Link to post
Share on other sites
i want to learn how can i read DME1 value given by FSUIPC offset 0C29. I can read it as a hex value or as a longint correctly but it doesnt make any sense.how can i convert this value to correct DME1 value.

It's a printable string already. It does actually say this in the SDK. Just read the field as 5 characters and print them. the last character may NOT be a zero, so add that as a 6th character first.

Pete

Share this post


Link to post
Share on other sites

ok i got it but now i have a problem reading NAV1 frequency at 0x0350 because it is 16bit not 32bit.

normally i read DME1 string by char array but it doesnt work for it.

what can i do?

Share this post


Link to post
Share on other sites
ok i got it but now i have a problem reading NAV1 frequency at 0x0350 because it is 16bit not 32bit.

Are you using a language which doesn't support 16 bit ("short") variables?

If so just read it into whatever is big enough and ignore the rest.

normally i read DME1 string by char array but it doesnt work for it.

what can i do?

Sorry, I have no idea. What does "string by char array" mean?

If you say what language you are using perhaps some other programmers using the same language can help. If it is Visual Basic you are using, I am starting to think that it must be just about the worst language in the world, because 99% of the queries on "how to program" come from VB users. Or maybe it is just the books about it are so bad? It is very depressing.

Good luck, I do hope someone can help you.

Pete

Share this post


Link to post
Share on other sites
i am using VC++ and when reading 32bit, i used %c to read and %x to read 16bit values.

That confuses me. Aren't %c and %x just markers for a single character and a hex integer in Printf and Scanf library routines, and their derivatives?

In C, at least, you can read the 5 character DME string at 0C29 by:

char chDME1[6];

DWORD dwResult;

FSUIPC_Read(0x0C29, 5, chDME1, &dwResult);

chDME1[5] = 0;

then you can print it directly from chDME1.

For a frequency, or any unsigned 16 bit value you'd use (for example, NAV1):

unsigned short sFreq;

FSUIPC_Read(0x0350, 2, (BYTE *) &sFreq, &dwResult);

Regards,

Pete

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.