Jump to content
The simFlight Network Forums

Multiple messages (writes) to 3380...


cknipe

Recommended Posts

Hi All,

 

I can successfully display a message ONCE, but I'm failing to write multiple messages to the sim (not multiple lines - multiple messages)..

 

Let's say I have the following... (presume FSUIPC is connected)

' Inside my timer loop
        If SIMRate <> 256 Then
            Console.WriteLine("WARNING: SIM RATE IS AT " & SIMRate.ToString)
            SimulationRate.Value = 256
            Dim fsuipc_TextDelay As Offset(Of Short) = New FSUIPC.Offset(Of Short)("SendMessage", &H32FA, True)
            Dim SimulationMessage As Offset(Of String) = New Offset(Of String)("SendMessage", &H3380, 128, True)       ' Simulation Message
            SimulationMessage.Value = "SimRate is locked to 1X speeds"
            fsuipc_TextDelay.Value = 5
            FSUIPCConnection.Process("SendMessage")
        End If
 

The first time I change the sim rate, it is correctly set back to 1X as it is supposed to, and the message is displayed in the sim.  Any other time when I change the sim rate, the sim rate change is still detected and set back to 1X - but the message is not displayed again... 

 

I would -expect- the message to be displayed each and every time that the if condition matches.

 

Am I missing something?

Link to comment
Share on other sites

I think there are two problems:

 

1. You've declared the message text offset (3380) after the control offset (32FA). This means the control will be sent before any text has been set.

 

2. You're declaring offsets inside the main timer loop. Offsets must only be declared at the class or form level. The way you have it now, you are creating two new offsets each time this code runs. You app will eventually crash when the FSUIPC memory file gets full.

 

To solve these problems I suggest moving the declarations to the form or class level (see my sample application for where they should go if you're not sure), and reverse the order so the control offset is sent after the text is set:

' At the form/class level...
Dim SimulationMessage As Offset(Of String) = New Offset(Of String)("SendMessage", &H3380, 128, True)       ' Simulation Message
Dim fsuipc_TextDelay As Offset(Of Short) = New FSUIPC.Offset(Of Short)("SendMessage", &H32FA, True)
' Inside my timer loop
If SIMRate <> 256 Then
            Console.WriteLine("WARNING: SIM RATE IS AT " & SIMRate.ToString)
            SimulationRate.Value = 256
            SimulationMessage.Value = "SimRate is locked to 1X speeds"
            fsuipc_TextDelay.Value = 5
            FSUIPCConnection.Process("SendMessage")
End If

The order that you assign values to the offsets doesn't matter. You can set the text after setting the delay value. It's the order you declare (Dim) them that's important.

 

If you declare any other offsets in the timer loop, or any other method, you must move them up to the form/class level as well.

 

Paul

Link to comment
Share on other sites

Oh - Paul replied :)

Ya - just debugging / testing code Paul, will check it out. Thnx.

Had no idea that the order of the declares was important though - is this documented somewhere? I don't recall reading anything to that effect?

Anyways, made the changes and it still seems to be working. Will look into this some more in the morning after some sleep... Thnx Paul!

Link to comment
Share on other sites

It does mention the order in the FSUIPC Offset Status pdf:

 

For 3380:

 

After placing the message text, you must write the
16-bit timer value to offset 32FA to make FSUIPC send the
message (see 32FA above).

 

 

 

For 32FA:

 

Write the message as a
zero-terminated string to offset 3380 (see below), ..., then
write a number to this offset, 32FA, as follows:

 

 

 

However, what isn't documented anywhere is that the DLL sends the requests in the order the offsets are declared. Most of the time the offset order doesn't matter so I didn't think to include it in my User Guide.

 

Paul

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.