Announcement

REXYGEN forum has been moved. This one is closed.
Head over to the new REXYGEN Community Forum at https://forum.rexygen.com.

Looking forward to meeting you there!
 

#1 2016-11-20 17:16:13

alex
Member
Registered: 2016-11-18
Posts: 2

HMI on Raspberry Pi

Hello,

I have two questions:

1) When you download the executive and HMI to the target (Raspberry PI), where are the .html files saved? I can't find them anywhere.

2) I want to allow only some of the HMI files to be viewed from the internet? I thought I could do this with a separate webserver (nginx) using port 8080 and copying all HTML source files to that folder. The files display fine, but they aren't actually connecting to the Rex Core (error message "connecting to WS server failed). I know I can just port forward my router to 8008, but I don't want to make all HMI files available online, only some of them.

I am using v2.50 RexDraw and v2.50 RexCore.

Last edited by alex (2016-11-20 17:16:26)

Offline

#2 2016-11-21 00:07:55

osevera
REX developer
Registered: 2015-10-27
Posts: 13
Website

Re: HMI on Raspberry Pi

Hello Alex,

1) When you download the executive and HMI to the target (Raspberry PI), where are the .html files saved? I can't find them anywhere.

There are two ways to feed the built-in webserver of RexCore with HMI (HTML) files:

  1. When you press Compile & Download button in the RexDraw all the HMI files from the HMIDir directory (see the documentation for the HMI block) are packed and downloaded as one /rex/rexcore/hmi.rex file.

  2. If you want to add some additional files (large images, some configuration files, etc.) you can copy them manually to the  /rex/www directory on the target device. These files are available as a static content independent of the current executive running on the target.

2) I want to allow only some of the HMI files to be viewed from the internet? I thought I could do this with a separate webserver (nginx) using port 8080 and copying all HTML source files to that folder. The files display fine, but they aren't actually connecting to the Rex Core (error message "connecting to WS server failed). I know I can just port forward my router to 8008, but I don't want to make all HMI files available online, only some of them.

The HMI is communicating with the target device over the WebSocket. You can serve all the HMI files from arbitrary webserver but you have to redirect the WebSocket connection. You can setup some proxy in the NGINX server or you can change the URL where the HMI is connecting to.

  • If you have HMI from the RexHMI Designer, you can simply change the 'target_url' option. (e.g. Your NGINX server is running on the 192.168.1.1:8080 so you set target_url to 192.168.1.1:8008, which is where the webserver of RexCore is listening)

  • If you use WebBuDi or WebWatch you have to enable the script tag and call the REX.HMI.setTargetUrl function in each generated *.html file in the HMIDir directory. (See the example bellow)

    1. Create you HMI

    2. Edit all the *.html file in the ./hmi/ directory

    3. Disable the auto-generation of the HMI by unchecking the GenerateWebWatch and GenerateRexHMI option in the HMI function block

    4. Compile and Download your executive

<script type="text/javascript">
    REX.HMI.init = function(){
        REX.HMI.setTargetUrl('ws://192.168.1.1:8008',true);
    }
</script>

Offline

#3 2016-11-29 17:33:03

alex
Member
Registered: 2016-11-18
Posts: 2

Re: HMI on Raspberry Pi

Awesome, your REX.HMI.setTargetUrl example did the job, except I had to change it to the following to eliminate all errors:

REX.HMI.setTargetUrl('ws://192.168.1.1:8008/rex',true);

Thanks for your help.

Offline

Board footer

Powered by FluxBB