Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,724
  • Joined

  • Days Won

    77

Everything posted by Paul Henty

  1. Looks like you haven't reversed all of the conversion formula on the way out... //current = ((state*65536)*foot/100) //Should be... current = ((state*65536)/foot*100) ipc.writeUD(0x07d4, current ) Paul
  2. Hi Marco, It would be very surprising if a certain aircraft was stopping FSUIPC from reporting the Lon/Lat. Do you know what values are being returned from the function? Place a breakpoint on the 'Return' lines and see what's in the Latitude.Value property. I suspect what's happening is that these functions are never being run. This is probably because you have some other logic in the program which is not working because of the Q400. If it's a complex payware plane then they often model some things outside of FSX/P3D. This means you cannot get those value via FSUIPC. So maybe some other logic is not working and your program is never checking the Lon/Lat. Paul
  3. Great! Thanks for letting me know. It's good that the 32-bit restriction has been overcome, even for those only thinking about the Microsoft-based flight sims. Thanks for pushing me to take another look at this. Paul
  4. Hi, 'swapc1' would suggest you're trying to swap the COM1 radio, but 66444 does COM2. Have you tried 66372 (COM_STBY_RADIO_SWAP)? Another method you could try to swap radios is writing the following byte values to offset 0x3123: 8: COM1 swap 4: COM2 swap 2: NAV1 swap 1: NAV2 swap Paul
  5. Hi Jürgen, Thanks for the explanation. I've looked into this a bit more and it is possible to share the memory between the 32bit and 64bit apps. The problem was handling the different size pointers. I've made some changes and managed to recompile the DLL to run on "Any CPU", so it will switch between 64/32 depending on the process it's running in. Also it doesn't matter if the FSUIPC/XPUIPC it's connecting to is running in a 32 bit or 64 bit flight sim, this new DLL should now connect to either. I cannot test on XPUIPC as I don't have X-Plane, but it works here for FSX from a 64 bit and a 32 bit client application. Hopefully it will also connect to your 64 bit XPUIPC. Regards, Paul FSUIPCClient3.0_BETA.zip
  6. Thomas is correct. If the DLL was compiled as 64 bit (or 32/64 combined), it would not be able to communicate with any of the simulators. Windows does not allow 64 bit programs and 32 bit programs to share memory files. Lockheed Martin are said to be bringing out a 64 bit version of P3D, but there are no time-scales yet. If they do, it would need Pete to bring out a 64 bit version of FSUIPC as well. If all of that ever happens then I can easily release a 64 bit version of the DLL. But at the moment, as Thomas says, there is no point. If you want to use FSUIPC, you have no choice but to compile your application as 32bit only. Paul
  7. Hi, The Altitude problem is because the variable Me.APAltitudeValue has not been given a type when you defined it. If you say it's a decimal it will work: Dim APAltitudeValue As Decimal The VS Hold problem is because you've declare the offset as 4 bytes (Integer) when it's only 2. It will work if you change the declaration to be Short (2 bytes): Dim fsAPVSValue As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H07F2) Paul
  8. Hi, Your timer loop idea is the only way it can be done. You just have to keep reading the data and then compare the new values against the old ones that you've saved from the previous read. When you detect a change you can either fire your own event(s) or just call the appropriate subroutine(s) directly if you prefer. Monitoring 40 variables like this won't cause you any performance or memory problems at all (you could easily do 400 if you wanted). Paul
  9. Your DFYFlightCenter.exe is being compile with the 'Prefer 32 Bit' option ticked. This needs to be unticked and the 'target CPU' or 'platform target' set to x86. You can find these options in the properties window of the project, on the 'Build' (C#) or 'Compile' (VB) tab. Paul
  10. See the following post for how to merge the DLL and your exe. Note however that this is for the normal linking situation where you just add a reference to the DLL file on the disk. I don't know if it will work if you've added the DLL as a resource. http://forum.simflight.com/topic/78233-embed-fsuipcclientdll-in-exe/ Paul
  11. Your conversion format is correct. The ToString() method just returns the formatted string however, it doesn't affect the com1DecStby variable at all. So you need to use the output of the ToString function. e.g. Me.Label1.Text = Me.com1DecStby.ToString("##0.000") Paul
  12. Here is the ADF code: In your code you'll want to define the two offsets (Main and Extended) for the ADF (I've use ADF1 here:) Dim adf1BCDMain As Offset(Of Short) = New Offset(Of Short)(&H34C) Dim adf1BCDExtended As Offset(Of Short) = New Offset(Of Short)(&H356) and a decimal copy of this to make changing/displaying it easier Dim adf1Decimal As Decimal Here are two functions to encode and decode to/from the Decimal value to the two BCD offsets: Private Function getADFFromBCD(ADFMain As Offset(Of Short), ADFExtended As Offset(Of Short)) As Decimal Dim freq As Decimal freq = Decimal.Parse(ADFMain.Value.ToString("X4")) Dim extended As String = ADFExtended.Value.ToString("X4") freq += Decimal.Parse(extended.Substring(0, 2)) * 1000 freq += Decimal.Parse(extended.Substring(2, 2)) / 10 getADFFromBCD = freq End Function Private Sub copyADFToBCDOffsets(ADFDecimal As Decimal, ByRef ADFMainOffset As Offset(Of Short), ByRef ADFExtendedOffset As Offset(Of Short)) Dim freq As String = ADFDecimal.ToString("0000.0") ADFMainOffset.Value = Short.Parse(freq.Substring(1, 3), Globalization.NumberStyles.AllowHexSpecifier) ADFExtendedOffset.Value = Short.Parse(freq.Substring(0, 1) & "0" & freq.Substring(5, 1), Globalization.NumberStyles.AllowHexSpecifier) End Sub And here are two functions that increment and decrement individual digits in the real decimal value of the ADF. These handle wrapping around from 9 to 0 and 0 to 9. They also prevent the frequency from going outside the valid FSX range. Private Sub incADFDigit(ByRef ADFDecimal As Decimal, digitIndex As Short) Dim ADFOriginal As Decimal = ADFDecimal digitIndex = digitIndex - 1 If digitIndex = 4 Then digitIndex = 5 Dim digitValue As Short = Short.Parse(adf1Decimal.ToString("0000.0").Substring(digitIndex, 1)) Dim amount As Decimal = 0 Select Case digitIndex Case 0 amount = 1000 If digitValue + 1 > 1 Then amount = -1000 End If Case 1 amount = 100 If digitValue + 1 > 9 Then amount = -900 End If Case 2 amount = 10 If digitValue + 1 > 9 Then amount = -90 End If Case 3 amount = 1 If digitValue + 1 > 9 Then amount = -9 End If Case 5 amount = 0.1 If digitValue + 1 > 9 Then amount = -0.9 End If End Select ADFDecimal += amount If ADFDecimal > 1799.9 Then ADFDecimal = ADFOriginal End If If ADFDecimal < 100 Then ADFDecimal = ADFOriginal End If End Sub Private Sub decADFDigit(ByRef ADFDecimal As Decimal, digitIndex As Short) Dim ADFOriginal As Decimal = ADFDecimal digitIndex = digitIndex - 1 If digitIndex = 4 Then digitIndex = 5 Dim digitValue As Short = Short.Parse(adf1Decimal.ToString("0000.0").Substring(digitIndex, 1)) Dim amount As Decimal = 0 Select Case digitIndex Case 0 amount = -1000 If digitValue - 1 < 0 Then amount = 1000 End If Case 1 amount = -100 If digitValue - 1 < 0 Then amount = 900 End If Case 2 amount = -10 If digitValue - 1 < 0 Then amount = 90 End If Case 3 amount = -1 If digitValue - 1 < 0 Then amount = 9 End If Case 5 amount = -0.1 If digitValue - 1 < 0 Then amount = 0.9 End If End Select ADFDecimal += amount If ADFDecimal > 1799.9 Then ADFDecimal = ADFOriginal End If If ADFDecimal < 100 Then ADFDecimal = ADFOriginal End If End Sub How to use these: 1. When your application starts you need to fill the decimal value by getting the current value from FSX: FSUIPCConnection.Process() adf1Decimal = getADFFromBCD(adf1BCDMain, adf1BCDExtended) 2. Call the inc/dec digit function when you need to change the digits. Note you need to pass in the decimal variable and the number of the digit to change. The digits are numbered from 1 to 5 from left to right. So the thousands is digit 1 and the tenths is digit 5. e.g. incADFDigit(adf1Decimal, 2) ' increment the hundreds digit decADFDigit(adf1Decimal, 3) ' decrement the tens digit 3. Write the new value back to FSX: copyADFToBCDOffsets(adf1Decimal, adf1BCDMain, adf1BCDExtended) FSUIPCConnection.Process() Paul
  13. Ah sorry about that - I had it in my head that the frequencies were rounded up, not down. If your mod works that's fine, but these are the corrected versions of the conversion functions: Private Function encodeFreqAsBCD(freqDecimal As Decimal) As Short encodeFreqAsBCD = Short.Parse((Int((freqDecimal - 100) * 100)).ToString(), Globalization.NumberStyles.AllowHexSpecifier) End Function Private Function getFreqFromBCD(freqBCD As Short) As Decimal Dim freq As Decimal = ((Decimal.Parse(freqBCD.ToString("X")) / 100) + 100) ' If the freqency is not a multiple of 0.025 then it's been truncated ' Add 5Khz to get real value If (freq * 1000) Mod 25 <> 0 Then freq += 0.005 End If getFreqFromBCD = freq End Function For the ADF frequencies I suggest using the same approach: keeping a decimal version for your own use and encoding to/from BCD. The ADF encodings are complicated though because they are split over two different offsets. I can get you the encoding/decoding functions tomorrow. Paul
  14. Yes, FSX doesn't deal with the third decimal place. That's just for our use so the frequency increment follows the correct pattern. If we calculate the real frequency to be 126.025 we're actually going to send 0x2603 to FSX after encoding. The radio should show 126.03. Paul
  15. Hi Marco, The Pause indicator offset (0x0264) is 2 bytes long. Make sure you've declared the offset as a short or ushort. I suspect you have it declared as an integer and therefore you are reading data from adjacent offsets as well, giving you false readings. If that's not the case, please post some code, especially the relevant offset declarations and the part where you test the value. Without seeing the code it's almost impossible to tell what the problem could be. Paul
  16. You cannot work with the value in the offset. You need to keep your own frequency value to 3 decimal places and work with that (i.e. add and subtract 0.025). The offset value is in BCD format, not a real hex number, so maths will not work on it. You should declare a value for the full frequency as a decimal alongside the offset: Dim com1bcdstby As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H311A) Dim com1DecStby As Decimal ' This will hold the full decimal number I would then setup 2 functions to easily convert between FSX BCD format and a real decimal number containing the whole frequency: Private Function encodeFreqAsBCD(freqDecimal As Decimal) As Short encodeFreqAsBCD = Short.Parse(((Decimal.Round(freqDecimal, 2, MidpointRounding.AwayFromZero) - 100) * 100).ToString("F0"), Globalization.NumberStyles.AllowHexSpecifier) End Function Private Function getFreqFromBCD(freqBCD As Short) As Decimal Dim freq As Decimal = ((Decimal.Parse(freqBCD.ToString("X")) / 100) + 100) ' If the freqency is not a multiple of 0.025 then it's been rounded ' Subtract 5Khz to get real value If (freq * 1000) Mod 25 <> 0 Then freq -= 0.005 End If getFreqFromBCD = freq End Function Now you can always do the maths on the full decimal number (which is easy) and then convert it to BCD when you assign the new value to the offset: Here's an 'add' example (you can add the previously discussed wrap-around code) Private Sub Add() ' Add 0.025 to full decimal value com1DecStby+= 0.025 ' set this new value to the offset (convert to BCD) com1bcdstby.Value = encodeFreqAsBCD(com1DecStby) End Sub When you program first starts you need to read the current frequency from FSX and fill your decimal variable as an initial value: FSUIPCConnection.Process() Me.com1DecStby = getFreqFromBCD(com1bcdstby.Value) Paul
  17. Look like you need offset 0x3123 to swap the operational/standby frequency in the Flight Sim. Declare this as type 'of Byte' and write only: Dim stbySwap As Offset(Of Byte) = New FSUIPC.Offset(Of Byte)(&H3123, True) Then you need to write the following value depending on which radio you want to swap: 8: COM1 4: COM2 2: NAV1 1: NAV2 e.g. to swap COM2: stbySwap.Value = 4 ' COM2 FSUIPCConnection.Process() Paul
  18. Yes the easiest thing to do is just check if the value has gone out of range. If it has you have two choices: One is to wrap around as you said in your post, the other option is just to stick on the min or max so you can't go any further. something like this: ' Check for over max If newFreq > maxFreq then newFreq = maxFreq ' Use this line to limit to max or... newFreq = minFreq ' Use this line to Wrap around end if ' Check for under min If newFreq < minFreq then newFreq = minFreq ' Limit to min or... newFreq = maxFreq ' Wrap around end if Paul
  19. The com frequencies are divided into steps of 25khz. So if we start at 108mhz we get these frequencies: 108.000 108.025 108.050 108.075 108.100 108.125 And so on. Radios generally only show the first two decimals so it looks like it's adding 2,3,2,3 etc. The .005's are just hidden. You just need to keep the full value in a variable and add/subtract 0.025. Then drop the last digit when you write to FSUIPC. Paul
  20. No, looks fine to me. Have you tried putting a breakpoint in pictureBox3_click() and stepping though to see if it's called? Two reasons I can think of that the line is not getting called: 1. The click of the pictureBox3 is not actually bound to pictureBox3_click(). Check in the form designer - properties of pictureBox3. 2. There is an exception being thrown in an earlier line. You would normally see this, unless you're catching the exception somewhere and not reporting it. Paul
  21. The problem is you're calling Process() without the group name, so it's not updating (reading) the "update" group which has all your relevant offsets. I did give you the correct code with the group name included (post #7). private void setLastValues() { FSUIPCConnection.Process("update"); this.lastlatitude = this.Latitude.Value; this.lastlongitude = this.Longitude.Value; this.lastaltitude = this.Altitude111.Value; this.lastairspeed = this.Airspeed.Value; this.lastheading = this.Heading.Value; } Paul
  22. Strange. I can't see anything obviously wrong with the code. Use the debugger (set breakpoints) to see where the values are wrong. Check the values being saved in setLastValues(). In pictureBox4_Click() check the values of the this.lastlatitude etc. Also use the FSUIPC logging to log FSUIPC Writes. Then see exactly what value is being written to FSX. (If you log to the console and run FSX in window mode you can see this in realtime). Paul
  23. I can't see anywhere in the code that you call process() before setting the values. Process() needs to be called to get the current values from FSX. Unless you have a more suitable place I would put this in setLastValues(). private void setLastValues() { FSUIPCConnection.Process("update"); this.lastlatitude = this.Latitude.Value; this.lastlongitude = this.Longitude.Value; this.lastaltitude = this.Altitude111.Value; this.lastairspeed = this.Airspeed.Value; this.lastheading = this.Heading.Value; } See if that helps. Paul
  24. 'Grounding rate' is called 'Touchdown rate' or 'Vertical Speed at Touchdown' - offset 0x030C. The height of the plane above sea level is called 'Altitude', Offset 0x6020. This is the real altitude. To get the reading on the Altimeter instrument you need 0x3324. Paul
  25. Hi, This feature in FSX (via FSUIPC or SimConnect) doesn't support Unicode characters. It only shows ASCII. Chinese characters cannot be encoded into ASCII so they appear as ????. I don't think there is a solution to this. It just isn't supported by FSX. Paul
×
×
  • 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.