Jump to content
The simFlight Network Forums

How writing NAV Frequency 109.50 to FSUIPC ?


Recommended Posts

Example: OFFSET 0350 - NAV1 Frequency

FSUIPC stating: Frequency show as BCD (Binary Coded Decimal), however the prefixed "1" is removed

We Input and convert with Visual Basic the frequency 110.50

We declare:

Dim nav1bcd As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H350)

Text-Field Input = 1050

in txtNav1Input.Text is the Value 1050

VB code =

nav1bcd.Value = Short.Parse(Me.txtNav1Input.Text, Globalization.NumberStyles.AllowHexSpecifier)

Result: 110.50 = OK FSUIPC Freq is 110.50 - Cockpit-Radio Freq = 110.50

The QUESTION IS how we convert the frequency: 109.50 ???

The Input 0950 is not accepted (0) in front

Anyone has the solution ?

Thanks in advance for the right formula

Raimund

.

Link to comment
Share on other sites

Example: OFFSET 0350 - NAV1 Frequency

FSUIPC stating: Frequency show as BCD (Binary Coded Decimal), however the prefixed "1" is removed

We Input and convert with Visual Basic the frequency 110.50

The QUESTION IS how we convert the frequency: 109.50 ???

The Input 0950 is not accepted (0) in front

I've no idea what is wrong with your Visual Basic (I don't know it -- hopefully someone else will jump in), but the BCD hexadecimal values 0x1050 and 0x0950 most certainly are both okay and result in 110.50 and 109.50, respectively.

Perhaps some references in the VB documents or books will explain how to manipulate binary and hexadecimal values? VB has always seemed to me to be one of the most awkward languages for any sort of real computer work.

Regards

Pete

Link to comment
Share on other sites

The Input 0950 is not accepted (0) in front

Do you mean VB isn't converting this value? You get an exception? Or do you mean that FSUIPC isn't responding to this value?

There shouldn't be any problem on the VB side of things. I've just run this code and it's fine:

        Dim t As Short
        t = Short.Parse("0950", System.Globalization.NumberStyles.AllowHexSpecifier)
        MessageBox.Show(t.ToString())

I think we're going to need more details of the actual problem you're having in order to help. If you're getting a VB exception you really need to paste the exception text here. The exception box has a link to copy the details to the clipboard. Use that and paste it here.

Paul

Link to comment
Share on other sites

Do you mean VB isn't converting this value? You get an exception? Or do you mean that FSUIPC isn't responding to this value?

There shouldn't be any problem on the VB side of things. I've just run this code and it's fine:

        Dim t As Short
        t = Short.Parse("0950", System.Globalization.NumberStyles.AllowHexSpecifier)
        MessageBox.Show(t.ToString())

I think we're going to need more details of the actual problem you're having in order to help. If you're getting a VB exception you really need to paste the exception text here. The exception box has a link to copy the details to the clipboard. Use that and paste it here.

Paul

Thanks for both your answers.

Here the READ Procedure

Dim nav2bcdString As String = nav2bcd.Value.ToString("X")

nav2bcdString = "1" & nav2bcdString.Substring(0, 2) & "." & nav2bcdString.Substring(2, 2)

Me.txtNav2Activ.Text = nav2bcdString

Here the WRITE Procedure

Private Sub Nav2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nav2.Click

Dim txtInputVal As Short = Val(Me.txtNav1Input.Text)

' MAKING A TEST - Add "0" in Front as TextField value returning "950" not "0950"

If txtInputVal < 1000 Then

Me.txtNav1Input.Text = ("0" + txtInputVal.ToString())

End If

If Me.txtNav1Input.Text > "" Then

Try

FSUIPCConnection.Process()

nav2bcd.Value = Short.Parse(txtNav1Input.Text, Globalization.NumberStyles.AllowHexSpecifier)

Catch ex As Exception

MessageBox.Show(ex.Message, NavError, MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try

End If

Me.txtNav1Input.Text = "" 'clear Input Field

End Sub

1) Meanwhile

This change is working ' MAKING A TEST - Add "0" in Front as TextField value returning "950" not "0950"

In fact when using the Button the new Value 109.50 is shown on the Cockpit-Radio

BUT

2) The READ-PROCEDURE cannot return a VALID string into the separate Txt-Field 'Me.txtNav2Activ.Text' that is showing the Value

when Reading (f.e. 110.50).

This is happening only for this king of values.

NOTA: the inputfield is different from the txtNAV-Fields that are only showing the values.

In Sintesi:

[ Input Field ]

[ Sub Nav2_Click Button] >>InputValue>> in [ Nav2 TextField ] (readonly)

[ FSUIPC Read Proc ] >>Return Value>> in [ Nav2 TextField ]

(here is the error)

Input Field = 1050 - Result in Nav2 TextField = 110.50 when reading offset

