Author Archives for Kevin Cloutier

















When we want to reboot the JNIOR from our Java application we call the command line reboot command.  To call to the command line we use the ConsoleProcess class.  Since there will not be any user to confirm the reboot we need to use the -f command to force the reboot.

        try {
ConsoleProcess consoleProcess = new ConsoleProcess("reboot -f");
consoleProcess.waitPrompt();
} catch (Exception ex) {
throw new IOException("Error rebooting").initCause(ex);
}

Sometimes you need to find out what the IP Address of the JNIOR is that is sitting on your network.  Sometimes someone else set it up and are no longer working with you or maybe you programmed it but years have passed and you haven’t needed to access the JNIOR because it is performing its job and no attention has been needed.

There are a couple of different ways to find out the IP Address.

By far the easiest way to find the JNIOR IP Address is the use the JNIOR Support Tool.  The JNIOR Support Tool only works on Windows systems.  http://jnior.com/category/news/support-tool/ will have links to the latest, as well as previous, versions of the JNIOR Support Tool.  Once loaded and started you will be presented with the Beacon tab.  The Beacon tab will show all the JNIORs that are present on your LOCAL network that have reported.  When the Support Tool launches a broadcast is sent out asking for all the JNIORs to report their information.  Some network configurations can either help or hinder this operation.  In most cases it works as intended.  Here is a picture of the Beacon screen.  If you have more than one JNIOR shown you can use the Serial Number of the JNIOR to identify which row corresponds to your unit or you can use the identify feature to pulsate the amber LED next to the power indicator.  To perform that function you can right click on a row and select either Query | Identify or Configure | Identify from the menu.

The other way to determine the IP Address of a unit is to directly connect a serial cable to the RS-232 port.  Computers do not come with serial ports anymore so a USB to Serial adapter will be needed.  You can find them at Amazon.  Once the cable is connected, select your favorite terminal application or use the Command Line application included with the Support Tool.  The serial settings must be 115200, 8, 1, none for the baud rate, data bits, stop bits and parity respectively.  Now that the connection is set up you can press enter and the login prompt will be presented.  The default credentials are username: jnior and password : jnior.  You can now enter ipconfig to see the current network setup.

 

 

 

 

 

 

 

 

Lastly, for those who know Morse code, you can unplug the network cable and the status LED will flash Morse code representing the value of the last octet.  You must know the first 3 octets of your network.

    0 --- --- --- --- ---
    1 - --- --- --- ---
    2 - - --- --- ---
    3 - - - --- ---
    4 - - - - ---
    5 - - - - -
    6 --- - - - -
    7 --- --- - - -
    8 --- --- --- - -
    9 --- --- --- --- -

Cinema.jar 3.4.1 - Update Project - 320 KB - MD5: 74f51ea7ccb40962eb2118bf16457c50

  • Released May 28 2019

! Fixed a bug where the watchdog was no longer working. In the Cinema application crashed it would not be restarted.

Cinema.jar 3.4.0

Cinema 3.4.0 - Update Project - 320 KB - MD5: 63b627ede9c8a79710ddb3d7fd3ca852

  • Released May 16 2019

+ Allow you to query the temperature sensor via a HTTP Request.  A JSON representation of the device will be returned.

As of now the only available devices are Type28 and Type7E...

Type28 is the temperature probe and Type7E is the environmental sensor.

To enable this you will need to set the AppData/Cinema/WebServer/Port registry key. The JNIOR will need to be rebooted after this key has been changed. In this example I chose 8081. Port 80 or 443 is normally the default web server port. This web server port is an additional web server that cinema is hosting to handle these types of requests.

Cinema 3.4.0 - Update Project - 320 KB - MD5: 63b627ede9c8a79710ddb3d7fd3ca852

  • Released May 16 2019

+ Allow you to query the temperature sensor via a HTTP Request.  A JSON representation of the device will be returned.

As of now the only available devices are Type28 and Type7E…

Type28 is the temperature probe and Type7E is the environmental sensor.

