Michael A Posted December 30, 2004 Report Posted December 30, 2004 Hi Pete / Everyone Else, If you consider this a stupid question, feel free to shoot me =) Ok, I program in Delphi and can successfully create a connection to FS with FSUIPC. I understand how to use FSUIPC_Read and Process. The software compiles and loads fine. However, this is my problem... when I call the process, things look wierd. Sometimes it shows a stupid number i never heard of (most likely requires * this and / that to get the correct number), or it just doesnt display anything. I have searched and browsed delphi/fsuipc related sites and even used their code snippets for testing, but i get the same results, either nothing displays in the label's caption or some stupid number. I have even seen it sometimes display data when it feels like it (even tho its just an altitude setting for example). I understand you are not fully up with Delphi Pete, but if anyone else reads this, maybe you could help too. I have read and understood all the documentation / examples. Hmm, i hope this was understandable to read. Thx, Mick.
CATIII Posted December 30, 2004 Report Posted December 30, 2004 Hi Michael, you may post some code snippets here which describe the problem you have more clearly. Ciao, CATIII
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 Im actually at work now, but I think it went something like this... procedure TForm1.Timer1Timer(Sender: TObject); var dwResult : DWord; height : DWord; //$0020 has a value of 4 ?? begin FSUIPC_Read($0020, 4, @height, dwResult); FSUIPC_Process(dwResult); Label2.Caption := ?? //Whats the best solution here end; This is the offset for altitude only that I am trying to grab for now until I master it, then I'll expand from there. Label2 I just have as default caption of 0. When I run the program, sometimes it will display a value, sometimes it will just remove the caption and display nothing, and sometimes the caption will display something after a minute of so (without editing the code). The timer is set to 1 sec intervals. As I said, i have tried snippets from other sites but they produce the same results. Even a sample that you may have done could just trigger what is wrong. Cheers Mick
CATIII Posted December 30, 2004 Report Posted December 30, 2004 Try this: procedure TForm1.Timer1Timer(Sender: TObject); var dwResult : DWord; height : DWord; //$0020 has a value of 4 ?? (no value -> length in bytes...) begin Timer1.Enabled := False; // avoids 'overlapping' of Timer events, suggest 50 to 100ms FSUIPC_Read($0020, 4, @height, dwResult); FSUIPC_Process(dwResult); Label2.Caption := IntToStr(round(height * 3.28084 / 256)) + ' ft'; Timer1.Enabled := True; end; You get the proper conversion factors from the 'FSUIPC for Programmers' document or from FSInterrogate. Ciao, CATIII PS: Why do you want ground altitude? A/C altitude is much more interesting: $0570(8)
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 $0020, $0570 doesnt really matter during testing :) Ok, i'll give that a go when i return home in a couple of hours. Thx CAT :) Also, i dont recall seeing the conversion information in the Programmers Guide, but i'll definately look again. Cheers, Mick.
CATIII Posted December 30, 2004 Report Posted December 30, 2004 As an example: in case you want the airspeed from FS the programmers guide says: 02BC 4 IAS: Indicated Air Speed, as knots * 128 Therefore you have to do a FSUIPC_Read($02BC, 4, @IAS, dwResult); and for the conversion: Label2.Caption := IntToStr(round(IAS / 128)) + ' kt'; Good luck! CATIII
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 Thx for the help first of all CAT =) Below is the code i inserted and ran. procedure TForm1.Timer1Timer(Sender: TObject); var dwResult:DWORD; height:DWord; IAS: DWord; begin Timer1.Enabled := False; // avoids 'overlapping' of Timer events, suggest 50 to 100ms FSUIPC_Read($0020, 4, @height, dwResult); FSUIPC_Read($02BC, 4, @IAS, dwResult); FSUIPC_Process(dwResult); Label5.Caption := IntToStr(round(height * 3.28084 / 256)) + ' ft'; Label2.Caption := IntToStr(round(IAS / 128)) + ' kt'; Timer1.Enabled := True; end; When run, it only shows 0ft and 0kts Cheers, Mick.
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 Something else to add, when i minimize the project, and maximise it again, a value of 9765kts will display then it'll go back to 0ft immediately. :?
Pete Dowson Posted December 30, 2004 Report Posted December 30, 2004 Label5.Caption := IntToStr(round(height * 3.28084 / 256)) + ' ft'; Label2.Caption := IntToStr(round(IAS / 128)) + ' kt'; When run, it only shows 0ft and 0kts I don't know Delphi, so I don't know how it evaluates something like height * 3.28084 / 256 but I'd use (height * 3.28084) / 256.0 in C, just to be sure. Does "round()" take a floating point number then? Again, in C IAS / 128 would give an integer, not floating point -- you'd need IAS/128.0 for that. Please try using FSInterrogate in parallel with your program, to see what it is getting -- it is very usefull as it shows the values in all sorts of formats (and, by coincidence, it is also written in Delphi). Your "0" for ground altitude may actually be correct for all I know. And use FSUIPC's IPC read logging so you can see what FSUIPC is actually supplying you. These debugging aids are there to help! Regards, Pete
CATIII Posted December 30, 2004 Report Posted December 30, 2004 Michael, something must be wrong with your application. Please run the attached example which works fine with my FS9.1. It uses your code. Best regards, CATIII FSUIPC-Example.zip
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 Thx CATIII, I checked it out and it does exactly the same. As soon as i start it the labels go to 0ft, 0ft and 0kts. This is so weird.. *scratches head I am using the latest FSUIPC and FS2004. Mick.
CATIII Posted December 30, 2004 Report Posted December 30, 2004 Now it gets interesting... Are you running the app on the FS host or another WideFS-connected computer? What happens if you let the aircraft fly (maybe from another airport). Did you restart your computer recently? CATIII
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 Oh, and so you know, i am already flying at 14,000 ft and 300IAS when testing this. Mick. PS. You never know, all this small detail may help.
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 And Im in Single Player Mode. Mick.
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 And another FSUIPC applications are working ok. Like for instance FSInterrogate Mick.
CATIII Posted December 30, 2004 Report Posted December 30, 2004 Mick, would you mind sending me your application project? Maybe I can find something... CATIII
Pete Dowson Posted December 30, 2004 Report Posted December 30, 2004 I checked it out and it does exactly the same. As soon as i start it the labels go to 0ft, 0ft and 0kts. What does the FSUIPC Log file show (close FS first, then show me). Are you using a user-registered FSUIPC? If not, your program should be getting an unaccredited error. If so, maybe there's a problem with your user key. Have you tried using FSInterrogate and FSUIPC IPC logging as I suggested? Pete
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 Log Attached.. Thx Guys.. Mick.
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 CAT, I used exactly the source you sent me. Didnt modify it in anyway what so ever. It is just about identicle to mine too. But I'll post the .pas code here... // Delphi <-> FSUIPC/WideFS Communication Version 1.004 // Copyright © 2000 by Pelle F. S. Liljendal pelle@liljendal.dk // All Rights Reserved // // MainForm.pas // // Example-program demostrating how to use FPCuser.pas (based on C-source // by Peter Dowson) // // (Modified by Chris Brett to add support for FS2002 UIPC compatibility.) // (chris@formulate.clara.net) // //----------------------------------------------------------------------------- unit MainForm; interface uses Windows, Messages, SysUtils, Classes, Controls, Forms, StdCtrls, ExtCtrls; Const ResultText : Array[0..15] of String = ('Okay', 'Attempt to Open when already Open', 'Cannot link to FSUIPC or WideClient', 'Failed to Register common message with Windows', 'Failed to create Atom for mapping filename', 'Failed to create a file mapping object', 'Failed to open a view to the file map', 'Incorrect version of FSUIPC, or not FSUIPC', 'Sim is not version requested', 'Call cannot execute, link not Open', 'Call cannot execute: no requests accumulated', 'IPC timed out all retries', 'IPC sendmessage failed all retries', 'IPC request contains bad data', 'Maybe running on WideClient, but FS not running on Server, or wrong FSUIPC', 'Read or Write request cannot be added, memory for Process is full'); SimulationText : Array[0..6] of String = ('Any', 'FS98', 'FS2K', 'CFS2', 'CFS1', 'FLY', 'FS2002'); type TFormMain = class(TForm) ButtonOk : TButton; Timer1: TTimer; StaticText1: TStaticText; StaticText2: TStaticText; StaticText3: TStaticText; Label5: TLabel; Label1: TLabel; Label2: TLabel; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure ButtonOkClick(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private declarations } public { Public declarations } end; var FormMain: TFormMain; implementation {$R *.DFM} Uses FPCuser; procedure TFormMain.FormCreate(Sender: TObject); var dwResult : DWORD; begin // Try to connect to FSUIPC (or WideFS) if FSUIPC_Open(SIM_ANY, dwResult) then begin FormMain.Caption := FormMain.Caption + ResultText[dwResult]; Timer1.Enabled := True; end else begin // Unable to "Connect" FormMain.Caption := FormMain.Caption + ResultText[dwResult]; end; end; procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction); begin FSUIPC_Close; end; procedure TFormMain.ButtonOkClick(Sender: TObject); begin Close; end; procedure TFormMain.Timer1Timer(Sender: TObject); var dwResult:DWORD; height:DWord; Altitude:Word; IAS: DWord; begin Timer1.Enabled := False; // avoids 'overlapping' of Timer events, suggest 50 to 100ms FSUIPC_Read($0020, 4, @height, dwResult); FSUIPC_Read($02BC, 4, @IAS, dwResult); FSUIPC_Read($0574, 2, @Altitude, dwResult); // Altitude in meter; * 3,28084 gives feet FSUIPC_Process(dwResult); Label5.Caption := IntToStr(round(height * 3.28084 / 256)) + ' ft'; Label2.Caption := IntToStr(round(IAS / 128)) + ' kt'; Label1.Caption := IntToStr(round(Altitude * 3.28084)) + ' ft'; Timer1.Enabled := True; end; end. Cheers, Michael.
CATIII Posted December 30, 2004 Report Posted December 30, 2004 Hi, I will leave it to Pete to interpret your log file but it seems to me as if you have to use a _registered_ version of FSUIPC/WideServer. Obviously, the unregistered version does not allow you to read the requested data. Cheers, CATIII
Pete Dowson Posted December 30, 2004 Report Posted December 30, 2004 Log Attached.. 1. You are using an out of date version of FSUIPC. Please only ever use the latest. I cannot support old versions. Current is version 3.44. 2. Did you bother to look at the log? Somehow you have entered your user name and email address, but no valid user key. You are not user registered, therefore your program cannot gain access to FSUIPC for anything other than checking the version number. Here, look: User Name="Mick"User Addr="...." FSUIPC not user registered and 10453741 Illegal read attempt: offset 0020, size 4 10453741 Illegal read attempt: offset 02BC, size 4 10453741 Illegal read attempt: offset 0574, size 2 You are repeatedly reading these things approximately every 110 mSecs, which merely fills the log with these illegal access reports. You need to register your FSUIPC with a validly purchased user Key. You also should update to version 3.44. Regards, Pete
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 Yeah, after a FS restart I finally got the "not accredited" message. I just thought if i was learning how to use it first I wouldnt need to register it for such a simple test program. Thx for your help tho CATIII, much appreciated =) Thx, Michael.
Michael A Posted December 30, 2004 Author Report Posted December 30, 2004 Where is the application? For this access right, commercial and shareware products pay a fee or subscription. All genuine freeware programs get free access keys on application. Dont say the link on that sticky note page, they all ask for payment. How does somebody know where they issue access keys that its freeware without having a finished product first? i mean, i need a key to even get a small program that only requires an altitude read out to work. And thats going to cost me? If i purchase it, and find out something is not going to work, therefore not suiting the purpose, i would have wasted money? Anyhow, my opinion. =) Mick. Also, Pete, can you remove that email address of mine you quoted from the forum thankyou. =)
Pete Dowson Posted December 30, 2004 Report Posted December 30, 2004 i mean, i need a key to even get a small program that only requires an altitude read out to work. And thats going to cost me? So far all software developers have found that the free SDK and all the support they get is well worth the price of registering FSUIPC as a User. A program does not become a "freeware" application just because you write it for nothing. The point of providing free keys to freeware applications is so that your users, those to whom you are going to supply your wares, do not have to pay for FSUIPC -- after all, they may not need anything from me at all. However, if you are insistent, and do not come back for much support nor requests for additions to FSUIPC, then I could arrange a freeware application key for you. You would be the first such developer, so disappointing, and I would not like it to become a precedent. Please read the Access Registration document in the SDK. I'll need information -- send details it lists to me at petedowson@btconnect.com. Note that it may not work in debug mode (I know VB doesn't, but I don't know with Delphi). 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