Set Initial Output States on Boot

Written on: July 1, 2021 8:59 am

When the JNIOR Boots up we may want to define an initial state.  Sure, the JNIOR WebUI gives you a way to configure this for the Internal Outputs.  Setting a value of ZERO causes the relay to get close while a value greater than ZERO is the number of milliseconds to pulse the relay for.

But what about the Outputs on the External Modules?

An application like this is extremely easy to write.  You can set the states for up to 16 outputs using the .setOutputStates(bits, mask) in the JANOS Runtime Library.

How do we know what outputs to set you ask?  Well we will take an argument that supplies a mask containing which outputs to close.  The mask can be represented as HEX or DECIMAL.  To specify the mask in HEX we must prefix the value with 0x.  For example, flash/closeoutputsonboot 0x7 will close outputs 1, 2, and 3 when the application executes.

Here is the code for this application.

package closeoutputsonboot;

import com.integpg.system.JANOS;

public class CloseOutputsOnBoot {

    public static void main(String[] args) throws IOException {
        // make sure one argument was supplied
        if (1 != args.length) {
            // print the usage string to the stdout.  This isnt useful when the 
            // application is executed on boot.  So we will also log it to the 
            // syslog in case the argument is not supplied in the run key.   Then
            // exit with -1 indicating an error occurred.
            String usage = "MUST supply an argument that contains the "
                    + "MASK of OUTPUTS that should be closed.";

        // get the binary mask and set the ALL of the output states.  we 
        // allow the mask to be specified in HEX or DECIMAL
        int binaryMask;
        if (args[0].startsWith("0x")) {
            // HEX representation
            binaryMask = Integer.valueOf(args[0].substring(2), 16);
        } else {
            // DECIMAL representation
            binaryMask = Integer.valueOf(args[0]);

        JANOS.setOutputStates(binaryMask, 0xffff);


To get this application to run on boot we set a run key. My run key will close output 13 on boot. I chose to specify the mask in hexadecimal. This will cause the application to execute on boot for a brief period of time while is reads the mask argument and sets the outputs. Once that has been completed the application will finish.

The JAR file below can be loaded into the flash/ directory on the JNIOR.

Name Version Release Date Size MD5
CloseOutputsOnBoot.jar v1.0 Jul 01 2021 2.0 KB 774c7b1cb6a7dda818ee02c2242ada13
By | Updated On November 17, 2022 10:06 am | No Comments | Categories: , | Tags:


INTEG Process Group, inc. © 2022

Mon - Fri, 8am - 4pm EST
P: 724-933-9350
Always Available
Contact Form