JANOS remembers the last 16 unique commands entered during a single session. This allows you to user the UP_ARROW and DOWN_ARROW keys to scroll through the recent commands. A command can easily be re-executed by scrolling back to it and hitting ENTER. A prior command can be first edited. That may be useful when wanting to add an option to its execution.

The HISTORY command displays the recorded commands. They are numbered but the HISTORY command does not give you the means to select from the list.

bruce_dev /> history
1: history
2: whoami
3: help passwd
4: passwd tech
5: passwd
6: users
7: useradd -cd tech
8: useradd
9: userdel
10: usermod
11: help usermod
12: help

bruce_dev />

Note that in addition to scrolling using the up and down keys you can use the TAB key to retrieve from the list.

TAB when used at the beginning of the command line offers valid commands in addition to file names. It includes those from the recent HISTORY. If you want to recall the ‘help usermod’ command given the above HISTORY you can simply type ‘h’ followed by TAB until you get the line that you are seeking. Note that TAB presents options alphabetically.

The WHOAMI command can be used to verify your login. While it seems trivial this command may be useful if you walk up to an existing login and need to confirm its permissions.

bruce_dev /> whoami
 jnior       1  Administrator
bruce_dev />

A password may be changed using the PASSWD command. The PASSWD command is available to all active accounts but only an Administrator can use it to alter the password of another account by specifying the account user name.

In addition, if you are not an Administrator changing the password on another account you will be asked to enter the current password before you can provide a new password. This is an added level of security.

bruce_dev /> help passwd
PASSWD [user]

Sets the password for the user. Defaults to the current user.

bruce_dev />

The USERDEL command removes 1 or more users from the system. This is not reversible. If you are uncertain about the deletion of a user you can add the Disabled tag to temporarily close the account using the USERMOD command. Multiple users can be removed by listing the users on the command line separated by spaces. The following would remove the ‘admin’, ‘user’ and ‘guest accounts.

userdel admin user guest

Note that there is no confirmation so use this command carefully. The command has no options and you must specify at least 1 user.

bruce_dev /> userdel
USERDEL user...

Removes one or more users from the system.
Multiple users can be specified separated by spaces.

bruce_dev />

You cannot remove yourself by the way. This command is also only available to an Administrator account.

The USERMOD command allows you to add or remove user account privileges or tags.

bruce_dev /> help usermod
USERMOD user

Options:
 +A,-A          Add or remove Administrator rights
 +C,-C          Add or remove Control rights
 +D,-D          Disable or Enable the account

Modifies user privileges.

bruce_dev />

The Series 4 uses three different tags: Administrator, Control, and Disabled. These are described under the USERS command topic. Basically accounts tagged as Administrator can do everything. An account tagged for Control can only manipulate I/O status. And, a Disabled account is just that, disabled.

The USERMOD command actually violates the JANOS standard for command options. This command uses the plus sign ‘+’ as well as the dash ‘-‘ to designate an option. This is a legacy thing left over from the Series 3.

The following command disables the ‘user’ account by adding the Disabled tag:

usermod +d user

This would re-enable the account by removing the Disabled tag:

usermod -d user

Note that the USERMOD command can only modify a single user. So you cannot add a tag to a set of users. You must also specify a user.

If you are at all concerned about security the USERS command is important! The JNIOR ships with four (4) default user accounts each with an obvious password. Two (2) of those accounts are Administrators. Most customers are not aware of this. We have seen where a customer will change the password for the ‘jnior’ account and think they are good to go. In reality the ‘admin’ account remains active and accessible with the default password. The USERS command is the only way you can see what accounts are active.

The USERS command is part of JANOS and new to the Series 4. While the account situation, as far as having two (2) administrators, is the same with the Series 3 you can only see the active accounts on those older JNIORs by viewing the content of the /etc/passwd file. That file is not present on the Series 4.

Here is a default account status as shipped.

412dmx_r00 /> users
 admin       3  Administrator
 guest       0  Disabled
 jnior       1  Administrator
 user        2  Control, Disabled

412dmx_r00 />

In addition to the two (2) active administrator accounts there are two other account. Not that those are Disabled by default. JANOS allows you to disable an account without deleting it. It was not possible to do that with the Series 3. In that case the ‘user’ and ‘guest’ accounts are active.

The USERS command has no options. It lists each account and the tags associated. There are 3 possible tags:

Administrator

An account tagged as Administrator has full access to the JNIOR. An administrator can access any file regardless of its permissions. An administrator can utilize every command available at the command line and can fully configure the JNIOR. An account with the Administrator tag has access to all of the capability afforded by the Control tag.

Control

An account tagged as Control can manipulate I/O. This includes toggling relays and adjusting external module I/O settings. These users cannot configure the JNIOR and are subject to all file permissions.

Disabled

You cannot log into a Disabled account. The account still exists and can be restored at any point. This tag can be used to temporarily make an account inaccessible.

The account tags can be added or removed using the USERMOD command. Users can be added or removed using the USERADD command or USERDEL command respectively.

The MODE command is rarely used and has one specific purpose. It controls whether or not the RS-232 (COM) port at the bottom of the JNIOR next to the LAN port is to be used for boot messages and command line interaction.

Issue the MODE command without parameters and it will display the current status of the “diagnostics port”. By default it is enabled. You would disable this if you were to use that serial port as part of your application to communicate with another device. In that case any spontaneous messages or command line interception would cause your protocol communications to fail, so you disable it.

To disable the diagnostics port issue the MODE -S command. You can think of the ‘S’ option as being “Silent”.

To enable the diagnostics port issue the MODE -V command. Okay in this case the option perhaps means “Verbose”. This is the default.

Now there is an Easter Egg here. JANOS has a few undocumented command options. There are very few and most of them provide some cryptic debug information more or less for my use. But here’s one for you.

The MODE -A command is undocumented. This enables the AUX port for command line interaction. Once you issue the MODE -A command any character received on the AUX port will start a command line process there. You cannot disable this mode. It is reset on reboot.

This “feature” was added to facilitate production program and test. The builder that initially programs the JNIOR and tests all of its I/O uses a command line connection through the AUX port to test the AUX port.

Here we see that a command line process is now active on the AUX port.

bruce_dev /> ps -v
      runtime       mem  hnd stk frm     id    desc
          36.667                          0: Idle Process
           1.395    2.6K   7   9          1: Network Service
           1.320    1.3K   7  17          2: System
           0.048   34.5K   7  12          4: Command/AUX
4 total          39.547 uptime

bruce_dev />

For this to work, you must not have an application running that uses the AUX port for communications. If you have used an application on that port you may need to prevent it from running on boot and to reboot the unit. The application may program timeouts and other port features that will interfere with the command line use. The port must also be set for 115,200 baud.

In order to breath life into a being you must get its heart beating. For a generic operating system the heart is it’s multitasking capability. In developing JANOS one of the very first modules that was created was the one responsible for coordinating the execution of multiple independent processes.

Practically every microprocessor program that has been written is responsible for, and therefore juggles, more than one task. Even those that seem to be so specific so as to be focused on one single task end up responsible for two or more sub-tasks. That doesn’t imply though that every program need implement sophisticated multitasking algorithms. In most cases a simple loop need be employed to cycle through the various tasks at hand.

With a focused application a control loop is often sufficient. In this case task A, B, C, etc. are executed in sequence if they are needed. Once all tasks have been given the chance to run the loop is repeated. Depending on the needs of the application a loop may repeat as often as possible or it may have the luxury of sleeping. The latter being helpful in reducing power requirements.

The rate at which a control loop repeats is variable and dependent on the number of tasks that needs to execute in each cycle and the amount of time each task takes to complete. If there is one task that is time sensitive there can be issues. If the total time required by the other tasks that need to run delays the loop too long, the time critical task may fail. The programmer has to take this into consideration. This can be a real problem if any task becomes dependent upon an external event and must wait for an indeterminate amount of time.

When a task has to wait it is prudent to move on and let other activities be performed in the meantime. We can employ a state machine. Here we break the current task down into a set of sub-tasks where a variable is used to keep track of the current sub-task. If a task has to wait it exits allowing other tasks in the main control loop a chance to run. When the main loop returns to the task at hand, the state machine takes us back to the point where we left off. If we still have to wait we exit again otherwise we handle the next step in the current task.

With fairly complex applications, the main control loop can become complex. The programmer may need to implement some kind of priority scheme. This would increase the time allotted for a set of tasks and force others to take a backseat. Then if multiple tasks require state machine implementations the overall dynamics start to become fuzzy. The programmer suddenly finds situations where the system may behave strangely leading to tweaks and eventually a feeling of careful balance. It works but you are now cautious not to add much more to it. Not without emphasizing testing.

Consider a generic operating system such as JANOS. Here there is a spectrum of system tasks that may be optionally running. Then there can also be multiple programs developed by others (of varying skill levels) running in the system and requiring CPU time. The resulting set of tasks can be so unpredictable that a simple tasking loop is doomed to failure.

A program may need to wait on a communications channel and the third-party programmer does not realize the need to return to allow other tasks to run. At a minimum this slows the system down and suddenly the task handling network traffic might start to cause timeouts and protocol failures. You just cannot predict this let alone control it with the simple loop approach.

So rather than to even try, JANOS employed a preemptive approach right from the start. Now every task becomes a process. Each process executes within its own context. Every context is isolated from other contexts creating independent processes. A timeslice is defined. For JANOS a timeslice is 32 milliseconds. JANOS allows each process to run for up to one timeslice before forcibly moving on to another. A process can relinquish its timeslice when it is waiting on something but it cannot monopolize the CPU.