To enable this you will need to set the AppData/Cinema/WebServer/Port registry key. The JNIOR will need to be rebooted after this key has been changed. In this example I chose 8081. Port 80 or 443 is normally the default web server port. This web server port is an additional web server that cinema is hosting to handle these types of requests.

  • Fixed a bug that stopped the serial port from being read if an Ethernet connection was disconnected. This appears to be a bug that was introduced in version 5.3.
  • Moved the serial configuration to take advantage of the AUXSerial and COMSerial settings that JANOS uses.

Release Date: May 10 2019

Serial to Ethernet 6.0 - Update Project - 41 KB - MD5: d06bd5279d05546652b56faf427cc676

Serial To Ethernet 6.0 - Application File - 44 KB - MD5: fd897cf50763a56e7f4828dac566b933

MODBUS is a communications protocol used to communicate between a master and a slave or several slaves. The JNIOR implements MODBUS TCP. MODBUS TCP is the form for this protocol over the Ethernet network. The JNIOR acts as a slave by accepting requests and forming responses. Since Ethernet networks call devices clients or servers, the JNIOR is a server. Therefore the JNIOR has an application called MODBUS Server to handle the MODBUS TCP requests.

The MODBUS Server application is NOT enabled by default. It must be enabled before MODBUS masters or clients can send requests to the JNIOR. Once enabled the JNIOR will begin listening to TCP connections on port 502.

To enable the MODBUS Server you should go to the DCP (Dynamic Configuration Page).

Then navigate to the ‘Configuration’ tab.

Now, select ‘Applications’ halfway down the left side. Make sure the MODBUS Server application is checked

Reboot the JNIOR.

You can then optionally make a telnet connection to verify. The ps command to make sure the modbusserver application is running. Then you can use the netstat command to see that port 502 is listening.

Pronounced “jump”, the JMP protocol is the JANOS Management Protocol. It will be available in JANOS 1.8.

The JMP protocol shares the messaging JSON structure that is used by the DCP (Dynamic Configuration Page) and the web-socket protocol but on port 9220, by default.

To make processing easier we wrapped the JSON message in a two element JSON Array.

[ number, object ]

Where number is the size in bytes/characters of the JSON object that follows.

Doing this relieves us of needing to count braces to see when an entire JSON message was received. To parse the structure we can do the following:

  1. Look for the opening ‘[‘.
  2. Then process numeric values until a ‘,’ is found. White-space is ignored.
  3. White-space is again ignored and N bytes are read.
  4. Finally remaining white-space is ignored and the trailing ‘]’ confirmed.

If the numeric value is invalid, the comma missing or the trailing ‘]’ bracket not found, the entire message is to be ignored. The extracted JSON Object can then be validated as well.


Many times the best way to send diagnostic information to INTEG is to send us a Snapshot. A Snapshot is a zip file containing all of the files from the JNIOR.

When a Snapshot is taken the Support Tool will make a telnet connection, run a few diagnostic commands and then download all of the files. The diagnostic commands that are executed will be logged to the snapshot.log file.

There are two commands that will generate files that are not normally in the file system.

The first in the iolog command. The iolog command will generate a jniorio.log file. This file shows the past 512 digital input transitions as well as the past 512 relay output transitions. Up to 16 relay outputs will be shown in the log. The relays on the expansion modules will be logged as well.

The second command is the netstat -c command. This command generates a network capture file in the temp directory. The network capture file can be loaded in a desktop application called wireshark. This file will grow up to 512Kb. The duration of time covered by the file depends on the amount of traffic that the JNIOR handles. Optionally filters can be applied to the capture buffer to limit the types of traffic that are logged.

To take a snapshot follow these steps:

  1. Open the Support Tool. Go to the Snapshot tab.
  1. Click on ‘Take Snapshot’.
  1. Answer ‘Yes’ to the Snapshot confirmation dialog
  1. Select the JNIOR you want to take a Snapshot from and click ‘Ok’.
  1. Once your snapshot is compete find it on the left. It should be made visible once it is complete. Right click on the Snapshot file and select ‘Show in folder’. You could also expand the zip archive in the tree view or double click it to open in your loaded Archive application.

It’s been 5 months since the release of 1.7.1. We finally had a reason to touch JANOS. We implemented the JMP protocol. JMP (JANOS Management Protocol) is the same JSON messaging structure that is used in our weboscket protocol.

If you are going, please stop by and visit us at booth 2615A in the Augustus Ballroom.

