Jump to content
The simFlight Network Forums

Live FSX data for use with node.js


namboozle

Recommended Posts

Hello,

I've been hunting around the web all evening trying to find an answer but I'm not getting so far.
I'm looking at developing an application with node.js which will need to be fed live data from FSX.

I've looked through a few of the examples in the SDK, in various languages but I just want to see if any one knows if any of the following exist before I have to hack something together:

  1. Program that will save flight data to a JSON or XML file, and update on a set interval
  2. A server that can allow access to live data via an API. If you've seen PWFServer I mean something like that, but it documentation for accessing the data
  3. Node.js app which uses a C or Python as a bridge to FSUIPC

I realise what I'm asking might be a little ambiguous but any help or pointers would be great.

Thanks! 

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

What I did (any still have to finish) is using C# to connect to FSUIPC and a NodeJS WebSocket. Then, every 50ms (20hz) the program sends the data to the NodeJS server. But my program needs some work, as it is not efficient (it sends all data I need every time, even if it hasn't changed). I just need to find a way to make it more efficient and at the same time be reliable in terms of correct data.

What exactly are you building? Do you need any help with that?

Link to comment
Share on other sites

  • 3 months later...

I managed to read and write values 'directly' from FSUIPC using Node.js today. I used the C-language SDK and edited FSUIPC_User.h to export its functions (FSUIPC_Open, FSUIPC_Read, etc) before I compiled the code (FSUIPC_User.h, IPCuser.h, IPCuser.c) as a DLL in Visual Studio. I then used the package node-ffi to load the DLL into node and call the DLL's functions. Seems to work well - reads at 10 ms intervals without problems :)

Edit:
You might have some luck using a module like node-ipc too.

Link to comment
Share on other sites

  • 11 months later...
On 11/9/2016 at 11:47 PM, Even92LN said:

I managed to read and write values 'directly' from FSUIPC using Node.js today. I used the C-language SDK and edited FSUIPC_User.h to export its functions (FSUIPC_Open, FSUIPC_Read, etc) before I compiled the code (FSUIPC_User.h, IPCuser.h, IPCuser.c) as a DLL in Visual Studio. I then used the package node-ffi to load the DLL into node and call the DLL's functions. Seems to work well - reads at 10 ms intervals without problems :)

Edit:
You might have some luck using a module like node-ipc too.

I tried to implement this solution, exporting functions and compiling as DLL, but I can not connect to FSUIPC. I get the message: "Can not link to FSUIPC or WideClient", when a try to connect via FSUIPC_Open

I compile as 32 bits. My node.js is also 32 bits. Tried 64, but I get the same error.

This is my javascript code.

var ffi = require('ffi');
var ref = require('ref');

const pszErrors = [
    "Okay",
    "Attempt to Open when already Open",
    "Cannot link to FSUIPC or WideClient",
    "Failed to Register common message with Windows",
    "Failed to create Atom for mapping filename",
    "Failed to create a file mapping object",
    "Failed to open a view to the file map",
    "Incorrect version of FSUIPC, or not FSUIPC",
    "Sim is not version requested",
    "Call cannot execute, link not Open",
    "Call cannot execute: no requests accumulated",
    "IPC timed out all retries",
    "IPC sendmessage failed all retries",
    "IPC request contains bad data",
    "Maybe running on WideClient, but FS not running on Server, or wrong FSUIPC",
    "Read or Write request cannot be added, memory for Process is full",
];
// Creates a DWORD pointer
const DWORDPTR = ref.refType('ulong');

const fsuipc = ffi.Library('fsuipc', {
    'FSUIPC_Open': [ 'int', ['ulong', DWORDPTR]],
    'FSUIPC_Read': ['int', ['ulong', 'ulong', 'pointer', DWORDPTR]],
    'FSUIPC_Process': ['int', [DWORDPTR]]
});
var dwResult = ref.alloc('ulong');

if (fsuipc.FSUIPC_Open(0, dwResult)) {
    var chTime = ref.alloc('ulong');
    if (!fsuipc.FSUIPC_Read(0x238, 3, chTime, dwResult) || !fsuipc.FSUIPC_Process(dwResult)) {
        console.log(chTime.deref());
    }
} else {
    console.log(pszErrors[dwResult.deref()]);
}

 

Edited by nupp
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.