Jump to content
The simFlight Network Forums
Mario DANTAS

FSUIPC direc to or via WIDEFS

Recommended Posts

Hi fellows, I've a question.

 

How can we know if we're connected to FSUIPC directly (PC running simulator) or via WideFS (remote PC) in vb.net ?

 

I'll need to figure it out as I'm creating an application that must run via WideFS and NOT directly FSUIPC.

 

Cheers

Share this post


Link to post
Share on other sites

Hi Mario,

 

I've attached a new version of the DLL with a property to test if the connection is via WideClient or not:

If FSUIPCConnection.IsConnectedToWideClient Then
   ' OK
Else
  ' Not OK
End If

I've tested it here on FSX and WideClient and it seems to work.

 

Paul

 

FSUIPCClient3.0_BETA.zip

Share this post


Link to post
Share on other sites

It's stable now really - all of the new features have been tested for a while without problems.

 

I just need to find the time to write the documentation for the new features before I can do an official release. I should really do it in the next few months though as there are some cool new features that everyone should be able to use.

 

Paul

Share this post


Link to post
Share on other sites

Hi Paul,

 

nice to see that there is a new version upcoming. I will do my donation for sure!

 

I have another problem with Win10 PC, P3Dv3.1, FSUIPC and WideFS, because this function does not work. On PC without WideFS I never got a problem. Any ideas?

Imports FSUIPC
Imports System.ComponentModel

Public Sub sendMessageToSIM(message_SG As String)
        Try
            FSUIPCConnection.Open()
        Catch ex As Exception
            msgbox("Can't connect: " & ex.Message)
        End Try

        Try

            Dim msgcontrol As Offset(Of Short) = New FSUIPC.Offset(Of Short)("msg", &H32FA)
            Dim msg As Offset(Of String) = New FSUIPC.Offset(Of String)("msg", &H3380, 128)

            msg.Value = message_SG
            msgcontrol.Value = 5

            FSUIPCConnection.Process("msg")
            msgbox("ERROR: Send message < " & message_SG & " > to sim.")

        Catch e As FSUIPCException

            msgbox("ERROR: Send message to sim: " & e.Message)

        End Try

    End Sub

Log says:

Can't connect: FSUIPC Error #14: FSUIPC_ERR_RUNNING. FSUIPC is not running.
Can't connect: FSUIPC Error #12: FSUIPC_ERR_SENDMSG. Error sending message to FSUIPC.
Can't connect: FSUIPC Error #12: FSUIPC_ERR_SENDMSG. Error sending message to FSUIPC.
 
I will test the v3 as well. Any ideas?

Share this post


Link to post
Share on other sites

 

Log says:

Can't connect: FSUIPC Error #14: FSUIPC_ERR_RUNNING. FSUIPC is not running.
Can't connect: FSUIPC Error #12: FSUIPC_ERR_SENDMSG. Error sending message to FSUIPC.
Can't connect: FSUIPC Error #12: FSUIPC_ERR_SENDMSG. Error sending message to FSUIPC.
 

 

The last two messages are because the connection failed to open (first message).

 

The first message means that the DLL found WideClient.exe running and tried to connect, but WideClient wasn't connected to the main flight sim computer. You need the WideClient to be connected. When the DLL makes the connection it has to talk to FSUIPC, not just the WideClient part. If it is connected, make sure you have the latest version of WideClient.

 

Version 3 above might also work.

 

Also make sure your app and WideClient are running at the same privilege level - either both 'As Administrator' or both not.

 

Paul

Share this post


Link to post
Share on other sites

Hi Paul,

 

thank you for the clarification. I will test it.

 

A strange one is going on if I use the new BETA v3.0.5861.4 because this function isn't working now without WideFS as well:

Public Sub sendMessageToSIM(message_SG As String)

        Try
            FSUIPCConnection.Open()
            msgbox("Connected.")
        Catch ex As FSUIPCException
            msgbox("Can't connect: " & ex.Message)
        End Try

        Dim msgcontrol As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H32FA)
        Dim msg As Offset(Of String) = New FSUIPC.Offset(Of String)(&H3380, 128)

        msg.Value = "test" ' message_SG
        msgcontrol.Value = 5

        FSUIPCConnection.Process()
        FSUIPCConnection.Close()

    End Sub

If I simply go back to the former version everything works fine.

Nothing happens. Even the FSUIPC log inside FSX does not react if I fire this sub.

 

Any idea? Is there a coding failure?

Share this post


Link to post
Share on other sites

A strange one is going on if I use the new BETA v3.0.5861.4 because this function isn't working now without WideFS as well:

 

Any idea? Is there a coding failure?

 

 

What is the error message you get with V3? Is it different if you try to connect direct vs WideFS?

 

Also is your operating system 32bit or 64bit?

 

Paul 

Share this post


Link to post
Share on other sites

64bit OS, Application set to x86. I am using the .NET 4 version the application itself run with .NET 4.5.

 

No error message. If I debug it, he does every line of code but do not write something to the offsets.

Share this post


Link to post
Share on other sites

The difference is that the automatic 'write' detection has changed in this version. Offsets are not written unless you have read them at least once to sync the values with the sim (normal real/write offsets). The exception is offsets created as WriteOnly. These do not need to be read first, but are always written when processed.

 

As the messaging offsets you are using are write-only you should mark them as such when you create the offset:

Dim msgcontrol As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H32FA, True)
Dim msg As Offset(Of String) = New FSUIPC.Offset(Of String)(&H3380, 128, True)

You will find that works okay.

 