New for this year are some software updates as we continue to advance the JNIOR automation controller to handle more devices, more communication protocols and to be more robust than ever!  We continue to expand our capability to control LED strip lights, LED down lamps and DMX devices and provide more ways to monitor temperature and humidity.  Integrating the JNIOR with various third party systems such as Q-SYS, Barco, Dolby, Christie, etc. will be getting easier.

Bruce, Kevin  and I will be in our new booth.  If you want to set-up an appointment to meet with us at the show, please reply to this email with a date and time good for you.

Follow INTEG on Twitter for updates: @integpg

This is the first use of our new email system for staying in contact with our customers.  We will be using it to send notices about software updates, new products, etc.  If you were added by mistake or do not want to be on the list, then please reply to this email and we will remove you immediately.  If you know of anybody who would like to be added to our list, please forward this email to them so they can send me their contact information and approval.

See you in Vegas!

The JNIOR Control Panel is shipped with a ‘click’ sound that plays when a switch is pressed. This gives immediate feedback to the user that the panel has power and that the software is running normally and is ready to accept the press. There are times when the panel is used in a situation where the ‘click’ may not want to be heard. In this situation we may want to turn off that sound. The following application will accomplish this goal.


To run this application you need to download it from the button and load it on your JNIOR. Applications are generally loaded in the flash directory. To run it simply type the command as you see it above.

ControlPanel Applicaiton - 7 KB - MD5: c573b4c989ea0380729fecae5283e937

In the following code you will notice two classes. The main class of interest here is the ControlPanel class. This class will load the arguments into a ParameterGroup class so that we can process different commands at some point as well as there specific options. For now our command line is pretty simple but we set this application up for the future.


package com.integ;

import com.integpg.sensor.SensorPort;
import com.integpg.system.JANOS;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;

/**
 * This application will allow you to set the volume of the control panel click
 */
public class ControlPanel {

    private static final String USAGE_STRING = "CONTROLPANEL\n\n"
            + "Options:\r\n"
            + "  -VOLUME volume     Sets the volume level to a value between 0% and 100%\n"
            + "\n"
            + "Set options for the control panel";



    public static void main(String[] args) {
        // load the arguments into our parameters class
        ParameterGroups parameters = new ParameterGroups(args);

        // if the paremters are empty or there is a -help parameter then print the usage string and exit
        if (parameters.isEmpty() || parameters.containsParameterGroup("help")) {
            System.out.println(USAGE_STRING);
            return;
        }

        // go through each parameter and process it
        while (parameters.hasMoreParameters()) {
            String parameterGroupName = parameters.getNextParameterGroup();
            ArrayList parameterOptions = parameters.getParameterOptions(parameterGroupName);

            switch (parameterGroupName) {
                case "volume":
                    try {
                        // process set volume
                        processSetVolume(parameterOptions);
                    } catch (Exception ex) {
                        System.out.println(ex.getMessage());
                    }
                    break;

                default:
                    System.out.println("unknown parameter: " + parameterGroupName);
                    return;

            }
        }

    }



    private static void processSetVolume(ArrayList options) {
//        ArrayList volumeArguments = _parameters.get("volume");
        if (0 == options.size())
            throw new RuntimeException("must specify a volume parameter between 0% and 100%.");

        int volume;
        try {
            // get the volume from the arguments.  allow the user to enter a double but 
            // save the integer part
            volume = Double.valueOf(options.get(0)).intValue();
            if (0 > volume || 100 < volume) throw new Exception();
        } catch (Exception ex) {
            throw new RuntimeException("invalid volume specified: '" + options.get(0)
                    + "', volume parameter must be between 0% and 100%.");
        }

        // go through the external devices and set the volume for any connected control panels
        for (long externalModuleAddress : getExternalAddresses()) {
            // get a string representation of the address
            String addressString = getAddressString(externalModuleAddress).toUpperCase();

            // determine the type of module and handle accordingly
            if (0xfa == (externalModuleAddress & 0xff)) {

                try {
                    byte[] writeBlock = getSetVolumeWriteBlock((int) (volume * 2.55));
                    SensorPort.writeDeviceBlock(externalModuleAddress, writeBlock);

                    // lets print the result to the screen as well as the syslog
                    String result = String.format("Panel at %s set volume to %d percent", addressString, volume);
                    System.out.println(result);
                    JANOS.syslog(result);
                } catch (IOException ex) {
                    throw new RuntimeException(
                            String.format("unable to write to the control panel: %s.", addressString));
                }
            }
        }

    }



