Jump to content
The simFlight Network Forums

Rhysa

Members
  • Posts

    17
  • Joined

  • Last visited

Posts posted by Rhysa

  1. I have to say a purpose built module for .Net like this has been long overdue. Its great to see that someone who really knowns their stuff has put together a great module for the community. Its going to make coding for FSUIPC much more efficient. As developer of a few small addon's I'm happy to say I can discard the old methods and will be using this module from now on.

    So thanks, and keep up the good work!

    :D :D :D

  2. I had this problem too trying to read an Unsigned Int32 in VB.Net. So I too added another Get method that looked like this:

        Overloads Function FSUIPC_Get(ByRef Token As Integer, ByRef Result As UInt32) As Boolean
            Dim Size As Integer = 8    ' 8 bytes in a Double
            Dim InBuf(8) As Byte
            Dim i As Integer
            If (Token < 0) Or (Token > IPC_BUFFER_SIZE - (4 + Size)) Then 'Token out of range
                Result = Convert.ToUInt32(0)
                FSUIPC_Get = False
                Exit Function
            End If
            Result = BitConverter.ToUInt32(IPC, Token + 4)
            If IPCdr(Token) Then
                IPCdr(Token) = False
                FSUIPC_Get = True
            Else    ' If data ready flag not set, function returns FALSE and value found
                FSUIPC_Get = False
            End If
        End Function

    Now the only lines that I had to chage was

    Overloads Function FSUIPC_Get(ByRef Token As Integer, ByRef Result As UInt32) As Boolean
    
    Result = BitConverter.ToUInt32(IPC, Token + 4)

    Now C# and Vb.net are pretty similar and the only Get method in my code that uses Marshal.Copy is the string handler.

    It seems the VB.net and C# sdks are very different.

  3. Its easy. Once you have connected to read stuff just call these functions:

    FSUIPC_Read(offset, size, token, result)
    FSUIPC_Process(result)
    FSUIPC_Get(token, value)

    Offset (ie &H2342) and size are from the SDK and relate to the variable you are trying to read. Value is the actual final value. You need a different token for each variable you want to read.

    Multi-reads:

    FSUIPC_Read(offset1, size1, token1, result)
    FSUIPC_Read(offset2, size2, token2, result)
    FSUIPC_Process(result)
    FSUIPC_Get(token1, value1)
    FSUIPC_Get(token2, value2)

    And writes are simply:

    FSUIPC_Write(offset, value, token, result)
    FSUIPC_Process(result)

    Email if you want my .Net dll.

    MOST important, remember to declare your variables as the same data type as specified in the SDK. ie if it says integer with length 2 then use int16 data type.

    BONUS FUNCTION ( :D :D )

    To register your app with FSUIPC

    Dim token As Integer
    Dim bytecode() As Byte
    Dim a As New System.Text.ASCIIEncoding
    
    'Insert your key in this line
    bytecode = a.GetBytes("A4729AOCNPVU")
    
    FSUIPC_Write(&H8001, bytecode.Length, bytecode, token, dwresult)
    
    'if Process returns true then success else failed to register
    If FSUIPC_Process(dwresult) = True Then
     '...success code
    Else
     'failure
    End If

  4. It would be better if I can map them directly, but I'd need to see them changing for that. How do I do that?

    The wing fold is similar to the tailhook funtion - press a key and it animates. By default there is no key assigned,you have to set this up. Then you need an aircraft that uses it, Daisuke Yamamoto's F/A-18E Superhornet (http://flightinfo.ens.ne.jp/FS_KBT/dai.htm) has wing folding.

    How quickly would they change and be needed to be checked. If I have to read them procedurally I don't want to have to do it on every frame if I can avoid it.

    I would only need to know if they are fully folded, or unfolded. The rate of folding varies per aircraft and is specified in the aircraft.cfg.

    ie:

    [folding_wings]
    wing_fold_system_type=4                       ;0=None
    fold_rates=0.12,0.11                          ;Percent per second

    Its not a quick change, it could be read every second, there is no need for the position to be read at every interval.

  5. Pete is it possible to get any of these from FS:

    - Tailhook available, ie configured in aircraft.cfg

    - Wing fold position?

    It would be handy to have this information for my program.

    Also I found another reason VB.NET is not a good language for interfacing with FS, there is no native signed byte data type. Can work around it by doing:

    If val >= 128 Then
      newval = -(255 - Value + 1)

    But it still caused a few hours of frustration :evil: Good news is this type is in .NET v2.0

  6. Ive released my first add on for FS, 3Wire Aircraft Carrier Simulator. This version features:

    - Launch and recover any aircraft aboard aircraft carriers

    - Launch holdback

    - Adjustable forces

    - Optional require hook down

    - Cable holdback, raise the hook before taxiing!

    - Optional steam effect included

    - 8 page operating handbook

    - Ready to use with default and ArrCab carriers

    - Cable Zone Assistant, makes creating zones easy

    Its freeware, you can grap it at AVSIM and Aussim.com.au. Big thanks to Pete for FSUIPC, for giving me a key over a year ago (took some time but its here :D ) and for helping out with a few problems.

  7. Ok i got it working finally. As you said the value is unsigned, and represents the number of 2^32 parts. Anyway was continually reading negative numbers, and soon found out that the VB.NET SDK does not have the capability to handle unsigned numbers. Anyway I added some code which I wil post here for anyone else who ever runs into such a problem.

    Overloads Function FSUIPC_Get(ByRef Token As Integer, ByRef Result As UInt32) As Boolean
            Dim Size As Integer = 8    ' 8 bytes in a Double
            Dim InBuf(8) As Byte
            Dim i As Integer
            If (Token < 0) Or (Token > IPC_BUFFER_SIZE - (4 + Size)) Then 'Token out of range
                Result = Convert.ToUInt32(0) 'This line changed
                FSUIPC_Get = False
                Exit Function
            End If
            Result = BitConverter.ToUInt32(IPC, Token + 4)
            If IPCdr(Token) Then
                IPCdr(Token) = False
                FSUIPC_Get = True
            Else    ' If data ready flag not set, function returns FALSE and value found
                FSUIPC_Get = False
            End If
    End Function

    The change is:

    Result = BitConverter.ToUInt32(IPC, Token + 4)

    Which converts to unsigned 32bit integer. You may have to do a conversion back to double or signed integer in your code to perform any calculations.

    Hope this helps someone.

  8. Im having trouble getting the fractional part of the altitude at offset 0570. I can read the unit part at 0574, however im unsure of how to convert the fractional part at 0570. At the moment ive tried dividing by 10^9 then adding to the unit part. This gives an approximate value. But when I write to the fractional value and try to multiply by 10^9 I get an overflow (VB.NET).

    How do I handle the fractional part?

  9. I am relatively new to programming with FSUIPC. With the new keys scheme, I have found there is little opportunity for someone to learn and play around with FSUIPC.

    If its possible I think it would be great to have some kind of "dev" keys that allowed an application to access FSUIPC for a short time after the build date. Im thinking something where you have a generic key where the company name is, say, "Dev" and has an expiry date to prevent misuse, requiring a change of key periodically. But make it so that the application can only access FSUIPC for 24 hours after the last modification date of the exe. Therefore it would require the application to be rebuilt and therefore resetting the 24 hour period. Therefore in theory it could not be distributed and only useful to a developer. Then when the application was ready to be released an application for a proper key could be made.

    This is only a suggestion, and it may (most likely) have flaws, so take it for what u will.

×
×
  • 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.