One thing to note is that the offsets should be declared at the form (class) level, not in methods. As you have it now, each time this methods runs you get two additional offsets created. If this is just test code then no problem, but I thought I'd mention it.

 

If you use write-only offsets it's best to put them in their own group so they are not processed along with everything else. Write-only offsets are sent every time, not just after the value changes.

Dim msgcontrol As Offset(Of Short) = New FSUIPC.Offset(Of Short)("sendMessage", &H32FA, True)
Dim msg As Offset(Of String) = New FSUIPC.Offset(Of String)("sendMessage", &H3380, 128, True)
msg.Value = "test" ' message_SG
msgcontrol.Value = 5
FSUIPCProcess("sendMessage") ' Just process the two send message offsets

Paul

Share this post


Link to post
Share on other sites

Hi Paul,

 

thank you. Changed and it works.

I will come back to you with the WideFS issue, but open a new thread.

 

Very good support - THANK YOU!

Share this post


Link to post
Share on other sites

Ohh, I'll sill using 2.4 till the V3 becomes stable

 

Like most of times, the problem (me) sits in front of the system... *lol*

Everything looked good with v3 it was my mistake.

Share this post


Link to post
Share on other sites

[...] I have another problem with Win10 PC, P3Dv3.1, FSUIPC and WideFS, because this function does not work. On PC without WideFS I never got a problem. Any ideas? [...]

This is solved as well. I don't know (but I think not) that this one is related to WideFS. I used a background worker to check if "SimReady". I simply switched to Object Ticker and everything works fine.

I am happy.  :razz:

Share this post


Link to post
Share on other sites

Hello gentlemen, this beta dll is for remote pc use only? Or is it possible to use it for the same pc applications also?

Share this post


Link to post
Share on other sites
On 20.01.2016 at 0:36 AM, Paul Henty said:

The difference is that the automatic 'write' detection has changed in this version. Offsets are not written unless you have read them at least once to sync the values with the sim (normal real/write offsets). The exception is offsets created as WriteOnly. These do not need to be read first, but are always written when processed.

 

As the messaging offsets you are using are write-only you should mark them as such when you create the offset:


Dim msgcontrol As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H32FA, True)
Dim msg As Offset(Of String) = New FSUIPC.Offset(Of String)(&H3380, 128, True)

You will find that works okay.

 

One thing to note is that the offsets should be declared at the form (class) level, not in methods. As you have it now, each time this methods runs you get two additional offsets created. If this is just test code then no problem, but I thought I'd mention it.

 

If you use write-only offsets it's best to put them in their own group so they are not processed along with everything else. Write-only offsets are sent every time, not just after the value changes.


Dim msgcontrol As Offset(Of Short) = New FSUIPC.Offset(Of Short)("sendMessage", &H32FA, True)
Dim msg As Offset(Of String) = New FSUIPC.Offset(Of String)("sendMessage", &H3380, 128, True)

msg.Value = "test" ' message_SG
msgcontrol.Value = 5
FSUIPCProcess("sendMessage") ' Just process the two send message offsets

Paul

Paul, once you said that ...

Dim msg As Offset(Of String) = New FSUIPC.Offset(Of String)("sendMessage", &H3380, 128, True)

code should be on the top, and...

Dim msgcontrol As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H32FA, True)

code must follow it. 

But on the example above it is vice versa.. their sequence matters?

Share this post


Link to post
Share on other sites

Hi,

you declare normally only once the Offset you want to use outside the function, global, like you would do with global variables.

Have a look into the manual / examples that comes with the DLL, that will really help a lot to avoid mistakes.

Thomas

  • Upvote 1

Share this post


Link to post
Share on other sites
Quote

Paul, once you said that ...

Dim msg As Offset(Of String) = New FSUIPC.Offset(Of String)("sendMessage", &H3380, 128, True)

code should be on the top, and...

Dim msgcontrol As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H32FA, True)

code must follow it. 

But on the example above it is vice versa.. their sequence matters?

Yes you're right, the order does matter, and the code above does have them the wrong way round.

The 'control' offset should be declared after the 'message' offset.

I failed to spot that particular mistake in the original code.

Paul

Share this post


Link to post
Share on other sites
On 18.01.2016 at 9:16 PM, Paul Henty said:

Hi Mario,

 

I've attached a new version of the DLL with a property to test if the connection is via WideClient or not:


If FSUIPCConnection.IsConnectedToWideClient Then
   ' OK
Else
  ' Not OK
End If

I've tested it here on FSX and WideClient and it seems to work.

 

Paul

 

FSUIPCClient3.0_BETA.zip

Sir, i never used widefs, so please excuse me if the question is too stupid, if the LAN is somehow lost, i mean imagine that there is a power loss and the modem, that provides wifi lan, is off. Both laptops (one runs fs and the other one runs an application that uses fsuipcclient.dll) lose the connection with each other. The above code returns "Ok"? Or "Not Ok"?

Share this post


Link to post
Share on other sites

It will be 'OK'.

The DLL is still connected to the WideClient.exe which is still sending data to the DLL. (This data will be the last values as it last got from WideServer before the connection was lost.)

FSUIPCConnection.IsConnectedToWideClient will still be true.

Also FSUIPCConnection.IsConnectionOpen() will also still be true.

As long as the DLL can talk to WideClient.exe it will consider that it has a valid connection.

When the network connection is lost, your application will still receive data, but it will be 'frozen in time' until the network connection is restored.

If you want to check for the network connection being lost, you can monitor offset 0x337E (See the documentation). This is a counter that should change with each Process(). If you get the same number back a few times then you can assume the network connection between WideClient and WideServer has been lost.

Paul

 

Share this post


Link to post
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


×