Java on VxWorks using Micro Runtime

Java on VxWorks using Micro Runtime

By Ka Kay Achacoso

KaKay-photoVxWorks Micro Runtime (MRT) is a Java engine that runs Java byte code on VxWorks real-time operating system (RTOS).   For applications that run on multiple platforms, the same application code that runs on VxWorks can also run on Linux, Android, iOS, and Windows.

VxWorks Micro Runtime is developed by Intel’s Software and Services Group (SSG) in collaboration with the Internet of Things Group (IOTG) and Wind River.  The Java engine is highly optimized for Intel hardware.  It is designed especially for Internet of Things (IoT) devices.  The Intel Management Engine is powered by the same Micro Runtime engine.  By running Micro Runtime on VxWorks on Intel hardware, applications can take advantage of both the real-time properties of VxWorks and the performance optimizations of the Java engine.

Java 3rd party libraries

A big advantage of Java is the abundance of 3rd party libraries available to the Java community.    Developers can easily pick up technology implementations, some of these having run through several iterations of developer community vetting.  As a test run, I picked up two common IoT end-device technology libraries.

The first technology, MQTT, works on a publish-subscribe model.  An MQTT broker runs on a server.   An MQTT subscriber subscribes to the broker for messages of a certain topic.  An MQTT publisher publishes messages of a specific topic to the broker.  This way, an MQTT publisher can transfer data to MQTT subscribers.

The Eclipse Paho Java Client is an MQTT client library. Using this library, a VxWorks Micro Runtime application can publish messages or subscribe to messages when connected to an MQTT server, such as Mosquitto running on Linux.

Here is the Eclipse Paho Java MQTT publisher in action on VxWorks Micro Runtime.  Using just the sample application provided with the library, the MQTT client publishes a message to the broker, and a separate subscriber receives the message.

> Connected to broker.
Message published to broker.

I am running this Java application on a mini-ITX board with an Intel Core i7 processor.  The Micro Runtime Java engine is supported on all Intel modern Quark,  Atom, Core, and Xeon  processors, as well as the NXP i.MX6 processors.

The execution on the VxWorks MQTT publisher is boring.  The more interesting part is what the MQTT subscriber can do with the published messages.  With a few modifications on the Java client to publish more interesting data, I can use any freely available MQTT subscribers to view my data.  Figure 1 is a screenshot of the TeleMecha iPhone app that maps out the data from VxWorks.

 Fig 1 TeleMecha

Figure 1.  TeleMecha MQTT subscriber view of data sent from VxWorks MRT application running Eclipse Paho Java MQTT publisher library

The exact same Java class byte code files run on Oracle Java SE with no modifications.  I should point out here that VxWorks Micro Runtime does not use jar files and class files directly.  Instead, a file in JEFF format derived from the jar files and class files serves as input to the VxWorks Micro Runtime engine.   The JEFF format is an ISO standard.  It is a popular byte code format for embedded Java because of its compact size.  You can get information about the JEFF file format here.

Fig 2

 Figure 2.  The VxWorks Micro Runtime engine and the Oracle JVM use the same class files for its applications in the MQTT example

As a Java application, I first ran the MQTT publisher on my Windows host development laptop, and spent a few tight iterations tweaking the application.  Once the application code stabilized, the Java class files used on the Oracle Java Virtual Machine (JVM) were built into a jeff file and ran with no further tweaks on VxWorks.  The process of moving the application from a Windows platform to a VxWorks platform worked smoothly.

The second IoT technology tested was the RESTful web services for access to many services in the cloud.  Resty is a simple HTTP REST client for calling REST APIs.  https://beders.github.io/Resty/Resty/Overview.html.  Using the Resty client library, I was able to use VxWorks Micro Runtime to get current stock prices from Markit On Demand http://dev.markitondemand.com/MODApis/.   The response in JSON format was parsed to provide stock price information.  It was just as easy setting up the application to run on Oracle Java SE as it was to run on VxWorks Micro Runtime, and they yielded the same results.