Input Field = 0950 - Result in Nav2 TextField = "" when reading offset - BUT Freq 109.50 can be copied to the Radio Freq

Many thanks for your assistance

Raimund

.

Link to comment
Share on other sites

Hi Raimund,

I'm still not too clear what the problem is, but looking at the code I can see two potential problem areas:

Here the READ Procedure

     Dim nav2bcdString As String = nav2bcd.Value.ToString("X")
     nav2bcdString = "1" &amp; nav2bcdString.Substring(0, 2) &amp; "." &amp; nav2bcdString.Substring(2, 2)

This second line could throw an exception with 109.50 because nav2bcdString will be "950". Then nav2bcdString.Substring(2, 2) will throw an exception because there is no character 4.

To avoid this use the format code "X4" to make sure there are always 4 characters returned (it will pad leading 0s).

     Dim nav2bcdString As String = nav2bcd.Value.ToString("X4")

In this section...

        If Me.txtNav1Input.Text &gt; "" Then
            Try
                FSUIPCConnection.Process()
                nav2bcd.Value = Short.Parse(txtNav1Input.Text, Globalization.NumberStyles.AllowHexSpecifier)
            Catch ex As Exception
                MessageBox.Show(ex.Message, NavError, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End If

You are calling the Process() BEFORE you've set the value. You should really set the value first, then call process. Or, if you are using a timer cycle that calls Process() regularly, you can even remove this process() call from here.

Should be:

        If Me.txtNav1Input.Text &gt; "" Then
            Try 
                nav2bcd.Value = Short.Parse(txtNav1Input.Text, Globalization.NumberStyles.AllowHexSpecifier)
                FSUIPCConnection.Process()
            Catch ex As Exception
                MessageBox.Show(ex.Message, NavError, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End If

I hope this helps.

If not, make a simple version of your project with just the relevant fields, buttons and code. Just enough to produce the error and post the complete code here. It'll be easier for me to see the problem than with sections of code taken out of context.

Paul

Link to comment
Share on other sites

Hi Raimund,

I'm still not too clear what the problem is, but looking at the code I can see two potential problem areas:

This second line could throw an exception with 109.50 because nav2bcdString will be "950". Then nav2bcdString.Substring(2, 2) will throw an exception because there is no character 4.

To avoid this use the format code "X4" to make sure there are always 4 characters returned (it will pad leading 0s).

     Dim nav2bcdString As String = nav2bcd.Value.ToString("X4")

In this section...

You are calling the Process() BEFORE you've set the value. You should really set the value first, then call process. Or, if you are using a timer cycle that calls Process() regularly, you can even remove this process() call from here.

Should be:

        If Me.txtNav1Input.Text &gt; "" Then
            Try 
                nav2bcd.Value = Short.Parse(txtNav1Input.Text, Globalization.NumberStyles.AllowHexSpecifier)
                FSUIPCConnection.Process()
            Catch ex As Exception
                MessageBox.Show(ex.Message, NavError, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End If

I hope this helps.

If not, make a simple version of your project with just the relevant fields, buttons and code. Just enough to produce the error and post the complete code here. It'll be easier for me to see the problem than with sections of code taken out of context.

Paul

THAT's IT !

Many thanks for your kind help.

Regards

Raimund - Padova/Italy

.

The button are reading the InputValue and change the RadioFrequency accordingly. Except the Nav1.

When the Input-Field is Empty and the Button pressed then that frequency is replacing the Nav1-Frequency.

This in Order to Hold Freq for a VOR flying etc....

post-16277-067913200 1289325541_thumb.jp

Link to comment
Share on other sites

  • 5 years later...

Well, not sure what the above means, including ( NAV1 frequency, 4 digits in BCD format. A frequency of 113.45 is represented by 0×1345. The leading 1 is assumed. (See also offset 0388) from Project Magenta's FSUIPC offsets. I am using Excel with VBA and FSUIPC and to be able to Write to FSUIPC, this is what I did to make it work: Given a number (nav radio frequency, say 112.10.), 1) Cell (AU1) = 112.10 needs to become: 1210. I did it this way: Cell(AU2)=MID(AU1,2,4)*100. 2) Caveat: 1210 is the hex value. So perhaps this is the BCD format mention in Project Magenta's FSUIPC offsets. So then: Cell(AU3)=HEX2DEC(AU2). This result is: 4624 in decimal value, that will be sent to FSUIPC. 3) In my VBA, in part:

Dim dwresult as Long  ' this is actually done above in my code. 

'------ NAV 1 -----------

Dim NAV1Send As Integer
NAV1Send = [au3]
If FSUIPC_Write(&H350, 2, VarPtr(NAV1Send), dwresult) Then
If FSUIPC_Process(dwresult) Then
End If
End If

And Wha La, I can see the Nav 1 frequency change to the 112.10 that I desired.

My only question is: Does anyone know if a person can send indicated or true airspeed or ground speed through FSUIPC? Currently I had to set a speed and then determine the next latitude and longitude position based on that speed and desired heading. Long story as to why....

 

 

Link to comment
Share on other sites

According to docs:

FSUIPC3:
 

You can write to any of the speed offsets:

02B4 - Ground Speed
02B8 - True Airspeed 
02BC - Indicated Airspeed 

FSUIPC4 Only:

You can use the new 0558 offset to set the speed.

The docs say that 02B8 and 02BC might also be writeable in FSUIPC4 but this is not tested. 02B4 is readonly in FSUIPC4.

 

Paul

Link to comment
Share on other sites

When you use 0558 on its own. FSUIPC has to send the complete set of INITIAL POSITION values (0558-0570). This effectively pauses the sim whilst re-positioning the aircraft. It is a single SimConnect command. There's no way I know of altering the speed dynamically without changing thrust.

Pete

 

Link to comment
Share on other sites

Okay, you got me confused. Looking at: http://www.projectmagenta.com/all-fsuipc-offsets/ , I cannot find offset 0558. But in any case, as I mentioned above, a direct write to the airspeed and groundspeed did not work. However, adjusting thrust is a new thought I hadn't tried - so I will - thank you. I must also mention, I am using FS2004 (FS9). I know, I know...  Also mentioned above, using Excel, I am able to move the aircraft using a pre-defined groundspeed and heading, and predicting what the next latitude and longitude would be, and writing those to FSUIPC. I'm also doing that with altitude using a pre-defined vertical speed. I'm doing this because, 1) I was curious if I could. I use Excel and its VBA like many use WideFS (sorry Mr. Dowson but one must save money when one can, no matter the amount). I use Excel for many things, my FMC, abnormal procedures, like a stuck flap, runway vibration, etc. 2) The long story mentioned above: I recently joined a multi-player session and somehow (through FSInn), someone was able to cut my engines in a B737800. I could re-start them but then the engines would be cut again. I had to fly in this manner all the way to my destination - slow and frustrating. I have flown this aircraft for many years and never had it lose engines on its own - unless set to a random failure mode or using Excel. So now I use Excel and whomever on FSInn, cannot effect my aircraft's position anymore. From takeoff to descent, is done in this manner and the others "see" my aircraft moving in "real" time. This was important because (I don't like the idea someone could mess with my flight.  2) And my virtual airline keeps track of the flight. If I "crashed" I don't get credit for the flight. I can accept the consequences if I did something but not if someone else was the cause. I'm still curious how "they" were able to take control of my aircraft, and how I can prevent them from doing it. If I could then all of this would have been just a good learning process and fly the aircraft normally.

Link to comment
Share on other sites

12 minutes ago, gr8guitar said:

Okay, you got me confused. Looking at: http://www.projectmagenta.com/all-fsuipc-offsets/ , I cannot find offset 0558.

Why are you looking at a PM site for information about FSUIPC? The offsets list is installed for you in your FSUIPC Documents folder, alongside all the other FSUIPC documentation! Have you never used any of this?

I expect the PM one is mainly concerned with offsets that PM uses. It is not my website and I have no access to it to supply documents. 0558 and the following offset was new in FSUIPC4 -- I expect the PM siter is way out of date and only covers FS9 at most.

14 minutes ago, gr8guitar said:

I must also mention, I am using FS2004 (FS9)

Okay. But the offsets list is still installed in your Documents folder, and that is the one you should be using. And yes, as stated in Paul's reply, 0558 is for FSUIPC4 only.

I'm afraid I don't understand anything else in your message as I fail to understand how you can use Excel, a spreadsheet program, for controlling your aircraft. Sounds extremely clever to me! Mind you, I know virtually nothing about spreadsheets or Excel.

19 minutes ago, gr8guitar said:

I'm still curious how "they" were able to take control of my aircraft, and how I can prevent them from doing it.

I know of no way whatsoever unless you are using a program which does these things and you are on-line to some network with such capability, through that program. I thought "multiplayer" could only supply other aircraft data to your sim, and send your data through to others.

If you are running a program or have some sort of infection which allows others to do things to your system I'd try to find it and remove it at once before it starts stealing confidential information. Try a virus checker and malware detector.

Pete

 

Link to comment
Share on other sites

I used the PM website because I was under the impression, unknown to me, it was your website and I thought it might be more up to date than the old FSUIPC for FS9.  And yes, I have the FSUIPC docs and use them but unlike the author of those documents, I do not know all the information, nor can remember all the details of its vast material. Thanks for the heads up but I don't having anything confidential of significance on that computer and I don't have any viruses or anything like that. I heard another person with a very simple set up could not lower his gear using the [g] key so I know, somehow through FSInn, that the administrator can affect an aircraft. For a test, I renamed the FSInn's dll and there were no issues although no multi-player function either. I use Excel for sooo many many things, other than word-processing. It's been my "bread and butter" in work and for home hobbies. I'm grateful for whomever added the visual basic code to access the FSUIPC offsets as well as FSUIPC and GPSout.

Link to comment
Share on other sites

14 minutes ago, gr8guitar said:

I used the PM website because I was under the impression, unknown to me, it was your website

Strange. No, "PM" stands for Project Magenta which is an instrumentation system which does use FSUIPC. but it is owned and run by that company, proprietor Enrico Schiratti. This Forum and its subforums are the only repositiories I have. And all user documentation is installed when you install FSUIPC.

16 minutes ago, gr8guitar said:

And yes, I have the FSUIPC docs and use them but unlike the author of those documents, I do not know all the information, nor can remember all the details of its vast material.

You think I remember all that data? No, of course not. I have to look up stuff just like anyone else. All you need to know is where to look, and the FSUIPC Installer document, packaged with the FSUIPC ZIP, tells you where to find it and what to find there.

Pete

 

Link to comment
Share on other sites

Yes, but are you not the writer of the documents? If so, I would think you have a better idea of where to look than anyone else. I must admit, reading through the years, of the various questions of users you responded to, at times, you're not very patient. To you, FSUIPC options and functions should be obvious. But for me, and seems like others, do miss things or even simply don't understand). For example, it's been there for many years in the documentation, but I over-looked the part where a Lvar could be assigned in a macro (*.mcro as well as in a *.lua) until I had an issue with a Lvar (specifically with an xml gauge and FSUIPC offsets). I use the documentation, but if I can't find or recognize what can help me, I turn to the forum, and then search the Internet. Which brings to mind: Is this not the reason the forum exists? Many times, for me, just a change for wording can  help me understand a concept I have trouble grasping. Again, I am grateful for FSUIPC, GPSOut and the forum. It's made the simulator experience much more interactive.

Link to comment
Share on other sites

Pete Dowson said:

All I suggested is that it would be better for you to refer to the list of offsets I actually provide AND install on your computer than to go off and find some possibly incorrect and incomplete document on someone else's site. I don't deserve all your criticism. If you reads through more of the Forum you see I go out of my way to ensure my users hsave a good working product and in fact most of the facilities have been added due to user requests. And this process has been continuous over the last 18 years, the first 6 of which were for no reward but the satisfacton of doing it.

Pete

   I don't know why this did not show up in this particular topic. 1) yes, you do give support, which is good since it is now a purchased product, not to mention, an actual complex product, at least to me. 2) But by your own words, you said you don't deserve all my criticism. I only have one, and your above note indicates you don't have much patience. Again, you are the expert, and as such, I would hope you know more than most - definitely more than me but a little patience or even no response is better than a message that seems to belittle or berate someone. Also, numerous times, I have also thanked you for FSUIPC. And I believe both "criticisms" are valid - from my point of view. The positives of FSUIPC and its forum far out way its negatives...

Link to comment
Share on other sites

Sorry, I do not see anything whatsoever in my responses to you which indicates either lack of patience or any attemprt to "belittle" you! I only pointed out that you should be using the documents I provide and install, not someone else's on a website you found by searching.

Anyway, I've had enough. I am getting too old for this (I should have retired 8 years ago like all my friends), so will be stopping it all soon I think. I might get time to actually do some flying then. I try my hardest, but it is rarely appreciated.

Pete

 

Link to comment
Share on other sites

Yes, I'm talking about me (see my other posts) but also others I have read through the years. "I try my hardest, but it is rarely appreciated."  And apparently you don't read well, "Also, numerous times, I have also thanked you for FSUIPC."  how many times do I have to say thanks? "The positives of FSUIPC and its forum far out way its negatives..."  And there are plenty of accolades from many users as well. With an active mind like yours, as far as retirement, I retired in 2000, I'm busier now than when I worked. And doing actually flying is always good :).

Link to comment
Share on other sites

Okay. Thanks. I do get depressed sometimes.

I actually left employment when I was 36, starting my own software business with a more outgoing friend who was good at marketing and devising projects. I've always been a programmer only, really, leaving ICL when microcomputers became available -- the Commodore Pet was my first, on which I developed a word processor called WordCraft.

Later, when my eyesight problems stopped me getting a pilot's license I got into flight simulation., writing software for FS4, FS5 FSW95, FS98 before FSUIPC, which was freeware, as it was a hobby.

The company we formed stopped making enough money to pay me anymore a bit before FS9 appeared, so I was on the point of looking for a job instead of continuing FSUIPC when others suggested asking for donations. I did, but that paid almost nothing, certainly not enough to survive, so that's when FSUIPC went payware. It's been full time (apart from holidays) since.

So I have my ups and my downs.

Pete

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.