Solved

Sun Comm Api 2.0 for Windows XP

Posted on 2007-11-28
13
4,455 Views
Last Modified: 2013-11-24
I am developing software in Java within the Motorola MOTODEV Studio for Java(TM) ME v7.3 IDE.  I have found out that the communication API from Sun for serial communication within XP only works with the older jar file.  I have the three files:

comm.jar
win32com.dll
javax.comm.properties

and I placed them in the following directories according to this reference http://dn.codegear.com/article/31915

comm.jar should be placed in:
%JAVA_HOME%/lib
%JAVA_HOME%/jre/lib/ext

win32com.dll should be placed in:
%JAVA_HOME%/bin
%JAVA_HOME%/jre/bin
%windir%System32

javax.comm.properties should be placed in:
%JAVA_HOME%/lib
%JAVA_HOME%/jre/lib

I  went into the environmental variables within windows XP and created a system variable called JAVA_HOME and gave it the path
C:\Program Files\Java\jdk1.6.0_02

When i go within my ide and try to run a class file which i created provided by jamod (Java Modbus http://jamod.sourceforge.net/)
i get the following error.


Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library.path
Caught java.lang.UnsatisfiedLinkError: com.sun.comm.SolarisDriver.readRegistrySerial(Ljava/util/Vector;Ljava/lang/String;)I while loading driver com.sun.comm.SolarisDriver
java.lang.Exception
      at net.wimpi.modbus.net.SerialConnection.open(SerialConnection.java:99)
      at SerialAITest.main(SerialAITest.java:53)

In the project within the IDE i configured the build path and pointed to the comm.jar file in the JAVA_HOME directory.

Within the IDE when i go to the configuration details i see under the system properties category the listing:
*** System properties:
MOT_SDK_HOME=c:\Program Files\Motorola\MOTODEV Studio for Java(TM) ME v7.3\JMESDK

Does this mean that my java home location is not JAVA_HOME but rather MOT_SDK_HOME??
Can anyone help??????

I attached the SerialAITest.java file which uses the jamod.jar and the comm.jar files.  The program craps out at the 4th step where it trys to open a serial connection.  I am pretty certain that the issue is something with the Sun Comm API
import net.wimpi.modbus.ModbusCoupler;
import net.wimpi.modbus.io.ModbusSerialTransaction;
import net.wimpi.modbus.msg.ReadInputRegistersRequest;
import net.wimpi.modbus.msg.ReadInputRegistersResponse;
import net.wimpi.modbus.net.SerialConnection;
import net.wimpi.modbus.util.SerialParameters;
 
public class SerialAITest {
 
  public static void main(String[] args) {
	//if (args.length < 4) {
	//	System.out.println("not enough args");
	//	System.exit(1);
	//}else{
    try {
     System.out.println("hello");
     /* The important instances of the classes mentioned before */
     SerialConnection con = null; //the connection
     ModbusSerialTransaction trans = null; //the transaction
     ReadInputRegistersRequest req = null; //the request
     ReadInputRegistersResponse res = null; //the response
 
     /* Variables for storing the parameters */
     String portname= "COM1"; //the name of the serial port to be used
     int unitid = 1; //the unit identifier we will be talking to
     int ref = 1259; //the reference, where to start reading from
     int count = 1; //the count of IR's to read
     int repeat = 1; //a loop for repeating the transaction	 
     boolean isopen = false;
     
     
//   2. Set master identifier
     //ModbusCoupler.createModbusCoupler(null);
     //ModbusCoupler.getReference().setMaster(master); I added this in
     //ModbusCoupler.getReference().setMaster(true);
    // ModbusCoupler.getReference().setUnitID(1);	
     
//     3. Setup serial parameters
     SerialParameters params = new SerialParameters();
     params.setPortName("COM1");
     params.setBaudRate(9600);
     params.setDatabits(8);
     params.setParity("None");
     params.setStopbits(1);
     params.setEncoding("RTU");
     params.setEcho(false);
   
     System.setProperty("net.wimpi.modbus.debug", "true");
//   4. Open the connection
     con = new SerialConnection(params);
     System.out.println("Connection..." + con.toString());
     con.open();
     
     
     isopen = con.isOpen();
     System.out.println("Serial port status..." + isopen);
     
     
//   5. Prepare a request
     req = new ReadInputRegistersRequest(ref, count);
     req.setUnitID(unitid);
     req.setHeadless();
     
//   6. Prepare a transaction
     trans = new ModbusSerialTransaction(con);
     trans.setRequest(req);
     
//	 7. Execute the transaction repeat times
     int k = 0;
     do {
       trans.execute();
       res = (ReadInputRegistersResponse) trans.getResponse();
       for (int n = 0; n < res.getWordCount(); n++) {
         System.out.println("Word " + n + "=" + res.getRegisterValue(n));
       }
       k++;
     } while (k < repeat);
     
//   8. Close the connection
     con.close();
     
    } catch (Exception ex) {
      ex.printStackTrace();
    }
	//}//else
  }//main
  
}//class SerialAITest

Open in new window

0
Comment
Question by:teamcosmo02
  • 7
  • 6
13 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20370450
jamod appears to trying to load the solaris driver
0
 
LVL 92

Expert Comment

by:objects
ID: 20370470
whats the properties file contain?
0
 

Author Comment

by:teamcosmo02
ID: 20370487
Here is the contents of the properties file:


# javax.comm.properties (Solaris)
#
# This properties file is necessary in order for javax.comm to run,
# and its contents are critical, and not to be tampered with without
# a very clear understanding of the impact.  It is shipped with a 
# default set of values that work on the target platform.
#
# 1. The directory javax.comm is launched from
# 2. Each directory in the classpath (including the one in which comm.jar is in)
# 3. <jvm dir>/lib
# 4. <jvm dir>/jre/lib
#
# The following properties must be defined:
#
#   driver
#   serpath0 ... serpath<n>
#   parpath0 ... parpath<n>
#
#
# Driver:
#
#   The driver property specifies the fully qualified class name of the
#   platform specific implementation of the javax.comm.CommDriver class.
#
#   Format:
#
#     driver=<fully qualified classname>
#
#   Example:
#
#     driver=com.sun.comm.SolarisDriver
#
# Port paths:
#
#   Port paths must be specified to indicate to the implementation
#   which are the core set of ports to make available. These can
#   be either paths to directories containing ports or paths to
#   specific serial or parallel ports.
#
 
# Implementation specific driver
driver=com.sun.comm.SolarisDriver
 
# Paths to server-side serial port devices
serpath0 = /dev/term
serpath1 = /dev/cua
 
# Paths to server-side parallel port devices
parpath0 = /dev/ecpp0
parpath1 = /dev/printers

Open in new window

0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 92

Expert Comment

by:objects
ID: 20370490
thats the solaris version, you should be using the windows one
0
 

Author Comment

by:teamcosmo02
ID: 20370755
can i edit the existing file or is there some place i can dowload the windows version?  i'm having trouble finding one
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 20370849
driver should be:

com.sun.comm.Win32Driver

change the ports to whats on your box
0
 

Author Closing Comment

by:teamcosmo02
ID: 31411568
Fantastic service!!
0
 

Author Comment

by:teamcosmo02
ID: 20371473
i am still having a problem.  I am now getting the error message
java.lang.Exception
      at net.wimpi.modbus.net.SerialConnection.open(SerialConnection.java:99)
      at SerialAITest.main(SerialAITest.java:55)

It is occurring at the same line where it uses the open method.  Any ideas?  I edited the javax.comm.properties file to the windows driver.
0
 
LVL 92

Expert Comment

by:objects
ID: 20371497
did u update the ports?
0
 

Author Comment

by:teamcosmo02
ID: 20393393
what do you mean by updating the ports?
0
 
LVL 92

Expert Comment

by:objects
ID: 20393407
the port config in the properties file
0
 

Author Comment

by:teamcosmo02
ID: 20393642
do you know what the serpath0 and serpath1 values should be for windows xp sp2 x86 ?
0
 
LVL 92

Expert Comment

by:objects
ID: 20393722
don't sorry
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
oracle 11g 23 87
Tomcat: Unable to run tomcat service. 2 20
Convert from a json string array to a Java object 3 36
going to wrong jsp page 2 22
If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question