In coding JANOS the main.c program was the first created. It performs some initial configuration and starts the Process Engine. From that moment on the system became capable of executing more than one process. The main.c procedure then dubbed itself the “Startup Process”. Once it completes its required steps it renames itself as the “Idle Process” and falls into the tight wait loop. From that point forward it becomes solely responsible for collecting unused CPU time. This being the equivalent of twiddling your thumbs.

Before becoming the Idle Process mode the Startup Process initializes the Network Service. This process runs at all times and with priority to insure that all network traffic is handled properly and in a timely fashion. The Startup Process also starts the System process. The System process consists of a simple control loop executing low-priority background tasks such as logging, memory cleanup and event notification. These are the three low-level processes in the OS that run always and cannot be stopped.

Here some of the complexity becomes apparent. In addition to the three base processes that I have described we see some others. The jaccess.jar program is running. This is an application that the HoneyPot uses to create the Mirai Botnet Map web page that it serves to the public. While the Web Server process is required for you to access those pages it is likely running here because I have the DCP open in my browser. In fact the Console process there is mine as well. This results from a session in the Console tab of the DCP and that is where I executed the PS command you see above.

Finally there is a Command process running for some other random IP address. That indicates that there is a Telnet session open. On the HoneyPot those are generally from a Mirai infected host trying (unsuccessfully) to log into this JNIOR. Under JANOS there can be as many as 16 separate processes (including the Idle Process) running at one time.

So what is in the Process Engine that creates this preemptive multitasking environment? It may or may not seem complex to you. I have managed to create a preemptive environment on a variety of processors including the Z80, HP’s early entry into the minicomputer market, CP/M running on early Intel processors and many others. Notably I added this to the Dallas DS80C400 which created the multitasking capability found in the Series 3 JNIOR. The TINI OS that forms the basis of the Series 3 OS is not originally capable of multitasking. JANOS runs preemptive multitasking quite successfully on the Renesas RX63N.

To create a preemptive multitasking environment you need a few basic things. The first is a good 1 millisecond interrupt forming a process tick. You also need a way to switch program context with a minimum of overhead. And finally there needs to be a good atomic means to create a mutex (mutual exclusion object). That being a synchronization technique to control access to system resources when multiple processes are contending for them.

The main.c program during the initialization of JANOS sets up one of the timer registers in the RX63N to divide down the system clock and generate an interrupt every millisecond. The Process Engine first uses this to tally milliseconds and thereby track uptime and to create a real-time software clock. Then on every 32nd tick the Process Engine moves forward to see if another process is pending execution. In that case the context is changed and the next process is allowed to run.

The RX63N uses two stack areas. There is a User Stack which programs normally use to PUSH and POP data. The C Subroutine entry implementation also allocates local variables on that stack. For software to be re-entrant and therefore functional in such a multitasking environment it must store all of its variables on the stack. Now that can include pointers where each instance of that subroutine might allocate its own memory blocks and save the pointers. Later the route needs to release those blocks to avoid memory leaks. The point being that the “context” is really the stack content.

In addition to the User Stack the RX63N also uses an Interrupt Stack. When an interrupt occurs, for instance when the internal timer register is ready to signal 1 millisecond, The program pointer and certain critical resisters are save on the Interrupt Stack before running the interrupt service routine.

So for JANOS to change processes it simply saves the User and Interrupt stack pointers in the Process Table for the current process and then locates the next process that is ready to execute. The User and Interrupt stack pointers are updated from the Process Table for that process and we return from the tick interrupt. Ahh, but now we are not returned to where were just interrupted but to where the new task was interrupted before and so it continues. The originally interrupted process then waits for its turn to run again.

To change processes and context we swap two stack pointers. This is an extremely efficient (time wise) and low-overhead task swap. We do have to push all of the other registers onto the stack before swapping to insure and complete context swap. It happens very quickly. JANOS jumps cleanly from one process to the next without any process realizing it had been set aside temporarily.

This approach requires that we pre-assign 16 independent User Stacks and 16 independent Interrupt Stacks in the Process Table. Fortunately the RX63N has sufficient internal high speed RAM. The Process Engine initialization called by main.c gets that done before enabling the 1 millisecond tick.

Now to create a new process a PROC_create() method is provided that defines the starting point for the new process and passes a couple of useful parameters. The Web Server for instance starts at an entry point named HTTP_process(). An new entry is added to the Process Table for the new process. The name of the new process is one of the parameters supplied. The User and Interrupt stacks for the new process are initialized with content and initial values as would be expected when a return from the 1 millisecond interrupt is executed. Once everything is in order a flag for the new process is set allowing it to execute. We return from the creation routine to do other things but when our timeslice is up, the new process also proceeds from the point we defined.

If a program runs non-stop for its 32 millisecond timeslice it will be preempted. It then waits until it can continue after other tasks get their time in the sun. If a process needs to wait it can release its timeslice by calling PROC_yield(). This call generates a software interrupt that then performs the process swap and starts a new timeslice. The yielding process will continue once others have had a chance.

Often we know about how long we will need to wait. In this case we can release our timeslice for a certain number of milliseconds by calling PROC_sleep(). Here we not only allow our process to swap but also set a timer telling the Process Engine that we won’t be ready to execute for a while.

Along these lines to keep options open and flexible there is also a PROC_delayed() call. This sets the wait time so our process won’t run again until the specified time (uptime as opposed to RTC time). Add to this a PROC_pause() method that stops a process until another process specifically allows it to run again.

Finally there is a PROC_terminate() method which, like it says, terminates the process. This removes the process from the Process Table .

A process may be preempted at any time. This is likely to be in the middle of the assembly language executing a C statement. There are times when critical system structures are being read and updated. An interruption an an inopportune moment can invalidate an update and cause system issues. This is handled through the implementation of a CRITICAL SECTION.

A process can execute an ENTER_CRITICALSECTION macro. This establishes a section of code that cannot be swapped. Once the critical system structures are updated the EXIT_CRITICALSECTION macro restores normal swapping. While this seems to violate our statement earlier that the CPU cannot be monopolized, the Critical Section functionality is only available for use in JANOS system code and not by external application programs. It is not available to third party programmers. Those programs cannot monopolize the system. At least not so easily.

Critical Sections can be nested. That is just handled as a counter which is incremented upon section entry and decremented on exit. As a result there are very few situations where system interrupts must be disabled to prevent issues. This keeps the interrupt processing system ready at all times to service interrupts. Interrupts are not missed.

As a result of all this, the Web Server for example can be written without concern for anything else that may be running. It can also execute processes of its own. An example here is the PHP Scripting Engine which is started by the Web Server. This allows the Web Server to service other requests while a PHP program is compiled and then executed. Such complex interactions occur very smoothly and cleanly.

When a tick generates an interrupt only some registers are preserved on the stack. JANOS uses some inline assembly to also push R6 thru R13 and FP register. The two stack pointers are then passed to the scheduler which may or may not update them depending on what else need to run.

CODE: SELECT ALL

/* -- inline asm -------------------------------------------------------------
** inline_call_tick()
**
** Saves processor state in a consistent manner and manages the stack 
** pointers independent of C optimization effects.
** -------------------------------------------------------------------------*/
#pragma inline_asm inline_call_tick
static void inline_call_tick(void)
{
	PUSHM	R6-R13		; save balance of registers
	PUSHC	FPSW		; save FP register

	MVFC	USP,R1		; snapshot both stack pointers
	MVFC	ISP,R2
	BSR.W	_tick_proc	; perform task processing

	MVTC	R2,ISP		; update both stack pointers
	MVTC	R1,USP

	POPC	FPSW		; restore
	POPM	R6-R13
}

These are the additional registers that I mention needed to be saved.

Once the Process Engine became available the main.c proceeded to start Network and System processes as I have mentioned. Eventually in development of JANOS the Network process has to start receiving and then sending packets over the Ethernet LAN. That makes sense but we are kind of blind. That makes it difficult to develop and debug.

So the next process that we created was designed to handle command line interaction through the serial RS-232 (COM) port. The main.cprogram had been outputting notification strings on this port as the various events were occurring but we couldn’t interact with it. Just prior to becoming the Idle process the main.c program outputs a “Hit any key to login” message. We are not going to start a process for command line interaction until we know that there is someone there to use it.

This established the need for Polling Routines. A polling routine is a routine that can optionally be associated with a process class. It is called once every millisecond tick. Obviously these routines cannot do anything lengthy or they would significantly add to the overhead in the process engine. We would use this to detect an “any key” condition on the port and to then start the command line process.

So a structure for process design had started to evolve. The main.c program calls an initialization routine for each subsystem. For the command line process it calls CMD_initialize(). This initialization routine would indicate that it is “Starting command services” and issue the “Hit any key” message. Eventually when we got the network up and running it would start a Telnet server. The CMD_initialize() routine registers the CMD_polling() routine before returning. That polling routine merely checks the status of the serial port buffer and if a character is pending (the ANY key) and the command line process is not running, the CMD_process() is started.

Eventually we will use polling routines to check and handle timeouts and watchdogs among other tasks. It is a key aspect of the process engine and perhaps even a necessity.

FIND, GREP and EGREP are all aliases for the same command. These allow you to search a text file for matches to another string. For example:

HoneyPot /> find NTP jniorsys.log     
10/24/17 10:16:38.000, Clock synchronized via NTP (-5)
10/24/17 12:21:59.000, Clock synchronized via NTP (-35)
10/24/17 12:23:21.000, Clock synchronized via NTP (+5)
10/25/17 13:55:55.000, Clock synchronized via NTP (-23)
10/25/17 14:13:59.000, Clock synchronized via NTP (-5)
10/26/17 15:38:34.000, Clock synchronized via NTP (-21)
10/26/17 18:37:50.000, Clock synchronized via NTP (-52)
10/26/17 20:17:50.000, Clock synchronized via NTP (-28)
10/27/17 14:03:21.000, Clock synchronized via NTP (-27)
10/27/17 14:48:22.000, Clock synchronized via NTP (-5)
10/31/17 09:53:57.000, Clock synchronized via NTP (-43)
 .
 .
 .

