• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

MSFS Managed SimConnect Library doesn't take negative values using VB .NET 2019 and TransmitClientEvent()

Messages
13
Country
germany
Hi Guys,

Have a issue to transmit client events.

In the managed SimConnect Library 0.12.0, the function TransmitClientEvent() takes UInteger data as event data.
Public Sub TransmitClientEvent(ObjectID As UInteger, EventID As [Enum], dwData As UInteger, GroupID As [Enum], Flags As SIMCONNECT_EVENT_FLAG)

But in the documentation the events have a range from -16383 up to 16383

KEY_AXIS_RUDDER_SETAXIS_RUDDER_SETSets rudder position (-16383 - +16383)
KEY_AXIS_ELEV_TRIM_SETAXIS_ELEV_TRIM_SETSets elevator trim position (-16383 - +16383)

And that seems to be the truth because in my VB .Net example I can set the throttle - but the range is from 50% to 100%
Same for the rudder. If I send 0 it is in the middle and by 16383 the rudder is fully set to right.

Any idea, how to overwrite the wrong definition of the function? Or how to force the compiler to accept negative values and send the MSB?

Seems to be a VB .Net issue because in C++ the function takes a DWORD so it is possible to send negative values.
SIMCONNECTAPI SimConnect_TransmitClientEvent(HANDLE hSimConnect, SIMCONNECT_OBJECT_ID ObjectID, SIMCONNECT_CLIENT_EVENT_ID EventID, DWORD dwData, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, SIMCONNECT_EVENT_FLAG Flags);

I am grateful for any help.
 

DragonflightDesign

Resource contributor
Messages
1,088
Country
northernireland
The managed SimConnect libraries are simply wrappers around COM calls. My bet is that the documentation is wrong (again!). Try it - you can't break anything.
 
Messages
13
Country
germany
Sure, but the runtime environment fires an exception when you try to set a negative value.
 
Messages
4
Country
australia
Code:
    Public Sub TransmitClientEvent(ByVal eventID As [Enum], ByVal data As String)

        If sim IsNot Nothing Then
            Try
                Dim Bytes As Byte() = BitConverter.GetBytes(Convert.ToInt32(data))
                Dim Param As UInt32 = BitConverter.ToUInt32(Bytes, 0)

                sim.TransmitClientEvent(0, eventID, Param, SimEventGroupID.Group1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY)
            Catch ex As Exception
                Throw New Exception("The Transmit Request Failed: " + ex.Message)
            End Try
        End If

    End Sub
 
Messages
13
Country
germany
Yessss it works!
Thanks a lot


Select Case mySerialBlockInt32.myType Case CR_ROTARY Select Case mySerialBlockInt32.myDevice Case CR_ROTARY_ELEV_TRIM valElevTrim += (mySerialBlockInt32.myValue * CR_ROTARY_ELEV_TRIM_FACTOR) If valElevTrim < -16383 Then valElevTrim = -16383 ElseIf valElevTrim > 16383 Then valElevTrim = 16383 End If Try Dim Bytes As Byte() = BitConverter.GetBytes(Convert.ToInt32(valElevTrim)) Dim Param As UInt32 = BitConverter.ToUInt32(Bytes, 0) mySimConnect.TransmitClientEvent(0, EVENT_ID.KEY_AXIS_ELEV_TRIM_SET, Param, hSimconnect.group1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY) Catch ex As Exception ... End Try End Select End Select
 
Top