    private static long[] getExternalAddresses() {
        try {
            // query the unit for an array of external module addresses
            return SensorPort.externalDeviceList();
        } catch (IOException ex) {
            throw new RuntimeException("unable to get external device list.");
        }
    }



    private static String getAddressString(long address) {
        String addressString = "0000000000000000" + Long.toHexString(address);
        return addressString.substring(addressString.length() - 16);
    }



    private static byte[] getSetVolumeWriteBlock(int volume) {
        // the write block for the control panel is 20 bytes
        byte[] bytes = new byte[20];

        // to set the volume we only need to set the command byte and the audio volume byte
        bytes[10] = 4; // set audio volume command
        bytes[11] = (byte) volume; // audio volume level

        return bytes;
    }
}


/**
 * A class for interpreting command line arguments into parameter groups
 */
class ParameterGroups {

    private final Hashtable> _parameters = new Hashtable<>();
    private Enumeration _enumeration;



    public ParameterGroups(String[] args) {
        // parse the arguments
        ArrayList options = null;
        for (int i = 0; i < args.length; i++) {
            String arg = args[i].toLowerCase();

            if (arg.charAt(0) == '-') {
                while (arg.charAt(0) == '-') {
                    arg = arg.substring(1);
                }
                options = new ArrayList<>();
                _parameters.put(arg, options);

            } else if (options != null) {
                options.add(arg);

            } else {
                System.out.println("Illegal parameter usage");
                return;

            }
        }
        _enumeration = _parameters.keys();
    }



    public boolean isEmpty() {
        return 0 == _parameters.size();
    }



    public boolean containsParameterGroup(String paramterGroup) {
        return _parameters.containsKey(paramterGroup);
    }



    public String getNextParameterGroup() {
        if (null == _enumeration) _enumeration = _parameters.keys();
        if (_enumeration.hasMoreElements()) {
            return _enumeration.nextElement();
        } else {
            return null;
        }
    }



    ArrayList getParameterOptions(String parameterGroupName) {
        return _parameters.get(parameterGroupName);
    }



    boolean hasMoreParameters() {
        return _enumeration.hasMoreElements();
    }

}


Once the ParameterGroups class has been instantiated with our command line arguments we loop through each parameter group. When we find the “volume” parameter group we call processSetVolume() and pass in the parameter options.

        // go through each parameter group and process it
        while (parameters.hasMoreParameters()) {
            String parameterGroupName = parameters.getNextParameterGroup();
            ArrayList<String> parameterOptions = parameters.getParameterOptions(parameterGroupName);

            switch (parameterGroupName) {
                case "volume":
                    try {
                        // process set volume
                        processSetVolume(parameterOptions);
                    } catch (Exception ex) {
                        System.out.println(ex.getMessage());
                    }
                    break;

                default:
                    System.out.println("unknown parameter: " + parameterGroupName);
                    return;

            }
        }

