Jump to content
The simFlight Network Forums

Best way to make browser interface with FSUIPC?


Firefly
 Share

Recommended Posts

Paul, this is working great! And so far is faultless when doing everything locally (on my computer). The only issue I have is, accessing this from various devices On my network fails, I think it requires a secure websocket (wss), could this be an option at all?

well I’m assuming it does as I can’t make connections from devices on my network, even using your website. Tested with chrome and safari.

EDIT: Looks like this is a windows firewall issue after all!

Thanks 

Link to comment
Share on other sites

wss shouldn't be necessary - and doing the encryption will just take extra resources. Would only be for security purposes but there isn't much point when you are just on a home LAN. 

If it only listens on 127.0.0.1 it will only work locally, but if you select to listen on the LAN IP it works from other computers. The only problem I had was that I had to run the program as Administrator in order to be allowed to listen on the LAN IP. Can that changed?

Normally you can also set a program to listen on 0.0.0.0 which means any IP can connect to it...

Otherwise I'm looking forward to test this out more as soon as I get a chance!

Link to comment
Share on other sites

Hi Firefly,

Quote

The only problem I had was that I had to run the program as Administrator in order to be allowed to listen on the LAN IP. Can that changed?

It can't be changed from my code. It's the Windows security that's blocking it.

If you don't want to run as admin you can grant permissions to your user account to use a particular URL. The only way I've found to do this is via the command line: (note you'll need to run the command line as admin, and you need use the http version of the url).

Example for using 192.168.0.1 port 2048

netsh http add urlacl url=http://192.168.0.1:2048/fsuipc/ user=DOMAIN\user

Your user account will be able to use the URL without running as admin. But it will also block you from using all other URLs (including localhost), unless you register them in the same way.

To delete the permissions use:

netsh http delete urlacl url=http://192.168.0.1:2048/fsuipc/

Paul

Link to comment
Share on other sites

Hi Paul,

I will take my words back - I think we do need an option for wss after all. If the web page we implement this on is https the browser does not allow using an insecure socket connection. I ran into this issue when trying to inject a little script into the Skyvector map to show aircraft position there... 🙂

Allan

Link to comment
Share on other sites

There is now an installer ready that includes the WebSocket server + integration into FSUIPC7 (via an Add-ons menu entry). You can download from here:

 
There is an issue if the WebServer is already running when FSUIPC7 is started as it currently doesn't check for this. I may add this at a later date.
Also, there is currently no indication if the WebSocket server is running or not (apart from entries in the log). I think I'll update the FSUIPC7 title bar to include this information at some point. 
 
Let me know if you have any issues or suggestions.
 
John
Link to comment
Share on other sites

Hi everyone,

I've just released version 0.2.0 of the server.

Changes and additions are as follows:

  • Added option to use SSL (wss://). Requires you have an SSL certificate from a trusted issuing authority installed, and bound to the port you are using
  • Default address for new installations is now 'localhost' rather than 127.0.0.1
  • Website now supports the browser's back and forward buttons
  • Browser bookmarks will now deep-link to the selected page
  • Added payload commands to more easily read and write payload station and fuel tank data.

Paul

Link to comment
Share on other sites

6 minutes ago, Paul Henty said:

I don't have MSFS so I assumed I couldn't install/start FSUIPC7, but I just found that I can.

Yes, with FSUIPC7 now being a stand-alone exe rather than a dll, you don't need to have MSFS installed to install or run FSUIPC7. But of course, doesn't normally make much sense doing this!

7 minutes ago, Paul Henty said:

I tested with version V0.2.0 (0.1.0 threw an error on shutdown). All looks good including starting, shutting down, autostart.

Ok, thanks, I'll update the installer to include V0.2.0 and release sometime next week...once I've updated the FSUIPC7 user manual.

I'll also update the FSUIPC6 installer to include this, although I'm not sure yet if I'll add the start/stop/etc integration. I may do that at a later stage, via menu items in the P3D Add-on drop down menu entry, but that will depend if needed (i.e. requested). 

Regards,

John

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Hi Paul, first of all... thanks for jumping onto the Websocket-Train. 🙂

I tried to approach something similar with https://gitlab.com/joeherwig/portable-sim-panels-fsuipc-server which is used for https://github.com/joeherwig/portable-sim-panels
But It seems, i should investigate into the new Websocket-Server you provided.

What is essential is that only updated data is sent to the subscribers, as registering on events of course is a performance-bottleneck if you're receiving information which you don't need, as they did not change.
May i suppose, that this feature is already there?

And one more suggestion...
If we anyway have a "list" of FSUIPC offsets, there types and calculations... Wouldn't it be a good idea, to provide that already in the right format (JSON array), so that users can just import that without the need of fiddling around with the right types and conversions.

I'm sure based on the documentation Pete and John are doing anyway, it is also possible to render it into JSON right?

Thanks a lot!

        Joe


 

Link to comment
Share on other sites

Hi Joe,

Quote

What is essential is that only updated data is sent to the subscribers, as registering on events of course is a performance-bottleneck if you're receiving information which you don't need, as they did not change.
May i suppose, that this feature is already there?

Yes. Offsets can be registered in groups. An update for the group is only sent to the client when there are changes to any of the offsets in that group. Additionally there is an option per group to only include data from offsets that have changed since the last update was sent. 

This give two methods of consuming data, one suitable for real time displays and another for event driven applications like flight logs.

Quote

Wouldn't it be a good idea, to provide that already in the right format (JSON array), so that users can just import that without the need of fiddling around with the right types and conversions.

The types are handled (as in string, int, float etc). The unit conversions are not. That still needs to be done by the client (except for Lon and Lat which are done for you).

While it's possible to add unit conversion on the server side, it's a lot of manual work given the number of offsets. In the PDF offset lists the formulas are embedded in blocks of text and are not in a standard format so it makes it difficult to pull them out programmatically.

There will be helper modules added in the future (like in my .NET DLL for FSUIPC) that will make it easier to deal with certain data. The only one I've added at the moment is Payload and Fuel services. This allows reading and writing of the payload and fuel levels directly in common units (lbs/litres/gallons/kg etc). 

Paul

 

Link to comment
Share on other sites

  • 4 months later...

Hi Paul Henty and John Dowson

That are fantastic news since I have begin planning my annunciator implementation of my own design cockpit of the 737.

I have bought Prosim 737 and I am needing somwhere to read and see which annnuciatorn wich is active .... . My idea now is having a simple monitor running a Desktop app connected to a node server which will listen for offsett from FSUIPC Webbsocket?

If I am not all wrong I think the webbsocket is implemented in FSUIPC7 for FS2020 🙂

Best regards Fredrik Hjärpe

Link to comment
Share on other sites

  • 1 month later...

@Paul Henty

Is there a way I can send a control like I can do in the FSUIPC UI (eg. 66241 - TOGGLE_MASTER_BATTERY) through your websocket server?

Also, regarding Lvars - I guess I should be able to read/write those with the new FSUIPC 7.2 by configuring them in the .ini file?

Greetings, Allan

Link to comment
Share on other sites

Quote

Is there a way I can send a control like I can do in the FSUIPC UI

Yes you can create 2 offsets (best done in a separate declare request). They must be in this order:

0x3114 - uint 4 - Parameter
0x3110 - uint 4 - Control

In the offfset.write request, set your control number (e.g. 66241) and any parameter. (set 0 if there is no parameter like for TOGGLE_MASTER_BATTERY).

Quote

I guess I should be able to read/write those with the new FSUIPC 7.2 by configuring them in the .ini file?

Yes, I think you assign them to free offsets and then use the offsets and normal.

For FSUIPC4,5 and 6 I would need to update the websocket server for LVars as the offset trick is not available for those version. 

Paul

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
Hi, my name is Manuel. First of all I want to congratulate you for the incredible work you are doing.
I am doing an ACARS for a virtual airline. Everything in JS.
My question is the following:
Is there a way to send two commands at the same time?
I explain. I am already using the command: offset.declare and as explained by Paul's website, I send all the offset I need to track. But I would like to also be able to send the command payload.read since it gives all the information ready to read without the need to do calculations and conversions.
I already tried sending the two commands separately and joining them on the switch as explained in the documentation on the web. The problem is that when reading the payload it disconnects from the websocket and I need to keep tracking the rest of the parameters.
I hope you can help me with this if possible.
Thank you very much again and sorry if my English is bad I am using google translator.
Edited by Manuel Lence
Link to comment
Share on other sites

Hi Manuel,

Quote

The problem is that when reading the payload it disconnects from the websocket

The server doesn't close the socket after a single request. It remains open for multiple requests until you close it.

If you're seeing the socket being closed then it's probably your code that's closing it unintentionally.

Look for places in your code that you calling ws.close(). Check that this isn't being called by mistake when your handling the response from the server. (e.g. is a case statement falling through with no 'break'?)

It might help if you post your code so I can try it here.

Paul

Link to comment
Share on other sites

Hi Paul, thanks for answering.

The ws.close () is only executed with the finish button. I'm sure of that because if I send a single command it still works.

I show you the part of the code:

        ws.onmessage = function (msg) {
    
            var response = JSON.parse(msg.data);
    
            if (response.success) {
                if(response.name == 'myOffsets')
                {
                    showOffsetValues(response);
                }
                else if(response.name == 'myPayload')
                {
                    showPayloadValues(response);
                }
            }
        };

And this is where I declare the offset I need and send to the websocket:

    this.iniciar = function () {
        var data = {
            command: 'offsets.declare',
            name: 'myOffsets',
            offsets: [{...CODE...}
            ]
        }
        ws.send(JSON.stringify(data));
 
        var request = {
            command: 'offsets.read',
            name: 'myOffsets',
            interval: 1000
        }
        ws.send(JSON.stringify(request));
 
        var PayloadSend = {
            command: 'payload.read',
            name: 'myPayload',
            weightUnit: 'Kg',
            volumeUnit: 'l'
        }
        ws.send(JSON.stringify(PayloadSend));
}

Thanks for your time.

Edited by Manuel Lence
Link to comment
Share on other sites

  • 2 months later...

Hi Paul

So above you mentioned how to send controls and also deal with L:Vars. So now the inevitable question comes - how can I activate H:Vars? They are not assigned to an offset. I don't see much in the manual for advanced users on how to use the H:Vars...

I don't yet have a use for it yet but just wondering about even executing Calculator Code in the WASM module?! Is that something that could be dealt with if needed?

-Allan

Link to comment
Share on other sites

Hi Allan,

I think the only way to set HVars is via the WASM module, so it wouldn't be possible with the SocketServer at the moment.

My FSUIPCClient DLL (used by the socket server) now has support for accessing LVars/HVars directly from the WASM module. It seems to be stable now so next week I will expose this via the Socket Server.

This will mean you won't need to assign LVars to offsets anymore. You'll have direct access to them with something like "lvar.request". You'll also be able to set HVars and execute calculator code.

This will only be for MSFS/FSUIPC7.

Paul

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.