ARanc Posted March 6, 2008 Report Posted March 6, 2008 Hi everyone, I am using phenty's VB .Net dll to communicate with FSUIPC. What I am trying to do is to read the FS Com2 frequency, and I have already managed to do that via the code below... Dim com2bcd As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H3118) FSUIPCConnection.Process() Dim com2String As String = com2bcd.Value.ToString("X") com2String = "1" & com2String.Substring(0, 2) & "." & com2String.Substring(2, 2) me.label1.text = com2string The issue is that this code can only be executed when a flight has been loaded, in other words when the aircraft has loaded and not from the FS main menu. If I execute while FS is in the main menu I get a .Net error which I understand because a Com2 frequency is not present. My question now is if there is a way to detect that FS has loaded a flight and is not in the Main Menu anymore. This way I can add an If...End statement in my timer and check whether an FS flight has loaded and if it has then get the com2 frequency but if it has not loaded then continue the timer until it loads. I hope you understand what I am trying to do :D Thanks in advance, Alex
Pete Dowson Posted March 6, 2008 Report Posted March 6, 2008 The issue is that this code can only be executed when a flight has been loaded, in other words when the aircraft has loaded and not from the FS main menu. If I execute while FS is in the main menu I get a .Net error which I understand because a Com2 frequency is not present. I don't know why it is giving you an error. A not-present COM frequency should simply read zero, so giving you a result like "100.00". My question now is if there is a way to detect that FS has loaded a flight and is not in the Main Menu anymore. The flags at offsets 3364 and 3365 are used for this sort of thing -- only when both of these bytes are zero is FS actually fully "ready to fly". But if you are getting an error on the COM2 offset, I don't see why you won't get an error on every offset. What is the error in the first place and why is it occurring? Are you sure you aren't trying to connect before FS, and therefore FSUIPC, is even finished loading and running? If you get FSUIPC to load your program for you you will know you can connect to it as soon as your program is ready. If you are connecting via WideFS from a Client PC, use the "RunReady" method of loading your program, so that you know FS is "ready to fly" when your program is started. Regards Pete
ARanc Posted March 7, 2008 Author Report Posted March 7, 2008 Thanks Pete :D I fixed the problem, It was giving me an error because I was trying to convert the substring like if it was a frequency etc... when it was zero. I do however have another question. My question is as follows, my program is run before FS is ran. When the user wants to start the program main function, they click a "Start" button. My program then minimizes to the tray and begins a timer. The timer then scans if fs9.exe or fsx.exe are running. Once one of those are running then my program tries to open FSUIPC via the fsuipcconnection.open() command. The issue is that I am receiving the Error 12 exception which states something about FSUIPC error sending. How do I connect to FSUIPC without have to manually do so after FS has loaded. Thanks in advance, Alex
Pete Dowson Posted March 7, 2008 Report Posted March 7, 2008 My program then minimizes to the tray and begins a timer. The timer then scans if fs9.exe or fsx.exe are running. Once one of those are running then my program tries to open FSUIPC via the fsuipcconnection.open() command.The issue is that I am receiving the Error 12 exception which states something about FSUIPC error sending. How do I connect to FSUIPC without have to manually do so after FS has loaded. Just because the FS EXE process has started doesn't mean it has yet loaded FSUIPC and the latter has made itself ready to deal with your messages. It sounds as if this "error 12" (?) is the SendMessageTimeout to the FS window (class "FS98MAIN") simply timing out. Most programs using the IPC interface simply loop and retry until they get a successful connection. If you cannot deal with errors in that way then you can simply test for the FS window (class "FS98MAIN") or the FSUIPC window (class "UIPCMAIN"). The latter being present certainly means FSUIPC is up and running. The former is FS's own Window class and would be a better choice than the FS EXE process -- your program would work on a WideFS client too if you checked for FS98MAIN. Use the Windows API FindWindowEx with just the class name. 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