Now that we are inside the processSetVolume() method we need to validate the options provided. We make sure that a volume was provided and that it is a valid number between 0% and 100%.




    private static void processSetVolume(ArrayList<String> options) {
//        ArrayList<String> volumeArguments = _parameters.get("volume");
        if (0 == options.size())
            throw new RuntimeException("must specify a volume parameter between 0% and 100%.");

        int volume;
        try {
            // get the volume from the arguments.  allow the user to enter a double but 
            // save the integer part
            volume = Double.valueOf(options.get(0)).intValue();
            if (0 > volume || 100 < volume) throw new Exception();
        } catch (Exception ex) {
            throw new RuntimeException("invalid volume specified: '" + options.get(0)
                    + "', volume parameter must be between 0% and 100%.");
        }

...


Now that the options have been validated and we processed the assigned volume we are ready to write to the connected control panels. We loop through each connected panel and check to make sure it is a Control Panel which is type 0xFA. If it is a Control Panel we can get the write block and send it to the Sensor Port.


        // go through the external devices and set the volume for any connected control panels
        for (long externalModuleAddress : getExternalAddresses()) {
            // get a string representation of the address
            String addressString = getAddressString(externalModuleAddress).toUpperCase();

            // determine the type of module and handle accordingly
            if (0xfa == (externalModuleAddress & 0xff)) {

                try {
                    byte[] writeBlock = getSetVolumeWriteBlock((int) (volume * 2.55));
                    SensorPort.writeDeviceBlock(externalModuleAddress, writeBlock);

                    // lets print the result to the screen as well as the syslog
                    String result = String.format("Panel at %s set volume to %d percent", addressString, volume);
                    System.out.println(result);
                    JANOS.syslog(result);
                } catch (IOException ex) {
                    throw new RuntimeException(
                            String.format("unable to write to the control panel: %s.", addressString));
                }
            }
        }

Got a MODBUS device that you want to publish its data to the cloud?  Use the JNIOR and the MODBUS to MQTT application.

MODBUS is a protocol that many legacy systems use.  MQTT is new and works very well to publish data to any MQTT broker whether in the cloud or hosted locally.  The JNIOR can fill the gap and get that older equipment’s data from the equipment to where you need it for analysis.

Set up the MQTT broker

There are several free brokers that you can use to test with.  You can find that list here: https://github.com/mqtt/mqtt.github.io/wiki/public_brokers

Define your slaves and the tags

If your slave is RS485 then you will need to use the model 410 and set up the serial settings to match your device.

Once your setup is complete you will the the data update on the MODBUS to MQTT page.  A message will be sent around the message pump the the MQTT application to publish the data.  The data will be sent to the topic as follows with spaces in the slave name or data tag simply removed.

This application is still a work in progress so please register to leave a comment below!

Sometimes a JNIOR gets re-purposed.  A JNIOR was performing one task and now it is going to perform a new one.  You may want to clean up the JNIOR before configuring it for the new operation.  In this case we will want to sanitize the JNIOR.  To complete this task there will be two steps that will need to be performed.

First, we will need to “erase” the unit.  To do this we will execute the following command;

reboot -eraseall

After confirmation the JNIOR will erase itself.  It will be completely blank.  Only the operating system will be present.  All other software will be removed.  The title says reset to factory but the OS will still be the currently loaded version and will not revert to the version that was shipped.  The IP Address will also remain unaffected.  All other user configuration including the hostname will be cleared.

That leads into the second step.  You will need to get the software package that you wish to install and update the unit with that code.  Use the support tool and the Update tab to do this.

What is MQTT?

This is what MQTT.org says:

MQTT is a machine-to-machine (M2M)/”Internet of Things” connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium.

Here is a great intro to MQTT.  NOTE:  This application is in development and screenshot may appear different when released.  You can download the latest release here.

Load_MQTT_v1.2_16jan2019.zip - 637 KB - MD5: b33ebf0277e02a3612b8795490e1f6ec

 

Use MQTT with the JNIOR

Currently the MQTT functionality is limited but we are always looking for suggestions.  Currently will publish IO status by default.  When the JNIOR boots up and successfully connects to a broker we will report the current status of the digital IO.  Digital inputs will report state, usage meter and counter values.  Relay outputs will report just state and usage meter values.

To successfully connect to a broker you will need to have selected a broker and entered its information.  Information such as the Host URL, port number and whether the connection should be encrypted.  The JNIOR implements MQTT across a TCP connection.  The default port number for MQTT is 1883 when non-secure connection while it is 8883 when using a secured connection.  There are several public test brokers out there.  Do not use any free broker for sensitive information.  Brokers that require sign up will most likely provide a user name and password.

 

Groups!

There are two types of groups, Device Groups and Relay Output Groups.  Both of these concepts are in BETA as of version 1.2 and we are looking for feedback.

Device Groups allow JNIORs to subscribe to topics that contain the Device Group name instead of the Serial Number.  A JNIOR can be part of one or many Device Groups.  By default a JNIOR will subscribe to topics that are meant for it by Serial Number, for instance, jnior/618010001/set/...  The JNIOR may want to be part of the pump stations group for example the JNIOR will subscribe to jnior/pumpstations/set/... topics.

Relay Output Groups allow the specification of more than one relay to be affected at once.  To set relay channel 1 you can publish the jnior/SERIAL_NUMBER/set/digital/outputs/1/state = true.  But maybe you want channels 1 – 3 to be affected at once.  To do this you will define a named Relay Output Group, “lights”, for example.  Then, when the JNIOR receives the jnior/SERIAL_NUMBER/set/digital/outputs/lights/state topic all defined relays will change at once.

 

Enhance the MQTT implementation!

You can enhance the MQTT implementation on the JNIOR with a custom application.  Any topic that the JNIOR receives that is not part of our native implementation will be posted to the message pump for the consumption by another application.  A custom application may also put topics with payload data to the message pump to be published by the MQTT application.  This way the MQTT application performs the protocol logic while the custom application can worry about the logic.

  • Watchdog no longer causes reboot from foreground execution
  • REGEX Alternation ‘|’ has been corrected to properly work in Group
  • Corrected NULL Pointer write issue when a Group which employs alternation appears at the start of a REGEX expression
  • Resolved message pump memory issue relating to process termination
  • Expand the channel range for setOutputRelay() from 0-11 to 0-15
  • Corrected network capture filtering when an IP address is to be excluded
  • Supports networks using Jumbo Frames
  • Eliminated assertion associated with improper use of ‘%n’ in System.out.printf.

JANOS 1.7.1 - UPD - 870 KB - MD5: 70bc5f3d4ec311786fe304c4e447595b

All in One 1.7.1 - Update Project - 2 MB - MD5: b88a8d86302d867835a50e8f699edcad

release notes

The JniorWebSocket Library was started as an example project.  It has not had much use here in-house and therefore the testing has been limited.

Here is a quick application that demonstrates how to instantiate multiple JNIOR WebSocket objects.  Each Object is added to a tree control so that they may be interacted with individually.  So far I have added the ability to add and remove, connect and disconnect and pulse output 1.  This application can be easily extended to manage multiple JNIORs and perform many different tasks.

Here are 2 links.  The first is a link to the Visual Studio project for the library.  The second link is a zip file containing the example described above.

C# WebSocket Example - 6 MB - MD5: fe1be1e450c2772a16d090a0d9c37f99

MultipleJniors-1.zip - 1 MB - MD5: 26485d581f00d9c5985db3e7f481e551

 

Here is a very simple example of how we can use websockets in a client browser to interact with the JNIOR.  This example will demonstrate how to register a few event callbacks, connect, and display the messages that are received from the JNIOR.  To force a monitor message to get sent we added an inversion checkbox for Digital Input 1.  When the Inversion state changes the input acts as though an electrical signal has forced the state change.

The WebSocket connection now behaves like any other bi-directional TCP Socket.  All of the functionality of the JNIOR protocol has been implemented in the WebSocket protocol.  The binary implementation has been replaced by JSON.  This not only makes it easier to code and debug but it is more extensible.

Below we have a zip file containing a demo page.  The page shows the incoming JSON messages in the lower part of the page.  The upper part of the page contains a button that will invert input 1 in software thus simulating the input receiving an electrical state change.

The javascript for our demo page is listed below

        // or comm object.  The communication will be established to the device that serves this page.
        _comm = new Comm();


        // called when the connection is successfully opened
        _comm.onopen = function () {
            logToBody('comm opened');
        };


        // called when the connection closed
        _comm.onclose = function () {
            _loggedIn = false;
            logToBody('comm closed');
        };


        _comm.onerror = function (error) {
            logToBody('comm error: ' + error);
        };


        // called when there is an error
        _comm.onmessage = function (evt) {
            var messageJson = JSON.parse(evt.data);
            logToBody('comm message: ' + JSON.stringify(messageJson));
        };


        // called when the page has been loaded
        window.onload = function () {
            logToBody('init comm');
            _comm.connect();
        }


        // a function to create a div with a timestamped message to the messages section of the page.
        // The div will be prepended so that is is at the top of the section.
        var logToBody = function (message) {
            var el = document.createElement('div');
            el.innerHTML = new Date().toLocaleString() + ': ' + message;
            el.style = 'white-space: nowrap';
            var messagesElement = document.getElementById('messages');
            messages.insertBefore(el, messages.firstChild);
        };


        // called when the user clicks the inversion checkbox
        function invert(checkbox, channelNumber) {
            var registryWriteJson = {
                "Message": "Registry Write",
                "Keys": {}
            };

            registryWriteJson.Keys["IO/Inputs/din" + channelNumber + "/Inversion"] = checkbox.checked.toString();
            _comm.sendJson(registryWriteJson);
        }

wsdemo.zip - 6 KB - MD5: 7f19c6f6a69e39fc795b88444fddfff2

To run the demo simply place the downloaded .zip file in the flash/www folder on your JNIOR.  Then open your browser and navigate to http://[IP_ADDRESS]/wsdemo.

Using the zip file is taking advantage of another great feature of the JNIORs web server. A whole web application can be served out of a single zip file. This makes distribution and file management a lot easier.

The watchdog is a very powerful concept. Wikipedia says:

watchdog timer (sometimes called a computer operating properly or COP timer, or simply a watchdog) is an electronic timer that is used to detect and recover from computer malfunctions. During normal operation, the computer regularly resets the watchdog timer to prevent it from elapsing, or “timing out”. If, due to a hardware fault or program error, the computer fails to reset the watchdog, the timer will elapse and generate a timeout signal. The timeout signal is used to initiate corrective action or actions. The corrective actions typically include placing the computer system in a safe state and restoring normal system operation.

The sample below is very basic. You will need to adjust the duration and location of the watchdog for your application.

package com.integ.watchdogsample;

import com.integpg.system.JANOS;
import com.integpg.system.Watchdog;

public class WatchdogSampleMain {

    public static void main(String[] args) throws InterruptedException {
        JANOS.syslog("WatchdogSample started");

        // create a watchdog that will reboot the jnior if the watchdog is not fed once every 5 seconds
        Watchdog watchdog = new Watchdog("WatchdogSample");
        watchdog.setAction(Watchdog.WDT_REBOOT);
        watchdog.setDuration(5000);
        watchdog.activate();
        JANOS.syslog("WatchdogSample activated");

        // loop for 30 seconds.  we will feed the watchdog in this loop.  when the loop stops the watchdog will timeout and reboot the jnior.
        long loopExpiration = System.currentTimeMillis() + 30000;
        while (loopExpiration > System.currentTimeMillis()) {
            System.out.print(".");
            // feed the watchdog
            watchdog.refresh();
            // sleep for a second
            Thread.sleep(1000);
        }

        // now that the loop is finished.  the unit will reboot soon.
        JANOS.syslog("WatchdogSample loop finished");
    }

}

This is what we see in the log after the unit has come back up.

CODE: Select All


01/15/19 08:37:36.361, FTP/10.0.0.27:62888 uploaded /flash/WatchdogSample.jar [115.3 kbps]
01/15/19 08:37:44.081, WatchdogSample started
01/15/19 08:37:44.203, WatchdogSample activated
01/15/19 08:38:14.307, WatchdogSample loop finished
01/15/19 08:38:18.451, ** Assertion: WatchdogSample watchdog triggered reboot (Line 1278)
01/15/19 08:38:18.483, ** Terminating: System
01/15/19 08:38:20.971, ** Reboot on assertion: WatchdogSample watchdog triggered reboot (Line 1278)
01/15/19 08:38:20.997, -- JANOS 410 v1.7.1 initialized (POR: 1546)

Here are the options that are available to choose from when the watchdog expires.

 

WDT_REBOOT

This is the default action. Expiration of the watchdog timer causes the unit to reboot.

 

WDT_APPLICATION

This action indicates that a watchdog timer expiration is to be handled by the application itself. The system takes no action.

 

WDT_TERMINATE

When the watchdog timer expires the system will terminate the application.

 

WDT_BREAK

This interrupts the current application (similar to Ctrl-C interruption) when the watchdog timer expires.

 

WDT_RESTART

When the watchdog timer expires this will interrupt the current application and restart it.

 

WDT_MESSAGE

When the watchdog timer expires a WM_WATCHDOG (0x11) message will be sent through the system message pump. The content contains the text associated with the watchdog.

 

WDT_EVENT

Watchdog timer expiration will notify the first thread in the application that is waiting  for notification using waitOnWatchdogNotify().