This can be very useful if you are looking for a specific entry in a log file. Here is the HELP for the command. The only difference in the aliases is that the EGREP usage assumes the -E option allowing the search string to be a standard REGEX expression. It is the same as GREP -E or FIND -E.

HoneyPot /> help egrep
EGREP regex filespec

Options:
 regex          Regular Expression to match
 filespec       File specification
 -E             Use Regular Expressions (EGREP default)
 -C             Count lines
 -H             Print filespec
 -N             Print line numbers
 -I             Case-independent comparisons
 -M             Underline match

Peforms text file search.
Aliases: FIND, GREP, EGREP

HoneyPot />

The search string (or regex) is case-dependent. You can use the -I option to perform a case-independent search. For eample:

HoneyPot /> find manifest jniorsys.log     
11/22/17 08:26:27.567, FTP/50.197.34.73:64227 transferred /flash/manifest.json [116.6 kbps]

HoneyPot /> find -i manifest jniorsys.log     
11/02/17 08:28:32.943, Manifest updated.
11/02/17 08:32:43.210, Manifest updated.
11/02/17 11:31:03.541, Manifest updated.
11/20/17 07:38:17.390, Manifest updated.
11/22/17 08:26:27.567, FTP/50.197.34.73:64227 transferred /flash/manifest.json [116.6 kbps]

HoneyPot />

You will need to enclose you search string in quotes if searching for something containing a space. For example:

HoneyPot /> find -i "manifest updated" jniorsys.log     
11/02/17 08:28:32.943, Manifest updated.
11/02/17 08:32:43.210, Manifest updated.
11/02/17 11:31:03.541, Manifest updated.
11/20/17 07:38:17.390, Manifest updated.

HoneyPot />

The -C option counts the lines.

HoneyPot /> find -ic "manifest updated" jniorsys.log
 6 lines matched
HoneyPot /> 

Alright now there are 6 lines because I just updated using the MANIFEST command twice having seen that it has been a while.

HoneyPot /> find -i "manifest updated" jniorsys.log 
11/02/17 08:28:32.943, Manifest updated.
11/02/17 08:32:43.210, Manifest updated.
11/02/17 11:31:03.541, Manifest updated.
11/20/17 07:38:17.390, Manifest updated.
11/22/17 10:20:35.847, Manifest updated.
11/22/17 10:20:45.876, Manifest updated.

HoneyPot />

The -N option will include the file line numbers with the matched lines. And, if you know the case of what you are searching for you don’t need the -I option.

HoneyPot /> find -n "Manifest updated" jniorsys.log
  356: 11/02/17 08:28:32.943, Manifest updated.
  357: 11/02/17 08:32:43.210, Manifest updated.
  362: 11/02/17 11:31:03.541, Manifest updated.
  812: 11/20/17 07:38:17.390, Manifest updated.
  930: 11/22/17 10:20:35.847, Manifest updated.
  931: 11/22/17 10:20:45.876, Manifest updated.

HoneyPot />

As a general rule (with very few exceptions) options on the command line can be entered separately or combined. The may appear anywhere on the command line.

HoneyPot /> find -i "manifest updated" jniorsys.log -c 
 6 lines matched
HoneyPot />

Commands and options are not case-sensitive by the way.

The -H option not only provides the line number in the file but also includes the file specification which some error processors like to use.

HoneyPot /> find -h "Manifest updated" jniorsys.log   
/jniorsys.log[356]: 11/02/17 08:28:32.943, Manifest updated.
/jniorsys.log[357]: 11/02/17 08:32:43.210, Manifest updated.
/jniorsys.log[362]: 11/02/17 11:31:03.541, Manifest updated.
/jniorsys.log[812]: 11/20/17 07:38:17.390, Manifest updated.
/jniorsys.log[930]: 11/22/17 10:20:35.847, Manifest updated.
/jniorsys.log[931]: 11/22/17 10:20:45.876, Manifest updated.

HoneyPot />

Note that the output at the command line can be sent to a file using the traditional ‘>’ (create new file) or ‘>>’ (append to file) syntax.

HoneyPot /> find -h "Manifest updated" jniorsys.log > updates.txt

HoneyPot /> cat updates.txt
/jniorsys.log[356]: 11/02/17 08:28:32.943, Manifest updated.
/jniorsys.log[357]: 11/02/17 08:32:43.210, Manifest updated.
/jniorsys.log[362]: 11/02/17 11:31:03.541, Manifest updated.
/jniorsys.log[812]: 11/20/17 07:38:17.390, Manifest updated.
/jniorsys.log[930]: 11/22/17 10:20:35.847, Manifest updated.
/jniorsys.log[931]: 11/22/17 10:20:45.876, Manifest updated.

HoneyPot />

The Underline match option -M is interesting and unique to JANOS. This is especially useful when debugging a REGEX search. It works for any search as for example:

HoneyPot /> find -m "Manifest updated" jniorsys.log              
11/02/17 08:28:32.943, Manifest updated.
                       ----------------
11/02/17 08:32:43.210, Manifest updated.
                       ----------------
11/02/17 11:31:03.541, Manifest updated.
                       ----------------
11/20/17 07:38:17.390, Manifest updated.
                       ----------------
11/22/17 10:20:35.847, Manifest updated.
                       ----------------
11/22/17 10:20:45.876, Manifest updated.
                       ----------------

HoneyPot />

Finally, what about using REGEX? Regular Expressions are a kind of search language which can be used to specify some very complex search requirements. When the -E option or the EGREP command is used the search string can specify a standard REGEX. JANOS implements most but not all aspects of standard Regular Expressions. Here is an example:

HoneyPot /> egrep "NTP \\([+-][0-9][0-9]+)" jniorsys.log   
10/24/17 12:21:59.000, Clock synchronized via NTP (-35)
10/25/17 13:55:55.000, Clock synchronized via NTP (-23)
10/26/17 15:38:34.000, Clock synchronized via NTP (-21)
10/26/17 18:37:50.000, Clock synchronized via NTP (-52)
10/26/17 20:17:50.000, Clock synchronized via NTP (-28)
10/27/17 14:03:21.000, Clock synchronized via NTP (-27)
10/31/17 09:53:57.000, Clock synchronized via NTP (-43)
10/31/17 13:03:01.000, Clock synchronized via NTP (-53)
11/01/17 01:37:37.000, Clock synchronized via NTP (-17)
11/02/17 08:28:06.000, Clock synchronized via NTP (-54)
11/07/17 14:27:47.000, Clock synchronized via NTP (-46)
11/14/17 09:07:59.000, Clock synchronized via NTP (-42)
11/15/17 07:59:34.000, Clock synchronized via NTP (-27)
11/17/17 14:01:52.000, Clock synchronized via NTP (-57)
11/21/17 01:37:48.000, Clock synchronized via NTP (-25)
11/21/17 08:57:01.000, Clock synchronized via NTP (-56)
11/22/17 01:33:16.000, Clock synchronized via NTP (-14)

HoneyPot /> egrep "NTP \\([+-][0-9])" jniorsys.log -c   
 14 lines matched
HoneyPot />

Here we listed all of the Clock synchronization events that made adjustments of 10 or more milliseconds in either direction. Then we count how many others (less than 10 milliseconds).

