cknipe Posted March 9, 2016 Report Posted March 9, 2016 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?
Paul Henty Posted March 9, 2016 Report Posted March 9, 2016 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
cknipe Posted March 10, 2016 Author Report Posted March 10, 2016 Don't know what was wrong, but it's working now... Must have been some other reason why the messages didn't make it to the sim.
cknipe Posted March 10, 2016 Author Report Posted March 10, 2016 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!
Paul Henty Posted March 10, 2016 Report Posted March 10, 2016 It does mention the order in the FSUIPC Offset Status pdf: For 3380: After placing the message text, you must write the16-bit timer value to offset 32FA to make FSUIPC send themessage (see 32FA above). For 32FA: Write the message as azero-terminated string to offset 3380 (see below), ..., thenwrite 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now