Received value = {“Change”:0.32,”ChangePercent”:0.895104895104896,
“ChangePercentYTD”:-0.551419906258624,”ChangeYTD”:36.27,”High”:36.25,
“LastPrice”:36.07,”Low”:35.74,”MSDate”:42825,”MarketCap”:170935730000,
“Name”:”IntelCorp”,”Open”:35.75,”Status”:”SUCCESS”,”Symbol”:”INTC”,
“Timestamp”:”Fri Mar 31 00:00:00 UTC-04:00 2017″,”Volume”:21438385}

Company:  Intel Corp
Symbol:  INTC
Price: $36.07
Time:  Fri Mar 31 00:00:00 UTC-04:00 2017

Java Native Interface

Running Micro Runtime on VxWorks has the advantage of enabling a Java application to make use of real-time properties of VxWorks.  One subsystem can run as C application, and Java Native Interface (JNI) can be used to switch from a C context to a Java context.

The following vibration sensor application illustrates use of JNI in VxWorks Micro Runtime.  A set of sensitive accelerometers and strain gauges are mounted to a bridge for structural testing.  A VxWorks real-time application written in C calculates the tremor magnitudes and frequencies from the sensor readings.  An Micro Runtime Java application uses JNI to access these calculations.  Using readily available 3rd party libraries, the Java application publishes the tremor calculations to an MQTT broker, and I can visualize that data on my phone, or analyze that data further to make predictions.

The Micro Runtime application uses the Resty client library to access OpenWeatherMap web API to retrieve the prevailing wind speed and direction and compensate for some of the wind movement.

Fig 3

Figure 3.  Vibration detection VxWorks Micro Runtime application block diagram

The result is a graph on my TeleMecha MQTT app showing vibration spikes corresponding to a car crossing the bridge.  In this particular physical setup, only a single accelerometer was used and placed for a few minutes on a local bridge.

fig 4 telemecha

Figure 4.  Bridge vibration data from VxWorks Micro Runtime published to MQTT broker

On VxWorks, the query for wind speed at the same location showed some slight winds.

Received value = {“base”:”stations”,”clouds”:{“all”:75},”cod”:200,”coord”
:{“lat”:37.77,”lon”:-122.24},”dt”:1491600900,”id”:5322737,”main”:
{“humidity”:82,”pressure”:1012,”temp”:16.08,”temp_max”:18,”temp_min”:13},
“name”:”Alameda”,”sys”:{“country”:”US”,”id”:439,”message”:0.0055,”sunrise”
:1491572606,”sunset”:1491619112,”type”:1},”visibility”:16093,”weather”
:[{"description":"light rain","icon":"10d","id":500,"main":"Rain"},{"description"
:"mist","icon":"50d","id":701,"main":"Mist"}],”wind”:{“deg”:210,”speed”:6.2}}

Time:  4/7/17 2:35 PM
Location:  Alameda
Temperature: 16.08 degrees Celsius
Wind speed: 6.2 metres/second
The Micro Runtime application shown here takes advantage of JNI to access real-time functionality, 3rd party IoT libraries for efficient code reuse, and deployment of the same application on multiple platforms for fast development.

Debugging on VxWorks Micro Runtime

The VxWorks integrated development environment is Wind River Workbench, an Eclipse-based tool for developing, debugging, and testing VxWorks applications.  To debug the Java application, Workbench connects to the Java engine executing on VxWorks.  Once connected, I can set breakpoints, step through Java code, read variable values, and evaluate expressions.

Fig 5

Fig. 5.  Remote debugging of VxWorks Micro Runtime application

With the use of VxWorks Micro Runtime java engine and Wind River Workbench development environment , this application was fairly simple to put together.  The benefits of using the Java programming language was evident in the short development timeline.

You can find VxWorks Micro Runtime product information at http://www.windriver.com/products/product-overviews/Micro-Runtime-Product-Overview/.

 

 

Tweet about this on TwitterShare on Google+Share on FacebookShare on LinkedInEmail this to someone