It is important to note that when escaping characters in a REGEX on the command line you must escape the escaping character. So in Regex you would escape the open parenthesis (which would normally start a group) using \(. On the command line this must be entered as \\( as you can see.

Try the last search with the -M to underline matches.

HoneyPot /> egrep "NTP \\([+-][0-9])" jniorsys.log -m  
10/24/17 10:16:38.000, Clock synchronized via NTP (-5)
                                              --------
  \0(8) "NTP (-5)"
10/24/17 12:23:21.000, Clock synchronized via NTP (+5)
                                              --------
  \0(8) "NTP (+5)"
10/25/17 14:13:59.000, Clock synchronized via NTP (-5)
                                              --------
  \0(8) "NTP (-5)"
10/27/17 14:48:22.000, Clock synchronized via NTP (-5)
 .
 .
 .
HoneyPot />

You can see that with a Regex the matching groups are also displayed along with its length. With Regex, Group 0 (\0) is the entire match. We can separate the magnitude of the adjustment into its own group as follows.

CODE: SELECT ALL

HoneyPot /> egrep "NTP \\([+-]([0-9][0-9]+))" jniorsys.log -m
10/24/17 12:21:59.000, Clock synchronized via NTP (-35)
                                              ---------
  \0(9) "NTP (-35)"
  \1(2) "35"
10/25/17 13:55:55.000, Clock synchronized via NTP (-23)
                                              ---------
  \0(9) "NTP (-23)"
  \1(2) "23"
10/26/17 15:38:34.000, Clock synchronized via NTP (-21)
                                              ---------
  \0(9) "NTP (-21)"
  \1(2) "21"
10/26/17 18:37:50.000, Clock synchronized via NTP (-52)
                                              ---------
  \0(9) "NTP (-52)"
  \1(2) "52"
10/26/17 20:17:50.000, Clock synchronized via NTP (-28)
                                              ---------
  \0(9) "NTP (-28)"
  \1(2) "28"
10/27/17 14:03:21.000, Clock synchronized via NTP (-27)
                                              ---------
  \0(9) "NTP (-27)"
  \1(2) "27"
10/31/17 09:53:57.000, Clock synchronized via NTP (-43)
                                              ---------
  \0(9) "NTP (-43)"
  \1(2) "43"
10/31/17 13:03:01.000, Clock synchronized via NTP (-53)
                                              ---------
  \0(9) "NTP (-53)"
  \1(2) "53"
11/01/17 01:37:37.000, Clock synchronized via NTP (-17)
                                              ---------
  \0(9) "NTP (-17)"
  \1(2) "17"
11/02/17 08:28:06.000, Clock synchronized via NTP (-54)
                                              ---------
  \0(9) "NTP (-54)"
  \1(2) "54"
11/07/17 14:27:47.000, Clock synchronized via NTP (-46)
                                              ---------
  \0(9) "NTP (-46)"
  \1(2) "46"
11/14/17 09:07:59.000, Clock synchronized via NTP (-42)
                                              ---------
  \0(9) "NTP (-42)"
  \1(2) "42"
11/15/17 07:59:34.000, Clock synchronized via NTP (-27)
                                              ---------
  \0(9) "NTP (-27)"
  \1(2) "27"
11/17/17 14:01:52.000, Clock synchronized via NTP (-57)
                                              ---------
  \0(9) "NTP (-57)"
  \1(2) "57"
11/21/17 01:37:48.000, Clock synchronized via NTP (-25)
                                              ---------
  \0(9) "NTP (-25)"
  \1(2) "25"
11/21/17 08:57:01.000, Clock synchronized via NTP (-56)
                                              ---------
  \0(9) "NTP (-56)"
  \1(2) "56"
11/22/17 01:33:16.000, Clock synchronized via NTP (-14)
                                              ---------
  \0(9) "NTP (-14)"
  \1(2) "14"

HoneyPot /> 

As we hoped Group 1 (\1) contains the part of the match representing the magnitude of the adjustment. You can probably figure out how to include the sign of the adjustment in the group now if that was what you really wanted.

The -M option can be very useful in creating and debugging a Regex for use elsewhere in an application or PHP script.

I should probably cover Regular Expressions in some detail someplace. I put that on the TODO list.

By the way, we have been searching the system log (syslog) as stored in the /jniorsys.log file. That is not all of the event history available. You might notice in the Syslog tab of the DCP that entries go further back in time. So if we had wanted to search all of our syslog history then we could do the following.

HoneyPot /> cat jniorsys.log.bak > syslog.txt

HoneyPot /> cat jniorsys.log >> syslog.txt

HoneyPot /> egrep "NTP \\([+-][0-9])" syslog.txt             
09/27/17 10:40:32.000, Clock synchronized via NTP (+4)
10/24/17 10:16:38.000, Clock synchronized via NTP (-5)
10/24/17 12:23:21.000, Clock synchronized via NTP (+5)
10/25/17 14:13:59.000, Clock synchronized via NTP (-5)
10/27/17 14:48:22.000, Clock synchronized via NTP (-5)
11/14/17 09:23:24.000, Clock synchronized via NTP (+7)
11/14/17 10:08:44.000, Clock synchronized via NTP (-9)
11/15/17 02:13:57.000, Clock synchronized via NTP (+2)
11/15/17 08:06:37.000, Clock synchronized via NTP (+2)
11/15/17 08:11:08.000, Clock synchronized via NTP (+4)
11/15/17 08:15:41.000, Clock synchronized via NTP (+0)
11/15/17 08:18:55.000, Clock synchronized via NTP (-1)
11/15/17 08:21:40.000, Clock synchronized via NTP (+5)
11/17/17 14:45:24.000, Clock synchronized via NTP (-7)
11/18/17 03:26:33.000, Clock synchronized via NTP (-2)

HoneyPot /> rm syslog.txt

HoneyPot />

Seems that there is only one such event prior to October 24th. The syslog ages to a .BAK file when it grows to about 64KB in size.

This shows how you can concatenate files under JANOS. I haven’t implemented some of the syntax of the DOS COPY command that would let you do that. Maybe some day. There doesn’t seem to be much demand for it.

Did you know that every JNIOR since the beginning of time has used the same isolated digital input design? It is not that this design is particularly special. It is more that a better one hasn’t been suggested or required.

Here it is from external connector to the RX63N processor pin (right to left).

The input is optically isolated by the device U12. That means that you can bring a signal from a distance and not have to worry about it being referenced to any local GND. You won’t create any ground loop. There is no common connection between signals (they all need not be referenced to GND). To activate the input then all you have to do is turn that LED on.

The diode D34 protects the isolator LED from high voltages. You can put 30V on this input and not risk LED damage. The extra voltage above 5V is dropped across the 910 Ohm 1 Watt resistor. The input is limited by that 1W power rating. The maximum voltage is 35VDC. And 1 Watt is a lot of heat so you probably want to limit the amount of time that the input sits at that voltage.

To deal with that limitation you could add a series resistance. The maximum voltage is 5V above the square root of the series resistance assuming 1W resistors. So if you want to sense the presence of a 120VAC signal you might insert a 20K series resistance. I will leave the Ohm’s Law exercise to you. Just make sure that you can dissipate the power.

The input can be considered to have about a 1200 Ohm input impedance. It is not a high-impedance input. Therefore any signal used to drive an input must be able to deliver current into a 1200 Ohm resistance and turn on the isolation LED.

The circuit after the isolator creates a 2 KHz low-pass filter. Basically we’ve specified that input signals should not exceed 2000 Hz. The reasoning behind this lies in the need to be kind to the processor. Each input transition generates a software interrupt and executes some code. This allows JANOS to know when the state of the input changes, perform some debounce, and log the event. If this happens too fast the system can be overwhelmed having to execute interrupt code back to back and not get anything else done. That’s not ideal. So the hardware prevents it.

The processor can handle faster signals to be sure. But not if several of the inputs are cranking like that. Besides, the JNIOR is not targeted into applications that process high speed signals.

Now the RED LED that you see when the input is active is driven by the output of that filter. In other words, if the after the filter the hardware thinks that the input is ON then it turns the LED on. So those LEDs are software driven. They illuminate when the input is high enough to activate regardless of how the input is configured internally.

I’ve been meaning to see if there is a more cost-effective and compact implementation for that filter. It was implements old-school with separate gates. Works though.

The input signal then interrupts the processor. In the Series 4 each separate input has its own interrupt channel. That was not the case in the Series 3 where we had some trouble insuring that all of the input channels were properly counted when triggering simultaneously. There is no issue in the Series 4. Each input can be configured.

This shows the input signal processing. In this case we go from left to right. The DIN input generates interrupts. It can be optionally inverted by configuration prior to the debounce logic. This is consistent with the Series 3. Logically though you might want to invert an input afterprocessing. That inversion can be performed by the Conditioning block which finalizes the input state for the system. This is an extension in the Series 4.

The debounce delay by default is set to 200 milliseconds. Basically when an input that has been in one state for a while changes the new state is recognized immediately. The debounce timer then is started. During the delay time additional transitions restart the debounce timer and those state changes are ignored. The reported state is then refreshed once the timer does expire. The trigger is rearmed at that point.

This debounce approach effectively stretches an input pulse until it has been stable for the delay period. So if you want to detect the presence of a 60 Hz AC signal then you need to set the debounce delay long enough to ignore the time when the AC signal does not drive the input. That would be at least 17 milliseconds.

Latching

Input Latching is optional. When not enabled the function is bypassed as indicated in the flow diagram. When enabled it can be configured to latch either the HIGH or LOW state. Once latched the input state will remain the same until the input is reset. This would allow you to catch and deal with a pulse or otherwise not lose track of the fact that some alarm condition had triggered.

The latching can be configured to time out. This will latch a pulse and allow it to reset itself after a period of time. You can use this to stretch a short pulse so logic downstream has the time to detect it and to deal with it.

Counting

Once the input has been debounced and optionally latched it will be counted. The counter can be configured to count a LOW to HIGH transition (0->1) or a HIGH to LOW transition (1->0). Each counter can be reset to 0 or set to any initial value. These can even be manually incremented by an application.

When counters are displayed they can be scaled and shown with unique units. A counter can trigger an alarm when it reaches predefined values. Alarms can send email notifications.

Metering

The Usage Meter totals the length of time that an input has been active. You can tally time for the HIGH state or for the LOW state depending on configuration. Usage meters can be reset to 0. This can be useful in monitoring the operating time of a piece of equipment. An alarm can be triggered when the usage meter reaches a configured amount of time. Alarms can send email notifications. This could be helpful as a reminder for the performance of preventive maintenance.

Logging

All input and output signal transitions are by default logged. The IOLOG command can be used to review I/O activity.

Conditioning

Finally the input state can be conditioned (Series 4 only). Here the input state can be optionally inverted or forced to a HIGH (1) or LOW (0) state. The forced states may be of use in debugging applications or disabling an input without having to physically disconnect it. A forced input is masked but continues to be counted and metered.

Alarming

Note that alarms are available for Counters, Metering, and Input State. Alarms can be configured through the Registry or DCP. These can send unique email notifications.

In summary…

A digital input seems like it is a simple thing with just a HIGH or LOW input state. There is however a lot more to it. We have seen here what effect the hardware has and how the input can be configured. All of this before the input state ever affects any application.

We are all familiar with logs. These are text files someplace that list events such as logins, configuration changes, errors, etc. On the JNIOR the jniorsys.log file is one such log. These things are useful for systems and web servers. The JNIOR is also a controller and it can be very useful to have a log of I/O activity either digital or serial. This is provided by the IOLOG command.

bruce_dev /> help iolog
IOLOG

Options:
 -T             Indicate transitions
 -R             Reset logs
 -A             AUX Serial log
 -S             Sensor Port log
 -O             Output to stdout

Generates jniorio.log file from available logs.

bruce_dev />

The above HELP alludes to some different logging capabilities. There is something with transitions. That is a detailed log of recent Digital Input and Relay Output transitions. That even includes relays contained in the external expansion modules. The AUX port supports a bidirectional Transmission Log that details communications traffic that includes both the bytes and the timing. There is also a log for the Sensor Port.

The Series 4 JNIOR by default logs all all of this activity to internal buffers. At any time you can dump the log buffers into a file or to the display using the IOLOG command. The IOLOG -R command can be used to reset a log. This can be useful in debugging where you don’t want to be distracted by prior data. I will show some examples.

Let’s start with the AUX Serial Port since it is fresh in my mind. Here the IOLOG -AR command will remove historical data from the AUX port transmission log. The does not affect the other logs. The IOLOG -AO comand will display the log content. For example…

bruce_dev /> iolog -ao
--  11/21/17 12:13:04.991
 FE  56  01  FE  56  02  FE  56  03  FE  56  04  FE  56  05  FE     ~V.~V.~V.~V.~V.~
 56  06  FE  58  FE  52  FE  9D  13  FE  9C  40  FE  42  01  FE     V.~X~R~..~.@~B.~
 47  01  01  34  31  30  20  53  4E  20  36  31  34  30  37  30     G..410 SN 614070
 35  30  30  20  20  20  20  4A  41  4E  4F  53  20  76  31  2E     500    JANOS v1.
 36  2E  33  2D  72  63  33  20  20  20  20  62  72  75  63  65     6.3-rc3    bruce
 5F  64  65  76  20  20  20  20  20  20  20  20  20  20  20  31     _dev           1
 30  2E  30  2E  30  2E  35  39  20  20  20  20  20  20  20  20     0.0.0.59        
 20  20  20  FE  42  01                                                ~B.
--  11/21/17 12:13:14.872  +9.741
-43- FE  47  01  01  7E  44  69  67  69  74  61  6C  20  49  6E     C~G..~Digital In
 70  75  74  73  20  20  20  20  20  20  52  65  6C  61  79  20     puts      Relay 
 4F  75  74  70  75  74  73  20  20  20  20  20  20  20  43  6C     Outputs       Cl
 6F  63  6B  20  20  20  FE  47  01  04  20  53  70  6C  61  73     ock   ~G.. Splas
 68  20  53  63  72  65  65  6E  FE  42  01                         h Screen~B.
--  11/21/17 12:13:24.860  +9.873
-48- FE  47  01  01  20  FE  47  01  02  7E  FE  42  01 -48- FE     H~G.. ~G..~~B.H~
 47  01  02  20  FE  47  01  03  7E  FE  42  01                     G.. ~G..~~B.
--  11/21/17 12:13:31.967  +6.306
-45- FE  47  02  01  20  20  20  20  20  20  20  20  20  20  20     E~G..           
 20  20  20  FE  47  01  02  54  75  65  20  4E  6F  76  20  32        ~G..Tue Nov 2
 31  20  31  32  3A  31  33  3A  33  32  20  45  53  54  20  32     1 12:13:32 EST 2
 30  31  37  FE  47  02  04  20  20  20  20  20  20  20  20  20     017~G..         
 20  20  20  20  FE  42  01  FE  47  13  02  33  FE  42  01  FE         ~B.~G..3~B.~
 47  13  02  34  FE  42  01  FE  47  13  02  35  FE  42  01  FE     G..4~B.~G..5~B.~
 47  13  02  36  FE  42  01  FE  47  13  02  37  FE  42  01  FE     G..6~B.~G..7~B.~
 47  13  02  38  FE  42  01  FE  47  13  02  39  FE  42  01  FE     G..8~B.~G..9~B.~
 47  12  02  34  30  FE  42  01  FE  47  13  02  31  FE  42  01     G..40~B.~G..1~B.
 FE  47  13  02  32  FE  42  01  FE  47  13  02  33  FE  42  01     ~G..2~B.~G..3~B.
 FE  47  13  02  34  FE  42  01 -44- FE  47  02  01  44  69  67     ~G..4~B.D~G..Dig
 69  74  61  6C  20  49  6E  70  75  74  73  FE  47  01  02  20     ital Inputs~G.. 
 52  65  6C  61  79  20  4F  75  74  70  75  74  73  20  20  20     Relay Outputs   
 20  20  20  7E  43  6C  6F  63  6B  20  20  FE  47  02  04  53        ~Clock  ~G..S
 70  6C  61  73  68  20  53  63  72  65  65  6E  FE  42  01         plash Screen~B.

bruce_dev /> iolog -ar
AUX logs reset
bruce_dev /> iolog -ao

bruce_dev />

Here we see data in a traditional dump format with 16 bytes displayed in hexadecimal on the left and an ASCII representation of each byte on the right. If the byte does not represent a printable ASCII character it is replaced with a period ‘.’ in the text display.

The AUX serial communications can be bidirectional. Bytes received by the JNIOR are shown enclosed by a dash ‘-‘. In the example above there are single characters received (keypress codes). When a longer message is received the dashes make the incoming data appear to be desplayed over a background line. It is just a way to distinguish direction.

If the channel remains quiet for a couple of seconds, the IOLOG output includes a timestamp and includes the duration of the pause. All of this can be very helpful in debugging a serial communications based application.

The data displayed here is actual results from an HMI test. The content is explained in detail in a different thread. Here is the link to that discussion viewtopic.php?f=5&t=158&start=20#p316. The interface program generating these communications was developed in the thread.

The AUX Transmission log can be sent to a file using the IOLOG -A command.

bruce_dev /> iolog -a
 auxio.log generated.
bruce_dev />

The file will then contain the data in the same format displayed in the prior post.

The Digital I/O log has quite a different appearance. This is generated using the IOLOG -O command. The digital log is the default log assumed by the command.

bruce_dev /> iolog -o
11/15/17 08:40:27.085, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 09:45:27.073, DIN ---- 0000 0000, RLY ---- ---- 0000 0001
11/21/17 09:45:27.848, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 09:45:29.549, DIN ---- 0000 0000, RLY ---- ---- 0000 0100
11/21/17 09:45:30.330, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 09:45:31.582, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 09:45:32.619, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:05:55.007, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 10:05:56.056, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:05:58.144, DIN ---- 0000 0000, RLY ---- ---- 0000 0100
11/21/17 10:05:59.943, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:06:05.996, DIN ---- 0000 0000, RLY ---- ---- 0000 0100
11/21/17 10:06:09.173, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:06:11.282, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 10:06:12.518, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:10:58.434, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 10:22:00.468, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:25:21.980, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 10:28:43.913, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:44:08.223, DIN ---- 0000 0000, RLY ---- ---- 0000 0001
11/21/17 10:44:09.621, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:44:10.585, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 10:45:39.208, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:48:23.797, DIN ---- 0000 0000, RLY ---- ---- 0000 0100
11/21/17 10:48:24.859, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:51:09.241, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 10:52:02.613, DIN ---- 0000 0000, RLY ---- ---- 0000 0011
11/21/17 10:52:04.316, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 10:52:05.107, DIN ---- 0000 0000, RLY ---- ---- 0000 0011
11/21/17 10:52:05.891, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 10:52:08.636, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 10:52:09.168, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 10:54:14.726, DIN ---- 0000 0000, RLY ---- ---- 0000 0011
11/21/17 10:54:25.912, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 10:55:35.680, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 11:00:48.609, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 11:00:52.456, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 11:05:50.782, DIN ---- 0000 0000, RLY ---- ---- 0000 0100
11/21/17 11:07:27.885, DIN ---- 0000 0000, RLY ---- ---- 0000 0110
11/21/17 11:09:21.747, DIN ---- 0000 0000, RLY ---- ---- 0000 0100
11/21/17 11:09:22.243, DIN ---- 0000 0000, RLY ---- ---- 0000 0110
11/21/17 11:40:23.259, DIN ---- 0000 0000, RLY ---- ---- 0000 0100
11/21/17 11:40:24.670, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 11:59:31.745, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 11:59:33.136, DIN ---- 0000 0000, RLY ---- ---- 0000 0110
11/21/17 12:00:18.043, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 12:05:08.749, DIN ---- 0000 0000, RLY ---- ---- 0000 0000
11/21/17 12:05:10.141, DIN ---- 0000 0000, RLY ---- ---- 0000 0010
11/21/17 12:42:49.123, DIN ---- 0000 0000, RLY ---- ---- 0000 0000

bruce_dev />

This log is generated by combining separate input and output logs. Each can contain up to 500 transitions. Depending on how frequently inputs and relays change you could have data spanning weeks or simply minutes.

Each line represents at least one transition. There is a timestamp to the millisecond. A ‘1’ indicates when an input (DIN) is activated or a Relay (RLY) closed. The inputs and relays are shown from right to left. So the last transition in the above log shows Relay Output 2 opening. There can be up to 16 relays and 12 inputs logged.

The IOLOG -R command will reset the digital log and not affect others. The IOLOG command without options will store the digital log in a file.

bruce_dev /> iolog
 jniorio.log generated.
bruce_dev />

There is also a log for the Sensor Port but unless you are intimately familiar with Dallas 1-Wire communications none of it will make sense. You can write an application to take control over the Sensor Port and communicate with a custom device or non-standard device. It you are working at that level then this log could be very helpful. The Sensor Port log follows the same format as the AUX Transmission Log.

So you’re developing an application. It works, but you question if it is efficient or not. That is where the THD command comes in. The THD command will show all of the threads that are active in each Java application that is running.

This command will also show other useful JVM information. Information such as the number of unique classes that have been loaded, the amount of memory that has been allocated to hold that class information, process time, heap memory usage, stack usage and class object memory usage.

Then each thread is listed showing its processor usage time, thread name, the class that implements the thread, parent thread, state and whether or not the thread is a daemon thread.

Lastly any Watchdog that has been activated is listed with its name, the action that will be carried out should the watchdog be triggered and how long until the watchdog will be triggered should it not be fed.

Here is a quick application that tests the Watchdog. You can see that at the time the thd command was executed the Watchdog was about to expire, within 1 second.

kev-dev /> thd
   9 classes loaded.   44.7 KB
   1 JVM instances active.
Command/10.0.0.27:55691/flash/watchdogTest.jar         0.557   mem: 20.9K  pid: 36  stk: 0.3K  obj: 2.1K  cls: 12.4K
         0.150  1: main, java/lang/Thread, main, SLEEP
     Watchdog: 'Watchdog Test', WDT_REBOOT, remaining = 0.880s

Here is the code listing for the above test application.

package watchdogtest;
 
import com.integpg.system.JANOS;
import com.integpg.system.Watchdog;
 
/**
 * This application tests the watchdog. A watchdog will be registered with the operating system. It will be fed a few
 * times and then left to be triggered. When it gets triggered we should see the registered action get carried out.
 */
public class WatchdogTest {
 
    public static void main(String[] args) throws InterruptedException {
        // instantiate the watchdog and register it to reboot when it gets triggered
        Watchdog watchdog = new Watchdog("Watchdog Test");
        watchdog.setAction(Watchdog.WDT_REBOOT);
        watchdog.activate(60000);
        // log to the syslog so that we can see exactly when the operating system reboots
        JANOS.syslog("Watchdog Started");
 
        // sleep for 30 seconds and then feed the watchdog.
        Thread.sleep(30000);
        watchdog.refresh();
        JANOS.syslog("Watchdog fed");
 
        // sleep for longer than the watchdog duration.  This will allow the watchdog to get triggered.  We 
        // should see that the reboot occurs 60 seconds after the last time the watchdog was fed
        Thread.sleep(120000);
    }
 
}

And here is the associated log entries from the jniorsys.log. As expected the timing works out. The watchdog was started, 30 seconds later we log that it was fed and then 60 seconds later we get the Assertion indicating that the reboot sequence has been commenced. 15 seconds are given to applications and system processes for safe shutdown.

11/17/17 14:13:19.302, Watchdog Started
11/17/17 14:13:49.368, Watchdog fed
11/17/17 14:14:49.487, ** Assertion: Watchdog Test watchdog triggered reboot (Line 1139)
11/17/17 14:14:49.496, ** Terminating: System
11/17/17 14:15:05.937, ** Reboot on assertion: Watchdog Test watchdog triggered reboot (Line 1139)
11/17/17 14:15:05.945, -- JANOS 412 v1.6.3-rc2 initialized (POR: 58)

The JNIOR Connector Kit contains 5 connectors. Four (4) are the 8-position female screw terminal types for I/O connections and one (1) a 4-position connector of the same style for the power connection. The latter will also be found on power supplies that are obtained from INTEG. here are the part numbers.

They look like this. The others having 8 positions of course.

These are SINGLE ROW FEMALE TERMINAL BLOCK PLUG 0.200″ 5.08MM PITCH. Color is irrelevant although INTEG tries to supply BLACK for digital signals and power, and GREEN for analog (external modules).

There are alternatives to these connectors that you can source separately. INTEG does not stock an alternative although arrangements can be made upon request.

Connectors are generally an expensive part of the product. These two-part connectors add value to the JNIOR.

Some wiring hints…

If multi-strand cables are used it is recommended that either the stripped end of the wire be properly tinned or some form of crimp pin be employed. If neither is convenient then insure that the stripped wire is tightly and cleanly twisted and clamped securely by the connector. Cables should have sufficient slack so as to not stress the connection as connectors are inserted or removed. Ty-wrap cables for a single connector together within 3″ of the connector to provide strength in numbers.

If solid cable is used then it is important that cables have sufficient slack so as to not bend the cable at the connector when the connector is inserted or removed. Ty-wrap cables for a single connector together for added protection.

Screw terminals should be hand-tightened strongly. Periodically check screws and tighten as necessary. Repeated changes in temperature can over time loosen screws.

Clamping more than one cable at a connector position is not recommended. In this case the clamping mechanism will grab the largest diameter wire more strongly creating an intermittent and loose connection with the other. If you must chain wiring in this fashion either tin wires together or tightly and cleanly twist them before clamping. Carefully wiggle both wires separately to insure that both have been securely captured.

When stripping wire use the proper tool with the proper wire gauge setting. Be careful not to cut into the copper conductor. This is highly likely if using a knife to remove the insulator. This can completely cut outer strands of multi-stranded cables reducing their current carrying capacity and increasing the possibility of a poor connection when clamped. Over time as cables are flexed cables that are improperly stripped will tend to break where the insulator has been cut.

If your wiring reaches the JNIOR from above you may consider a connector style where the cables leave the connector at 90 degree angles. For example you can source connectors like this one.

This is Pheonix part nubmer 1836901 and these are available from other manufacturers.

There are screwless connectors. These use spring force to achieve clamping and have the advantage of not loosening over time. There are different approaches. Here is one example.

If strain relief is an issue it is best to secure the cabling to the connector. An arrangement like this can be helpful. This eliminates the flex at the cable end where wires may break or loosen.

Now if you are willing to carry another crimping tool you can take a different approach. This would be much more appropriate when the JNIOR is installed within another product or rack mounting. Here you by just the housing and crimp a pin on each wire which is then inserted.

Here there is no question of loosening and strain relief is built-in. That assumes you are proficient at crimping. This is Pheonix 1808832 and I will attach the data sheet as well.

1808832

If you are using the JNIOR PCB without the housing as part of your product and are will to purchase in quantities of say 100 and allow for a standard lead time we can accommodate any connector arrangement. The PCB holes are on 0.200″ (5.08mm) centers.

Depending on the commitment we can also create a custom PCB to meet your specific needs. This is not as expensive as you might think. Cost does depend on quantity. Call us. We are willing to work with you.

There is no cost in asking.

The JNIOR Web Page is the website served by the Series 4 JNIOR out of the box. Once you have powered your JNIOR, connected it to the network, and assigned it an IP Address you can access the JNIOR Web Page using your favorite browser. This website is contained in, and served from, the /flash/www.zip file on the JNIOR.

Input/Output Tab

You can use the JNIOR Web Page to monitor your JNIOR. Through the Input/Output tab you can see the status of each Digital Input and Output Relay. This tab offers two pages (listed down the left column). These are the Internal I/O and External I/O pages.

Internal I/O Section

If you log into an account with sufficient permissions you can control the relays. The appearance of this page can be configured through the Configuration tab. The labels can be redefined as might be appropriate for your application. You can remove unused inputs and outputs and even mask features such as usage metering if not of use.

External I/O Section

The External I/O refers to external modules that you may optionally use with your JNIOR. INTEG can supply a Power Relay module, analog modules for 10V or 4-20ma, and even temperature sensors. One or more of these may be daisy-chained on the Sensor Port. If you have any of those they can be monitored and controlled in the External section of the Input/Output tab.

Configuration Tab

The Configuration tab is available only to Administrator accounts. This provides a dozen and a half pages covering most every aspect of your JNIOR.

Display Section

The Display page configures settings that affect the appearance of the Input/Output Internal page. Here you may disable any channel which simply removes the channel from view on the Input/Output tab. This does not disable the function of the input or output. It merely allows you to hide unused or background channels. Similarly you can hide Counters, Usage Meters, Alarm indications and Controls. For relay outputs you can select the Pulse control instead of Toggle if appropriate. You may even alter the coloring used in showing the input or output state.

Note that each item of configuration is associated with a Registry Key. If you hold the mouse over a setting the related key is displayed in a Tooltip. Configuration settings that differ from default will appear in the Registry which can be viewed and edited directly using the Registry tab. More on that in a bit. While the mouse is hovering you may hit F1 to view the built-in Registry documentation.

Labels Section

The Labels page provides the ability to configure the text displayed on the Input/Output Internal page. In addition to Descriptions and I/O State labels you can change the units for the Counter.

This page is shown for the Model 410 which has 8 inputs and 8 outputs. The JNIOR Web Page will display different arrangements for the Model 412 and 414. The former having 12 relay outputs and only 4 inputs. The latter with 12 inputs and only 4 outputs.

Inputs Section

The Inputs page affects the function of each input. Here you can configure inversion, debounce and a number of other characteristics for each of the available inputs.

A Block Diagram is available through the provided link to help in visualizing input configuration. We can cover the details under another topic.

Counters Section

The Counters page sets counter configuration for each input. The JNIOR counts each activation of an input. Here you can configure how that is to happen and how it is displayed. You can scale a counter if each activation represented a number of items or a fractional amount of something. Here you can see the value of changing the displayed counter units which are configured on the Labels page.

Here you can also configure two different Alarm levels. Alarms are displayed on the Input/Output Internal page. They are also Events that can issue email notifications.

On this page you can also mouse over an input and click the displayed “X” to easily reset a counter to 0.

Outputs Section

The Outputs page provides state configuration for Usage Metering. The JNIOR tallies time for each activated input or output. This would potentially be useful for Preventative Maintenance. Here you can also set the default Pulse duration that would be used if you elected to configure a Pulse control (button) for the output on the Input/Output Internal page. If you want more information on this section, click here.

Metering Section

The Metering page displays the accumulated time for each Usage Meter. Like the Counters page you can mouse over a Channel and click the displayed “X” to reset the usage. Here you can also set the active usage state and configure alarms. This alarm can be set to send an email notification on the Events page.

Serial I/O Section

The JNIOR has two serial ports. The Serial I/O page can be used to set communications parameters for each port. The defaults are shown.

Generally an Application Program is used to perform communications over a serial port. The program itself may configure communications parameters. There are times where you may wish to set the parameters outside of an application. The IOLOG command provides access to a Transmission Log for the AUX port. You can set the Baud Rate and then check the IOLOG to see if data has been received properly.

Applications Section

The Applications page lists Registered Applications. Applications are automatically Registered during boot provided that a JAR file exists in the /flash folder containing a properly formatted appinfo.ini file. The content of the Applications page then may vary significantly from one JNIOR to another.

An application may be set to run at boot. When you check the box associated with the application the appropriate Registry Run Key is created. On reboot the application will automatically start. If available a link is displayed that can lead to additional configuration pages specific to the application.

Note that the checkbox only affects the status of the application after boot. The starting and stopping of applications at any other time is performed at the Command Line which can be accessed through the Console tab.

Mail-Account Section

Each JNIOR has the ability to send email notifications. Applications can be written to generate emails and potentially received them. Outgoing email requires a valid client account. The Mail-Account page is used to configure the outgoing email capability.

Here the Mail Server is something like smtp.comcast.net and the From Address would be the email address for a Comcast account. When you enter the SMTP Username you will be asked for a valid Password. The password is securely stored in the Registry. The remaining settings define the SMTP port, security and other characteristics for the communication. These are the credentials use in submitting outgoing emails.

Mail-Profiles Section

Email notifications can be generated for a number of Events if enabled. JANOS has default structures for those notifications. You can optionally define any number of custom email messages as Profiles using the Mail-Profiles page. When the default content is insufficient these profiles can be referenced by name to define custom email recipients and content.

Events Section

There is a small set of built-in events. The Events page is used to configure the actions associated with those events. For the most part this involves enabling an email notification and defining an optional email profile.

Beyond those listed here an unlimited number of events and actions can be accommodated through application programming or direct configuration of the Registry.

Note that the automatic starting of application programs can be disabled here without need for removing the Run keys.

Network Section

The JNIOR is shipped configured with an IP Address of 10.0.0.201. This likely will not work for you.

To configure the network addressing you can run the Support Tool. The Support Tool is a Windows application that you can download for free from the INTEG website https://integpg.com/jnior-support-tool/. You can also make a serial connection to the RS-232 (COM) port and use the IPCONFIG command at the command line.

Once you can access the JNIOR Web Page you can modify settings through the Network page.

Security Section

The Security page offers a couple of settings.

The Series 4 JNIOR can perform secure communications using Public Key encryption and SSL/TLSv1.2. By default a 1024-bit RSA key pair is used in concert with automatic self-signed certificates. This means that you can access the JNIOR Web Page using a HTTPS connection. You can also perform secure FTP transfers and Telnet connections. The latter is best done with a client program available from us. Of course, you do not need either FTP or Telnet as the JNIOR Web Page offers most of that functionality.

While it doesn’t seem prudent you can disable the SSL capability here by deselecting SSL Enabled. Perhaps more appropriate is enabling SSL Required. In this case FTP and Telnet connections must perform STARTTLS and proceed securely. The standard HTTP port (Port 80) is closed. You can continue to make the secure connection using HTTPS (Port 443). Email will only be transmitted securely.

IP Address filtering is available. The Allowed IP Addresses field can be set with a comma delimited list of IP addresses that can make connection to the unit. This field can also contain a sophisticated filter string. It is recommended that the documentation (use F1) be viewed before setting this field. You can block yourself. In that case you will need to make the serial Command Line connection and remove the filter through the REGISTRY command.

Telnet Section

The Telnet page simply lets you relocate the port. You may want to do that to hide it from casual connections. You can also disable the server entirely. You can do that since you can access the Command Line through the Console tab of the JNIOR Web Page.

WebServer Section

The WebServer page is used to configure the Web Server. Here you can relocate either the HTTP or HTTPS ports or both. You can disable the Web Server entirely. That also prevents use of the JNIOR Web Page but your application might demand the limited access.

By default web access requires a login. You can disable the login requirement and to do so you must also define a user account for anonymous access. If your JNIOR is physically secure and the network is isolated from the larger network you might disable the login. If otherwise you have some pages that you wish to share publicly you can place them in the /flash/public root. Pages are served from that area without the need for authentication.

FTP Section

You can relocate or disable FTP using the FTP page. You can disable FTP and still manage the JNIOR’s file system through the Folders tab of the JNIOR Web Page.

Anonymous FTP access is not recommended. You can allow that by defining a user account to be used for that.

Protocol Section

The JNIOR Protocol is deprecated and not recommended for new applications. The Series 4 offers a more modern Websockets interface which performs all of the same function and much more. It is also not binary. The JNIOR Protocol is still supported.

The Protocol page can be used to relocate the JNIOR Protocol port. The server can also be disabled.

We would recommend disabling the JNIOR Protocol unless you know that it is used. It is also highly recommended that the login requirement not be disabled. If you do so you must then define a user account for the anonymous access.

Modules Section

And finally for the Configuration tab is a page for the configuration of external modules. If you use an external module it will be listed here on the Modules page. If you have recently connected a module and don’t see that one you can select ‘rescan’ to update the list.

If the external module has configuration setting those can be seen by expanding the module. Click the triangle shape. For instance the 4ROUT labels can be altered for use on the Input/Output Externals page.

Console Tab

The Console tab provides access to the Command Line interface. This is similar to a Telnet connection but performed entirely through the web interface (Websockets). Note that an additional login is required here.

You can cut and paste here. That would be one advantage over a Telnet client. You can also drag a file to this window. That will place the file into the /temp folder convenient for further use from the command line. You might drag a UPD here and once it transfers use the JRUPDATE command to update the operating system as an example.

Folders Tab

The Folders tab provides a file explorer formatted view into the file system.

You can navigate through folders by clicking on the left tree or double-clicking folders on the right as you might expect. Files can be selected and downloaded. You can also delete files and create folders. Drag and Drop is supported both into and out of the folder. Although in that case there is some variation in availability depending on the browser you are using. I use Chrome extensively. That seems to provide all of the needed capability.

If you need to move entire folders including subfolders then FTP is a better bet. Here I recommend FileZilla. https://filezilla-project.org/

Registry Tab

The Registry tab provides an explorer view into the Registry. Here you can edit and remove keys as needed. Each setting found in the Configuration tab is associated with a Registry Key. You can make settings here if you know the proper key and format.

It is recommended that you become familiar with the Registry, There are some settings that are not accommodated by the JNIOR Web Page GUI. You will need to enter those here. The Registry can also be manipulated from the Command Line.

The JNIOR Web Page contains built-in and detailed Registry documentation.

Syslog Tab

The Syslog tab displays the System log detail in chronological order with the most recent event at the top. This is the content of the /jniorsys.log and /jniorsys.log.bak files concatenated. You can scroll then through all of the available log history in order from most recent to the oldest.

Here I’ll show a segment of the HoneyPot Syslog since my development unit sees a lot of crazy use and its log is full of confusing stuff. In fact you can see in this log where JANOS was recently updated. The infected.json file that keeps getting updated is the database for the http://honeypot.integpg.com/map.php application running on that unit. The HoneyPot JNIOR is connected directly to the Internet.

Peers Tab

The Peers tab provides quick link access to other JNIORs that you may have on the network. The Series 4 JNIOR is aware of nearby peer products. Here you can move to the JNIOR Web Page on these other units using the link provided. That can be convenient if you have many JNIORs. Okay, so here at INTEG the Peer list gets crazy.

For many this list will be short if there are any at all.

About Tab

And FINALLY! We have the About tab. This actually contains some text and potentially useful information.

Make sure that the Serial Input Buffer Size is adequate for your application. It is 128 bytes by default. If a greater number of bytes that the buffer size are sent and your application does not read them in time then the buffer can fill and data will be lost.

        // display the current buffer size
        System.out.println("auxSerialPort.getInputBufferSize(): " + auxSerialPort.getInputBufferSize());
 
        // set the new buffer size
        auxSerialPort.setInputBufferSize(256);
        // display the new buffer size
        System.out.println("auxSerialPort.getInputBufferSize(): " + auxSerialPort.getInputBufferSize());

The output should look as follows.

auxSerialPort.getInputBufferSize(): 128
auxSerialPort.getInputBufferSize(): 256

The PS Command displays the current processes. JANOS is a preemptive multi-tasking environment. It can execute up to 16 processes using a simple priority scheme. Each process is given an ID and each new process receives a unique ID. For example:

412dmx_r01 /> ps
      0: Idle Process
      1: Network Service
      2: System
      7: Command/Serial
4 total     2:19:16.988 uptime

412dmx_r01 />

The Idle Process (PID 0) collects time when the system has nothing to do; The Network Service (PID 1) handles all network activity on a high priority basis; And, the System Process (PID 2) performs all routine system activities. These 3 processes are created at boot and always appear in the process list. The PS -V command provides a more verbose output format that contains more information.

412dmx_r01 /> ps -v
      runtime       mem  hnd stk frm     id    desc
     2:24:35.303                          0: Idle Process
           3.991    2.7K   7  11          1: Network Service
          11.217    1.3K   7  13          2: System
          12.246   37.9K   7  20          7: Command/Serial
4 total     2:25:36.193 uptime

412dmx_r01 />

This displays the runtime accumulated by each process. The Idle Process should accumulate the most runtime. If that is not the case then perhaps there tight loops in an application that could benefit from a Thread.sleep().

This also displays the amount of memory assigned to the process (mem). If this number were to continually grow with subsequent PS -V commands, then the application may have a memory leak. You might be creating an array and never pruning old entries. Or, there could be a JANOS issue that we would very much appreciate you pointing out to us.

The Handle count is displayed (hnd). Handles represent I/O streams such as stdin, stdout, stderr, comin, comout, auxin, and auxout. These are the 7 default streams. If you open a file or a network stream a handle is assigned. An application can have a number of handles however these too should not increase with time. They also can leak if not properly closed.

Each process has its own stack. The percentage of stack usage is displayed (stk). If a stack overflows it s percentage would reach 100. This is not desirable.

JANOS can execute Java programs. A Java Virtual Machine is launched for each program. In those cases the number of stack frames in use is displayed (frm). This number is limited by the amount of memory. It should be fairly stable for any application.

Other processes may appear in the process list. For example:

412dmx_r01 /> ps -v
      runtime       mem  hnd stk frm     id    desc
     2:47:44.211                          0: Idle Process
           4.879    2.7K   7  11          1: Network Service
          12.895    1.3K   7  13          2: System
           2.939   73.9K   9  20         10: Web Server
          16.721   38.3K   7  20          7: Command/Serial
           0.057   33.8K   7  12         13: Console/10.0.0.20:13948
           0.499   33.8K   7  12         14: Command/10.0.0.20:13981
7 total     2:48:57.353 uptime

412dmx_r01 />

The Web Server is executed to handle connections from browsers. This process is started automatically and remains active for as long as there are valid and active web connections. If there are several minutes of inactivity the Web Server will terminate. It would be restarted should another connection request be received. A single Web Server process handles all web connections.

The Command/Serial process here indicates that I am connected via the RS-232 (COM) port and have an active command line session. Here I must be careful to use the EXIT or BYE command or the process will remain active. Simply disconnecting the cable will not remove this process. There can be only one active serial command line connection.

The Command/[IP Address:Port] process indicates that I have connected to a command line through Telnet (Port 23). This will terminate once that network connection is closed. Each Telnet connection is its own process.

And the Console/[IP Address:Port] process indicates that there is a Console Session open through the DCP (or other Websockets connection). There are multiple ways to access the command line. You can tell them apart by their process name. Each Console Session is its own process.

The Protocol Server may appear as a process. Like the Web Server the Protocol Server handles one or more JNIOR Protocol connections. The service is automatically started when a JNIOR Protocol (Port 9200) connection is requested. After a period of inactivity the Protocol Server will terminate.

The JNIOR Protocol is a deprecated binary protocol which can be used to configure, control and monitor the JNIOR. It is supported however we recommend that new applications use the Websockets Interface. The latter has the same functionality and much more. It is a modern interface.

Unlike the Web Server and Protocol Server each FTP (File Transfer Protocol) connection is its own process. These will appear as FTP/[IP Address:Port].

JANOS can make secure network connections using TLSv1.2. When secure communications are active the Secure Transport process will run. A single Secure Transport process handles all secure communications. It augments network streams belonging to other processes by imposing the TLS protocol and performing the associated encryption and decryption.

The Security Update process is related and is executed when new RSA Keys are being generated. The process of generating a new key pair is computationally intensive. The Security Update process performs that task at a low priority and in the background. JANOS can generate a new set of keys periodically. It then updates its own self-signed certificates. This represents a level of security unprecedented in an embedded controller. The Administrator can install externally generated keys and signed certificates.

Finally each application runs as its own process. Each is a JVM. These will be indicated by program name along with an indication as to how the program was executed. For example.

412dmx_r01 /> ps -v
      runtime       mem  hnd stk frm     id    desc
           1.956                          0: Idle Process
           1.335    1.2K   7   1          1: Network Service
           0.062    1.2K   7  15          2: System
           1.362   58.6K   7  24   7      3: Run/Dmx.jar
           0.020   34.3K   7  12          4: Command/Serial
5 total           4.760 uptime

412dmx_r01 />

here the DMX.jar program was started through a Registry Run key. Compare with the following where the same program has been started at the command line.

412dmx_r01 /> ps -v
      runtime       mem  hnd stk frm     id    desc
        1:51.124                          0: Idle Process
           1.406    2.7K   7   8          1: Network Service
           0.540    1.2K   7  15          2: System
           1.210   51.9K   7  24   7      5: Command/Serial/dmx
           0.081   34.7K   7  12          4: Command/Serial
5 total        2:24.376 uptime

412dmx_r01 />

Notice in the previous post how the application program has a number of stack frames (frm). These programs are executed by a JVM.

Ctrl-C (hole Ctrl and press ‘C’) interrupts an executing Java application when run from the current command line. If you need to stop an application that has been started from a different Console session or through a Registry Run key you will need to use the KILL command.

If an application is not running then Ctrl-C redisplays the Console Welcome banner. This is a quick way to see the current Model, Serial Number and JANOS version. It tells you the current time and uptime. Note that there are other ways to obtain all of that information but the banner is quick. Just hit Ctrl-C.

The display of the current “Uptime” in the banner is a recent addition. Normally this will display “System up time”. However, if the unit has been running uninterrupted for a record amount of time this will indicate the uptime as “Record up time”.

The banner is supplied when you make a Telnet connection before any login is required. The information in the banner is thereby made public.

The DEL key is used to delete characters as you would expect. It has one additional use. If entered as the first and only character on a command line it will toggle the use of the hostname in the prompt string.

The command line prompt displays both the hostname and the working directory/folder. Depending on the length of the hostname and what the current working directory may be the prompt can be lengthy. The DEL key can be used to shorten the prompt string by removing the hostname. The current working folder is always displayed.

If your application is set to start on boot then there is a chance that it will start executing before the network is ready. Add this simple check before you perform any critical network tasks.

            if (!Network.isActive()) {
                System.out.println("Waiting for network");
                while (!Network.isActive()) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace(System.err);
                    }
                }
            }
            System.out.println("Network Ready");

