calderoninc Posted June 30, 2005 Report Posted June 30, 2005 Hello, I am just begining in this and I have not find enough information to start. What I need is information about how to connect external programs with the FS trought FSUIPC, how to read/write values, and I need to understand what an offset is! If anyone could help me with some information, I0ll apreciate it. Thanks. Daniel Calderon Medellin - Colombia
Pete Dowson Posted June 30, 2005 Report Posted June 30, 2005 What I need is information about how to connect external programs with the FS trought FSUIPC, how to read/write values, and I need to understand what an offset is! Everything you need is in the FSUIPC SDK, from http://www.schiratti.com/dowson. An "offset" is simply a reference to a value. It is actually a hexadecimal number, and used to be the "offset" in FS's global memory to where the value was kept. However, that was back in FS95 and FS98 days. These days just think of the "offset" as being the identification of a value -- there are tables in the SDK defining them. Regards, Pete
calderoninc Posted July 2, 2005 Author Report Posted July 2, 2005 Thanks Pete, Now I am started. but I have a problem with the reading of the variables. for example, the offset 0x0BE8 that refers to the Gear control, is suposed to be 4 bytes length ( 0=Up, 16383=Down, according to the table), so in the calling to the function FSUIPC_Read, what kind of variable Do I have to assign to get that 4 bytes, and how can I convert those 4 bytes to an integer number. Thanks Again.
Pete Dowson Posted July 2, 2005 Report Posted July 2, 2005 the offset 0x0BE8 that refers to the Gear control, is suposed to be 4 bytes length ( 0=Up, 16383=Down, according to the table), so in the calling to the function FSUIPC_Read, what kind of variable Do I have to assign to get that 4 bytes, and how can I convert those 4 bytes to an integer number. One byte is 8 bits. 4 bytes is 32 bits, the size of an ordinary integer in Intel 32-bit processors. Read it into one of those in whatever language you are using. There's no conversion necessary -- read it into a 32-bit numeric variable and use it. Please check out FSInterrogate where you can see all this happening for real. Pete
calderoninc Posted July 3, 2005 Author Report Posted July 3, 2005 Sorry, but that is exactly the problem I have. I'm using Borland C++ Builder, and following the example in the SDK, I try to get that variable like this: int inGear; ... ... .........FSUIPC_Read(0xBEC, 4, inGear, &dwResult) But when compiling, there is a problem because it says that it cannot convert int to void*, but if I declare inGear as a char array it works! ¿? So i get 4 independent bytes each one as an element of the char array. Where is the problem?
Pete Dowson Posted July 3, 2005 Report Posted July 3, 2005 .........FSUIPC_Read(0xBEC, 4, inGear, &dwResult) But when compiling, there is a problem because it says that it cannot convert int to void*, but if I declare inGear as a char array it works! ¿? So i get 4 independent bytes each one as an element of the char array. Where is the problem? This is a basic programming misunderstanding. C/C++is not an easy language for a beginner! The reference inGear is NOT a pointer to anything, but represents the value in "inGear". This would be nonsense as a pointer, and the Compiler is doing you a favour by preventing a crash if it let you get away with it! The reason it doesn't fail with an array is that, in C/C++, the name of an array is actually representing the address of its first element -- in other words it is already a pointer. To convert the name of a variable into a pointer to it, in C/C++, you must use the "&" prefix, thus: &inGear This makes it a pointer to an integer. This should work, but you can also then cast it into a pointer to a BYTE: (BYTE *) &inGear Please check some books out of elementary C/C++ to learn more about pointers. It is really important, not only for FSUIPC interfaces but for Windows programming in general. Regards, Pete
calderoninc Posted July 3, 2005 Author Report Posted July 3, 2005 Thanks and Thanks again Peter, now it worked, I learned C in the university but I wasn't too smart to manage pointers. It worked perfect. Daniel Calderon. Medellin Colombia
calderoninc Posted July 5, 2005 Author Report Posted July 5, 2005 Hello Peter, Now I can get in an int variable, some variables from FS, but I have a little problem because whe I read, for example the Throttle lever, which takes 2 bytes I get it in an int variable with a timer event, then I put it in a Label with the IntToStr() function. For a prop engine, the range for that variable is suposed to be 0-16384, but I read some kind of random values; when full throttle, sometimes appear 16384 but sometimes I see 19021824 and I do not anything, where I am wrong? Why doesn't the variable stay steady ? what does that number mean? (19021824) Thanks, Daniel
Pete Dowson Posted July 5, 2005 Report Posted July 5, 2005 ... for example the Throttle lever, which takes 2 bytes I get it in an int variable with a timer event, then I put it in a Label with the IntToStr() function. I've no idea what that "IntToStr" function is (it isn't part of any library I use). However, if you read 2 bytes into a 4 byte integer, you must first take care to zero it -- otherwise any old rubbish will still be left in the two high bytes. A 2-byte value is a "short" or "unsigned short" (also a "WORD") in C/C++. You could declare it as such. But equally you can read it into a 4 byte value like an int provided: (a) you preset the value to zero, to make sure no rubbish is left in the two bytes at the top end which will NOT be read into! (b) you aren't reading a signed value -- if you are then the top two bytes would need to be set to all ones (0xffff), to propagate the sign. All in all you would be much much safer reading values into the correct variable types. If you read a 2-byte signed value into a "short", then it will be correct, and if you needed it as a 4-byte int you could copy it safely, i.e int x; short y; x = y; works fine, and propagates the sign for you. Please try to learn a little more about C/C++ and especially its number representations. You seem to be asking basic programming questions, things any programmer certainly needs to understand in any case. I'd prefer it if, here, you'd ask questions actually about FSUIPC than about basic elementary programming, as I'm not a good teacher at that level at all. whe I read, for example the Throttle lever, which takes 2 bytes I get it in an int variable with a timer event, then I put it in a Label with the IntToStr() function. For a prop engine, the range for that variable is suposed to be 0-16384 The throttle value can be negative as well, for reverse thrust, theoretically even in a prop. You should assume that the value is signed, not unsigned. Regards, Pete
calderoninc Posted July 5, 2005 Author Report Posted July 5, 2005 I'd prefer it if, here, you'd ask questions actually about FSUIPC than about basic elementary programming Thankyou for your help and I am sorry to bother you. Daniel Calderon.
Pete Dowson Posted July 5, 2005 Report Posted July 5, 2005 Thankyou for your help and I am sorry to bother you. It's not so much the bother, that's not a problem, it is just that I am the worst possible person to try to teach basics. I really don't have enough patience and I reach a point where I can't understand why the other person doesn't understand. From then it just gets frustrating for both parties and everything goes too negative. Just ask my children, they'll remember! :wink: I'd just rather it didn't go that far, see? This thread looked like it was turning into an elementary programming class, and that would end in tears or a row where I'm involved. I know this from experience. Sorry. Regards Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now