node-simconnect icon indicating copy to clipboard operation
node-simconnect copied to clipboard

MFS2020 : Aircraft management from node-simconnect

Open Oru-Bus opened this issue 2 months ago • 1 comments

Hello, I'd like to know if it's possible to manage the aircraft by sending it data, and if so, how? For example, we can find out the altitude of the autopilot by doing :

handle.addToDataDefinition(
            ALTITUDE_DATA,
            AUTOPILOT ALTITUDE LOCK VAR,
            feet',
            SimConnectDataType.FLOAT64,
            0.0,
            SimConnectConstants.UNUSED
 ) ;

handle.requestDataOnSimObject(
            REQUEST_ID_ALTITUDE_DATA,
            ALTITUDE_DATA,
            SimConnectConstants.OBJECT_ID_USER,
            SimConnectPeriod.SECOND,
            0,
            0,
            0,
            0
) ;
....

But is it possible to increase the autopilot altitude from node-simconnect?

For example, I tried :

const altitudeIncrement = 1000 ;

handle.transmitClientEvent(
    SimConnectConstants.EVENT_ID_AP_ALT_VAR_INC,
    altitudeIncrement,
    0, // Additional parameter (0 by default)
    SimConnectConstants.OBJECT_ID_USER,
    SimConnectConstants.EVENT_FLAG_GROUPID_IS_PRIORITY
 ) ;

But here's the error I got:

Error: TypeError: Illegal value: undefined (not an integer)
    at module.exports.ByteBufferPrototype.writeInt32 (D:\game\MFS2020\HomeCockpit\node_modules\bytebuffer\dist\bytebuffer-node.js:856:23)
    at RawBuffer.writeInt32 (D:\game\MFS2020\HomeCockpit\node_modules\node-simconnect\dist\RawBuffer.js:66:21)
    at SimConnectPacketBuilder.putInt32 (D:\game\MFS2020\HomeCockpit\node_modules\node-simconnect\dist\SimConnectPacketBuilder.js:41:28)
    at SimConnectConnection.transmitClientEvent (D:\game\MFS2020\HomeCockpit\node_modules\node-simconnect\dist\SimConnectConnection.js:124:14)

Oru-Bus avatar Apr 27 '24 12:04 Oru-Bus