The MANIFEST command is a utility that you can use to monitor the health of the file collection on the JNIOR.

If you copy a file from your PC to the JNIOR how do you know that the file has completely and accurately transferred?

Let’s look at the DCP file /flash/www.zip. Let’s see how we can tell if it is perfect.

bruce_dev /> manifest flash/www.zip
JNIOR Manifest      Tue Oct 31 15:49:01 EDT 2017
  Size                  MD5                  File Specification
 182900   2c6ce5c5d365ea53b437a3760d6f4dd0  [Modified] /flash/www.zip
End of Manifest (1 files listed)

bruce_dev />

MANIFEST tells me the size of the file and also the MD5. That is a unique (ugly) hexadecimal value calculated from the file content. If I calculate the MD5 for the file on the PC it should match. So lets see.

File Properties

2017-10-31_15-51-42.png

MD5 Matches

Wait! How do you get those Checksums in the File Properties?

There are many ways to get the MD5 of a file. I found this tool that you install and it adds this to the properties dialog. Here is the link http://code.kliu.org/hashcheck/. It’s sweet.

Don’t like the MD5 hash then use the -H option for the SHA-1 hash. It still matches!

bruce_dev /> manifest flash/www.zip -h
JNIOR Manifest      Tue Oct 31 15:59:14 EDT 2017
  Size                  SHA-1                        File Specification
 182900   34eda6ecf2cbd0f136ec4adef0cfb442a11f8254  [Modified] /flash/www.zip
