Common JNI Errors PDF Print E-mail
Written by martcon   
Monday, 05 January 2009 16:33

(Note: This post is principally relevant for MS Windows users.)

Vertoda doesn't use JNI directly but we have used it for other projects. In a nutshell, JNI (Java Native Interface) is a Java programming library that runs in the Java VM (Virtual Machine) and can call or be called by programs written for specific hardware or operating systems (referred to as native applications) as well as programs deployed as libraries and written in languages such as C and C++.

JNI is a very useful tool for accessing legacy code or libraries specific to a particular operating system. Device driver software is a good example as drivers for printers, monitors etc. are typically written for a specific operating system. Another example would be software for Serial COM ports. Data coming into acquisition boards for WSNs can be detected by a Java program listening on the Serial COM port to which the board is attached using the Java Communications API (http://java.sun.com/products/javacomm/). Given that Serial Port access is OS specific, this API uses JNI to access programs performing MS Windows specific functionality. A separate LINUX version is also available (http://www.agaveblue.org/howtos/Comm_How-To.shtml).

However, JNI can be frustrating to use initially. One must ensure that the paths to any libraries accessed are included. For example, let's say we're using a library called MyTest.dll and it's located in a directory called C:\MyDLLs. (A dynamic link library or DLL is a Microsoft Windows specific library.) Assume that we also have a Java JAR using JNI to access this DLL called MyJNITest.jar. We run the program using the following command:

java -Djava.library.path="C:\MyDLLs" -jar MyJNITest.jar

Note that we reference the path to the DLL in our -D runtime option but not the DLL file itself. If you don't specify this path you will get the following error:

java.lang.UnsatisfiedLinkError: no MyTest.dll in shared library path

Unfortunately, if our DLL depends on another DLL (say, MyOtherDLL.dll) then we will still get the following error:

java.lang.UnsatisfiedLinkError: "Can't Find Dependent Libraries"

This appears to be because JNI looks in the directory we specify for our java.library.path option but looks in the PATH environment variable for the directory location of DLLs on which our own DLL depends.

The first thing to do is find out what other DLLs our own DLL depends on. The easiest way to achieve this if you have Microsoft Visual Studio installed is the following:

  • Open a Command Line Window.
  • You will be using a file called dumpbin.exe. If you have Visual Studio installed this will be in C:\Program Files\Microsoft Visual Studio 8\VC\bin so cd to this directory.
  • Assuming our DLL is called MyTest.dll and is located in the C:\MyDLLs directory path we would run the following command:

             dumpbin.exe "C:\MyDLLs\MyTest.dll" /dependents

  • (Note that dumpbin.exe can be problematic on MS Vista. This will be the subject of another post.)
  • This will show what other libraries and DLLs our file depends on.

Let's assume we have one dependency called MyOtherDLL.dll located in a directory called C:\MyOtherDLLs. We can now add this directory to our path variable as follows:

  • On MS Vista click on the Windows button | Computer | System Properties to open the Control Panel.
  • Click on Advanced System Settings to open the System properties dialog and click on the Environment Variables pushbutton.
  • This opens the Environment Variables dialog window.
  • In the System Variables listbox select the PATH environment variable and click on the Edit pushbutton.
  • Assuming your dependency is located in C:\MyOtherDLLs add this to the path variable. Ensure that you postfix a semi-colon (;). Prefix a semi-colon (;) if it's the last entry.

You should now be able to run your JNI program.

 
Sun SPOTs PDF Print E-mail
Written by martcon   
Tuesday, 16 December 2008 15:22

Many commercial and academic organisations are involved in WSN development. Since Java runs on a myriad of devices from PC Servers to Blu Ray Players to Smart Phones it is only to be expected that Sun Microsystems would be one of these organisations. Sun SPOT (Small Programmable Object Technology) was launched in April 2007.  The most recent version is 4.0. The Sun SPOT project (see http://www.sunspotworld.com for more details) consists of a software development kit for programming Sun SPOT sensors and for taking readings into a PC. A typical Sun SPOT kit consists of two Sun SPOTs (a processor, sensor board, radio and battery) and a base station for connecting to a PC.

The motes communicate using the IEEE 802.15.4 standard and Zigbee can be run on top of the MAC layer.  Unlike other motes, Sun SPOTS have no operating system. Instead, they use a J2ME (Java Micro Edition) Virtual Machine (VM) called Squawk.

The clear advantage Sun SPOTs have over nesC programmable TinyOS based sensors is the familiarity and experience  many software engineers and IT professionals have with programming in Java. It is not a huge leap to move from programming for a Smart Phone or a J2EE (Java Enterprise Edition) application to programming a wireless sensor as the language is the same. By contrast,  nesC does represent a learning curve even for engineers who have substantial experience in programming in C and C++.

Another advantage the Sun SPOT project has over its nesC and TinyOS counterparts is the availability of an emulator that is easy to set up and use. This saves both time and money during WSN project development. There are certainly emulators available for TinyOS but none so convenient to use as the Sun SPOT equivalent. Emulators postpone the purchase of what can often be very expensive devices for those projects with constrained budgets.

One question regarding the use of Java with small devices like sensors would relate to speed. Given its use of a virtual machine, programs written in Java are slower than  their C and C++ equivalents so one may expect the same with Sun Spots compared with their nesC siblings. However, one must consider the fact that programmable sensors have quite limited functionality and that there is little anecdotal evidence or complaints about the speed of Sun SPOTS. It should also be noted that we are not dealing with a situation of a VM running over an operating system as the VM has device driver code to interact with the sensor hardware directly.

There is some evidence regarding an issue with battery life performance however. We have found that Sun SPOTs used in a project for monitoring motion had a battery life of approximately 7 hours. By contrast, TinyOS sensors have a battery life of up to 3 years. Further studies would be needed before we could draw any definitive conclusions.

Users will be able to use Sun SPOTs with Vertoda as we will be integrating a host application for reading data from these devices in a forthcoming edition of the system.

 
LinkedIn & Facebook PDF Print E-mail
Written by martcon   
Tuesday, 09 December 2008 18:09

There are now groups for Vertoda on LinkedIn (http://www.linkedin.com) and Facebook (http://www.facebook.com).

 
WSNs & Food Quality PDF Print E-mail
Written by martcon   
Tuesday, 09 December 2008 16:03

In recent days, food quality and its monitoring have been in the news with the recall by Ireland of all its pork products. This emerged after organic pollutants known as polychlorinated biphenyls (PCBs) were detected in pork fat during routine monitorng. PCBs are dioxins that emanate from fires and other forms of combustion. A small number of dioxins can cause skin disease or cancer and can damage immune andreproductive systems. The essential cause of the problem in Ireland is that machine oil accidentally contaminated pig feed in a food recycling plant. This feed was then given to pigs in just 19 farms in the island of Ireland but because pork is used in diverse products including processed foods it is perceived as difficult to trace. The economic effects are potentially catastrophic. 1400 jobs have been lost so far in Irish pork processing industries and this could rise to 6000. And of course the damage to the image of Irish food is immense.

One could argue that the deployment of smart sensors could help avoid such disasters for the food industry. This of course is not the first problem with food quality and issues have occurred in virtually every continent. The key point is that WSNs can play a role in the detection of contaminants in a timely fashion. The recent incident in Ireland took 3 months to come to light. Regulation driving the deployment of sensors to detect contaminants in food producing environments would deliver information to food safety authorities on a timely basis. WSNs can be deployed throughout the supply chain. RFID or indeed RFID sensors could be used to tag and trace pork from the farm to the supermarket shelves thus removing the need for blanket recalls and the untold damage this does to the reputation of the food industry in a country.

We have already examined the issue of food quality and the role WSNs can play in assisting the maintenance of same in a whitepaper on our site. We will be publishing an updated version of this paper in the coming year.

 
Smart Appliances & Vertoda PDF Print E-mail
Written by martcon   
Monday, 08 December 2008 10:46

Shifting energy usage from peak hours to other parts of the day is critical for greater energy efficiency. General Electric (GE) (http://www.ge.com) has recently launched a program for the delivery of smart appliances with the goal of superior energy management. For example, GE's smart refrigerator has an automatic defrost feature which is based on the number of times the refrigerator door is opened. The refrigerator can potentially delay defrost cycles from taking place during peak hours with the result that consumers pay less money for the same energy usage.

GE has also launched a program of smart appliances with Louisville Gas & Electric Company (LG&E).. Under this program, Energy management enabled appliances will be placed in a select number of participating pilot homes which will be equipped to receive and respond to signals from LG&E. This solution was discussed in a previous blog entry where it was argued that consumers and/or their smart meters/actuators would need to receive data about energy usage in order to respond appropriately. GE also intends to introduce energy management enabled ranges, laundry pairs, dishwashers and microwave ovens. Consumers will then be notified of a rate change or of peak pricing on their appliance displays so that consumers will know when higher rates are in effect. Appliances can be programmed to avoid energy usage at peak times but consumers will ultimately have control as they can override this program.

The diagram below summarises at a high level how energy data is transferred from smart grids to smart appliances. However, there is a lot of complexity and potential problems that need to be considered. For example, how is the usage data transferred from engineering units into a reading that makes sense to the consumer? Where is this energy usage data stored? How do we provide Business Intelligence capability for the vast quantities of energy usage data that is generated? How can we transfer this data from remotely located smart meters to a consumer's Internet account or their mobile phone? How can the utility company provide this data to the ERP and other Information Systems? Vertoda can provide an answer to all of these questions.

Smart Grids & Smart Appliances

The diagram below summarises the potential benefits of a smart metering system that integrates Vertoda. Raw data is translated by the Vertoda system and can be stored either in Vertoda's own database or loaded into the company's proprietary database system.The utility company's ERP, Business Intelligence and other Information Systems can all access the new pool of energy information for making decisions regarding energy needs and network planning. Consumers will also benefit from a utility company's use of Vertoda.Meaningful information can be delivered to smart appliances, mobile phones and email accounts in a timely fashion. Using Vertoda can help tap into the potential for smart grids and smart meters to more efficiently manage energy from the perspective of both the consumer and the supplier.

Smart Grid Appliances With Vertoda.

 
<< Start < Prev 11 12 13 14 15 16 17 18 19 Next > End >>

Page 17 of 19
RocketTheme Joomla Templates