End of Manifest (1 files listed)

bruce_dev />

Or the -C option for the simpler CRC32. It still matches!

bruce_dev /> manifest flash/www.zip -c
JNIOR Manifest      Tue Oct 31 16:00:41 EDT 2017
  Size     CRC32     File Specification
 182900   2a1f06bd  [Modified] /flash/www.zip
End of Manifest (1 files listed)

bruce_dev />

Pretty sure that file is accurately over on the JNIOR. What do you think?

It is not just about comparing checksums or hash values. You can use MANIFEST to monitor the ongoing status of your files. Here is the HELP for the command.

bruce_dev /> help manifest
MANIFEST [filespec]

Options:
 -S,-R          Include subfolders
 -U             Update reference point
 -C             Report CRC32
 -H             Report SHA-1
 -L             List differences only
 filespec       May contain wildcards

Produces a manifest of file system content including checksums.

bruce_dev />

Okay so we have experienced the -H and -C options. The -S (and -R alias) seems straight forward. If you use a wildcard this option will process subfolders as well.

The -U option creates a reference point. This is a manifest.json database containing file details. MANIFEST can use this database at a later time so you can detect changes, new files and missing files. In short, you will know what has changed and what has not on your JNIOR. That has some merit.

For example we will run MANIFEST -U to make sure that our reference point is set. I will then remove a file and let’s see if MANIFEST can detect it. The MANIFEST command without file specification processes ALL files on the JNIOR. The -L option lists differences.

bruce_dev /> manifest -ul
JNIOR Manifest      Tue Oct 31 16:10:52 EDT 2017
  Size                  MD5                  File Specification
End of Manifest (0 files listed)

bruce_dev /> dir help.txt -l
total 1
-rw-r--r--   1 jnior     root       17110 Oct 31 14:10 help.txt
  1920.7 KB available

bruce_dev /> rm help.txt

bruce_dev /> manifest -l
JNIOR Manifest      Tue Oct 31 16:11:37 EDT 2017
  Size                  MD5                  File Specification
                                            [Missing] /help.txt
End of Manifest (0 files listed)

bruce_dev />

Here we can see that the help.txt file is Missing.

MANIFEST will report missing, new and changed files. In fact if a file changes but its timestamp has not, then it is reported as corrupt. Use of this utility can really help develop confidence in your file system content. You just need to create that reference point.

By the way, there are 2 copies of manifest.json. One is /manifest.json and the other is /flash/manifest.json. One is backup for the other. They are the same. So if for some reason the SRAM is reformatted there is a copy still in the Flash. If Flash is reformatted there is a copy still in the SRAM which holds the root of the file system.