Java SerialPort using COMM API
Hi All,
I am trying to develop a java program that will dial a GSM modem and send some data over it.For developing this i am using java rxtxcomm API with jdk 1.6_38 on windows 7 OS.I am using notifyOnDataAvailable method in order to listen to any incomming data.
The following is the set of steps i need to perform
1) I am first executing AT command to check if the modem is connected or not
outpursteam.write("AR\r");
the above statement should return OK if the modem is connected.
2) then i will try to dial the number using DTD<modileNo> which should return CONNECT 9600.
if the remote party is nor responding or some problem in dialing the above command will returrn ERROR
3) Once the connection is open and no operation is performed for 1 Minute the connection will be closed by the destination which will be indicated By NO CARIER message.
when i run my program the first statement will return OK so now i am dialing the specified destination number (Step 2) it should return CONNECT 9600 but i did not get any message.After 1 minute i am getting both CONNECT 9600 and NO CARIEIER message together.
Can some one help me in resolving this problem
Thanks&Regards
kishore.m
Presumably step 2 has a \r on it.
Similar Messages
-
Can i develope a java application using C API
hai,
i have C api, the project was developed in C before, now i am having that api. I have to do that in java by using that C api.
can any one suggest me how to do this?Your question is not that very clear!! You want to convert the C api to a Java api? or you want to develop a Java application that uses the C api?
For the first question I believe that you should check the functionality of the C api and re-code it in Java! do not believe you should find anything imposible in that! (unless that api is trying to do something crzy directly with memory)
For the second question then I believe you will have to use native calling or something like that. I have never used it, but read about it, and it seems one way how Java can interect with C.
Over here there is a forum.
Regards,
Sim085 -
[METASOLV XML AP]devolop JAVA client using XML API for metasolv application
Hi All,
I am new in this group, and I need to help me to develop a java client to communicate with metasolv application using XML API.
I read "XML API Developer’s Reference" document, but I still not understand how can I setup the cllient.
I still need:
1- What API needed(jar files) I must use to build the client
2- A sample of source code using java.
3- detailed guide to communicate with metasolv application using XML API.
Thanks&Best Regards
RADOUANE Mohamedany help please!!!!
-
I am trying to use Sun's Comm API with Web Start so I can access COM1 from my application.
When the application starts, I receive an exception for the CommPortIdentifier. When I run this
application as a standalone, it works fine. I have to assume that there is a problem with the
deployment of the Comm API.
I have include the win32com.dll in a jar file and defined it in the nativelib tag in the jnlp file.
The comm.jar and the javax.comm.properties files are include in another jar. I am not sure
what is the proper way to deploy these files and cannot find any documentation on this.
Does anyone know the correct way to handle this?I have include the win32com.dll in a jar file and
defined it in the nativelib tag in the jnlp file.
The comm.jar and the javax.comm.properties files are
include in another jar. I am not sure
what is the proper way to deploy these files and
cannot find any documentation on this.
should like like this
<resources>
<j2se version="..." href="..."/>
<jar href="application.jar"/>
<jar href="comm.jar" />
</resources>
<resources os="Windows">
<nativelib href="win32com.dll"/>
</resources>
Then in the code in application.jar, call
System.loadLibrary("win32com");
/Dietz -
Error -- Java code using OIM API to find no of users in OIM
Hi Experts,
I hav a requirement that I need to query OIM to find out the total no of active users in the system using a stand alone java program to determine some other process. So I have developed a simple java code but it fails in the below line
rset=userIntf.findAllUsers(map); -- It throws null pointer exception
I have tried with deleteUser() instead of findUsers() , still it throws the null pointer exception on the same line.I have checked the other posts in the forum but could not find out where is the mistake. Can u please suggest me??
Here is the code
System.setProperty("XL.HomeDir","D:/bea-oim/xellerate");
System.setProperty("java.security.auth.login.config","D:/bea-oim/xellerate/config/authwl.conf");
System.setProperty("java.security.policy","D:/bea-oim/xellerate/config/xl.policy");
System.setProperty("log4j.configuration","D:/bea-oim/xellerate/config/log.properties");
tcUtilityFactory utilityFactory = null;
tcUserOperationsIntf userIntf = null;
try
tcResultSet rset;
ComplexSetting config = ConfigurationClient.getComplexSettingByPath("Discovery.CoreServer");
final Hashtable env = config.getAllSettings();
tcSignatureMessage moSignature = tcCryptoUtil.sign("xelsysadm","PrivateKey");
utilityFactory = new tcUtilityFactory(env, moSignature);
userIntf=(tcUserOperationsIntf)utilityFactory.getUtility("Thor.API.Operations.tcUserOperationsIntf");
HashMap map = new HashMap();
map.put("Users.Status","Active");
rset=userIntf.findAllUsers(map);
System.out.println(rset.getRowCount());
catch(NullPointerException ne)
System.out.println(ne.getMessage());
ne.printStackTrace();
catch(Exception e)
System.err.println(e.getMessage());
e.printStackTrace();
Thanks & Regards
INIYA* To change this template, choose Tools | Templates
* and open the template in the editor.
import java.util.HashMap;
import java.util.Properties;
import java.util.*;
import Thor.API.tcUtilityFactory;
import Thor.API.Operations.*;
import Thor.API.tcResultSet;
import com.thortech.xl.crypto.tcCryptoUtil;
import com.thortech.xl.util.config.ConfigurationClient;
* @author Rajiv
public class CreateBulkUsers {
public static void main(String args[])
System.setProperty("XL.HomeDir", "E:\\oim\\server\\xellerate");
System.setProperty("java.security.auth.login.config", "E:\\oim\\server\\xellerate\\config\\auth.conf");
System.setProperty("java.security.policy", "E:\\oim\\server\\xellerate\\config\\xl.policy");
tcUtilityFactory utilityFactory = null;
tcUserOperationsIntf userIntf = null;
try
com.thortech.xl.util.config.ConfigurationClient.ComplexSetting config = ConfigurationClient.getComplexSettingByPath("Discovery.CoreServer");
java.util.Hashtable env = config.getAllSettings();
com.thortech.xl.crypto.tcSignatureMessage moSignature = tcCryptoUtil.sign("xelsysadm", "PrivateKey");
utilityFactory = new tcUtilityFactory(env, moSignature);
// System.out.println((new StringBuilder()).append("utilityFactory = ").append(utilityFactory).toString());
userIntf = (tcUserOperationsIntf)utilityFactory.getUtility("Thor.API.Operations.tcUserOperationsIntf");
HashMap map = new HashMap();
map.put("Users.Status", "Active");
tcResultSet rset = userIntf.findAllUsers(map);
System.out.println(rset.getRowCount());
catch(NullPointerException ne)
System.out.println(ne.getMessage());
ne.printStackTrace();
catch(Exception e)
System.err.println(e.getMessage());
e.printStackTrace();
Include all the JARs to run this class from outside not only of OIm of JBoss or Weblogic also.
eg: jboss\client and jboss\lib -
Hi,
I am developing an applet which uses Java Comm API. I'm running into some deployment issue. My understanding is that Java Comm API needs to have win32com.dll and javax.comm.properties files installed on the client machine for my applet to use Comm API. Is there a way around this? The ideal way will be to have everything (win32com.dll and javax.comm.properties) in a jar file so that it doesn't need to install any file on the client machine. However looking at previous posts, I don't think that's possible with Java Plug-in. Will I be able to utilize Java WebStart to accomplish this? I'll be interested to find how other people deploy Java Comm API. Thanks in advance.
Regards,
JoyI�ve developed a solution to this problem. I created a class that creates the javax.comm.properties file where the comm.jar lib looks for it. The trick is to run the method that creates the file before the lib looks for it.
I show you the example of my code:
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public final class PrinterInit {
public static void printerInit(){
String archivoConf =
System.getProperty("java.home") + File.separator + "lib" +
File.separator + "javax.comm.properties";
try {
BufferedWriter out = new BufferedWriter(new FileWriter(archivoConf));
out.write(
"#"+ "\n" +
"# Drivers loaded by the Java Communications API standard extension"+ "\n" +
"# at initialization time "+ "\n" +
"# "+ "\n" +
"# Format: "+ "\n" +
"# Each line must contain ONE driver definition only "+ "\n" +
"# Each line must be of the form: "+ "\n" +
"# driver=<ClassName> "+ "\n" +
"# No spaces or tabs in the line. "+ "\n" +
"# ClassName must implement the interface javax.comm.CommDriver "+ "\n" +
"# example: driver=Win32Serial"+ "\n" +
"# "+ "\n" +
"#"+ "\n" +
"# The hash(#) character indicates comment till end of line."+ "\n" +
"#"+ "\n" +
"# Windows Serial Driver"+ "\n" +
"Driver=com.sun.comm.Win32Driver" + "\n");
out.close();
} catch (IOException e) {
System.err.println("No se pudo crear el archivo:" + "javax.comm.properties");
System.err.println("Ruta completa:" + archivoConf);
}Before opening the port I call
PrinterInit.printerInit();This example writes de javax.comm.properties file needed for a windows implementation. You can change the value of the Driver property for the system you are using.
Good Luck! -
I want to use comm api with JSP on windows platform.
I am using Tomcat 5.0 for running JSP.
On Sun's site comm api available only for solaris and linux platforms.
what should i do?
I also want to know prefered settings for configuring comm api with Tomcat. i.e.Where should i put appropriate comm API file in Tomcat?
Please also mention the necessary settings for classpath.
Thanks for help in advance.Version 2.0 of Java Communications was available for Windows, though I can't see how to download it from the Sun web site now...
-
Hello,
I used COMM API with JDk1.3.1 & 1.3.0. It worked fine for first few times....But after some times, it started
giving errors while compiling -->
Note: c:\temp\CommPortIdentifier.java uses a deprecated API. Recompile with "-d
eprecation" for details.
COMM API version is 2.0..............
Thank You !!
MayurYou do NOT need to compile classes of the comm api. Just put comm.jar in your JDK's jre/lib/ext directory and the comm api will be available to you. Get rid of the java source files unless you want to know what they are doing.
-
Hi!
I've gone through sun's examples on how to use comm api.
Are there any detailed tutorials anywhere which one can use to learn the intricacies of the comm api? This is because one can go through the code or even the javadoc and get already written code to run, but a good detailed tutorial somewhere always helps a great deal to really plunge into the essence of the technology in use.
I'm an undergrad student and my aim is to send AT commands to a cell phone using a JAVA applet as well as receive responses from it through the JAVA applet.
Thanks alot for all your help.This is a very well commented piece of code and is a good tutorial for the javx.comm api!
http://discussion.forum.nokia.com/forum/showthread.php?s=ffbe2f2bf1e0d951ec1a0867c9470bd0&threadid=27929&highlight=%2Ajavax.comm%2A -
How Can I execute a java program using java code?
{color:#000000}Hello,
i am in great trouble someone please help me. i want to execute java program through java code i have compiled the java class using Compiler API now i want to execute this Class file through java code please help me, thanks in advance
{color}Thanks Manko.
i think my question was not clear enough.. actually i want to run this class using some java code . like any IDE would do i am making a text editor for java, as my term project i have been able to complie the code usign compiler api and it genertaes the class file but now i want to run this class file "THROUGH JAVA CODE" instead of using Java command. I want to achive it programatically. do you have any idea about it.. thanks in advance -
How to invoke the JwscTask using Ant Api
Hi,
I need to invoke the weblogic JwscTask <jwsc> from a java class using Ant API, one way to do this is to write a build.xml file with the specified ant task and use the appropriate Ant api, whereas my requirement is to directly create a Task object and run the task how should one go about doing the same as the JWSCTask API is not open.
Thanks in advance
Regards,
PreethiHi,
I will agree with Martin on first you should take a step back and see the business drive for the use case but stil if you have to do it below is my thought to fire disable/enable task.
1.Insteed of firing a particular enable/disable task its better to enable/disable the resource.
2.To enable/disable the object instance you can use enableAppForUser()/disableAppForUser() method of tcUserOperationIntf which will in end will fire enable and disable task.
To kick of update task I will suggest to update the form field usingsetProcessFormData() method if tcFormInstanceOperationsIntf which will in result will kick of the update task.
Hope this will help.
Regards
Nitesh -
Help...problems using java comm API
Hi all
im using Fedora Core and in order to list all the available serial ports for my computer i'm using the classic program TestEnumeration, but when running from jbuilder 2005 not from shell i received the following errors:
Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library.path
Caught java.lang.UnsatisfiedLinkError: readRegistrySerial while loading driver com.sun.comm.SolarisDriver
Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library.path
Caught java.lang.UnsatisfiedLinkError: readRegistrySerial while loading driver com.sun.comm.SolarisDriver
warning: no ports found - make sure javax.comm.properties file is found
i have followed all the instruction to install comm API but i received the same error i need help plz if someone can
thximport java.io.*;
import java.util.*;
import javax.comm.*;
import java.lang.*;
import java.Buff.*;
public class SimpleRead implements Runnable, SerialPortEventListener
static CommPortIdentifier portId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
public static void main(String[] args)
{//System.out.println("hello");
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements())
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
if (portId.getName().equals("COM1"))
// if (portId.getName().equals("/dev/term/a")) {
SimpleRead reader = new SimpleRead();
public SimpleRead()
try
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
catch (PortInUseException e)
System.out.println(e);
try
inputStream = serialPort.getInputStream();
catch (IOException e)
System.out.println(e);
try
serialPort.addEventListener(this);
catch (TooManyListenersException e)
System.out.println(e);
serialPort.notifyOnDataAvailable(true);
try
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
catch (UnsupportedCommOperationException e)
System.out.println(e);
try {
out = new OutputStreamWriter(serialPort.getOutputStream());
out.write("ATQ0V1E0");
out.flush();
out.write("ATQ0V1E0");
Out.close();
//System.out.println("ATQ0V1E0");
catch (IOException e) {}
try {
int line;
int result ;
InputStream = serialPort.getInputStream();
int num= inputStream.available();
InputStreamReader reader = new InputStreamReader(inputStream);
System.out.println(reader.ready());
while ((line = reader.read()) <= 0)
result =reader.read();
System.out.println("Success " + result);
reader.close();
catch (IOException e) {}
readThread = new Thread(this);
readThread.start();
try {
OutputStream = SerialPort.getOutputStream();
catch (IOException e) {}
System.out.println("ATQ0V1E0");
public void run()
try
Thread.sleep(500);
catch (InterruptedException e)
System.out.println(e);
public void serialEvent(SerialPortEvent event)
switch(event.getEventType())
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
byte[] readBuffer = new byte[20];
try
while (inputStream.available() > 0)
int numBytes = inputStream.read(readBuffer);
System.out.print(new String(readBuffer));
catch (IOException e)
System.out.println(e);
break;
hi friends am getting these errors
C:\programs>javac SimpleRead.java
SimpleRead.java:115: illegal start of expression
public void run()
^
SimpleRead.java:159: ';' expected
^
2 errors
please help me....
its very urgent....this is the first program of mine.... am so tensed..
i should finish this soon... please help me...
this is my mail ID
[email protected] -
Problem in Accessing serial port using java comm Api
I have installed java comm Api in my pc.
i have gone through the instalation instruction which comes on this package.
I have done the instalation like this
Copy win32com.dll to my <JDK>\bin directory.
Copy comm.jar to my <JDK>\lib directory.
Copy javax.comm.properties to my <JDK>\lib directory.
and restart the system.
But when i run the BlackBox , it is giving me message
"serial port not found".
Can any one tell me , what is the exact problem ?I'm not sure what you mean by BlackBox, but I have used the COMM api extensively.
The majority of problems is that the api cannot see the serial port (which is what you are describing) and this is caused by incorrect placing of the javax.comm.properties file.
As well as <JDK>\lib, try putting it into <JRE>\lib as well. That has often solved problems on my setup. -
How to use the COMM API in a JAR file
I have developed an application, using the NetBeans IDE, to communicate with a modem over the COM1 serial port using the Java Comm API. The application works fine within the IDE, but when a JAR file is created and "double-clicked", the application launches correctly, but when the code is executed to "talk" over the COM1 serial port - nothing happens. No exceptions and no warnings are thrown. My environment is XP, SP1.
The manifest file is as follows:
Manifest-Version: 1.0
Class-Path: ../j2sdk1.4.2/jre/lib/ext/TimerBean.jar ../j2sdk1.4.2/jre/
lib/ext/AbsoluteLayout.jar ../j2sdk1.4.2/jre/lib/ext/comm.jar
Created-By: NetBeans IDE
Specified-By: Projects/TheApp/Files/TheApp.jarContent
Main-Class: Main
According to the Comm API installation instructions, the following files are copied:
copy comm.jar \j2sdk1.4.2\jre\lib\ext
copy wind32com.dll \j2sdk1.4.2\bin
copy javax.comm.properties \j2sdk1.4.2\jre\lib
I suspect it has something to do with the paths.
Any help would be greatly appreciated. Thanks.Thanks for your input, but after trying what you suggested the problem still exists. I think your right to be suspicous of the javax.comm.properties file. The application, that worked in the IDE, exhibits the same behavoir as the JAR file if the javax.comm.properties file is removed from the ../jre/lib directory. In other words it compiles correctly in the IDE, but when executed, nothing happens when the code that "talks" to the serial port is run.
I've tried moving the javax.comm.properties file into the working directory. Also, the CLASSPATH and PATH system variables were modified to include the path to javax.comm.properties.
If you have anymore ideas, please let me know.
Thanks. -
Stand Alone OC4J and Java's Comm API
I am using the Java Comm API alongwith a servlet. The code simply gets the required ports and displays it in a JSP page. The program is developed using Jdeveloper 9. It works fine with embedded OC4J but a blank jsp page is displayed when deployed in in standalone OC4j instance on the same machine. I have correctly copied the required wincom32.dll, java.comm.properites and comm.jar to the jre/bin, jre/lib and jre/lib/ext respectively. What could be wrong.
Thanks
MMNTry setting the OS PATH env variable to the directory where the .DLL is located before you launch the container. Or else put the .DLL in a directory which is in the existing path.
cheers
-steve-
Maybe you are looking for
-
I get the following msg's. This happening more often, and when I back out to restart it may take a couple of times so that I do not get the error msg's? Exc in ev handl: TypeError: oSAPlg.oRoot.log is not a function Exc in ev handl: Error: Bad NPObje
-
Is there any info on how ASP can access and get information from a jar on a server?
-
[RELEASE] ez-type URLS for PSP
Thought I would send this in, incase anyone is interested. Hayden ez-type URLS is an easy to use alternative to PSP's built-in text entry system, for typing URLs to web sites and file paths to Flash games saved on a memory stick. Select pre-typed url
-
Aol screen name to sign into itunes
yesterday i went into my itunes account using my aol screen name and password. today i tried logging in and it is non existent. can't update my apps on my phone without logging in. the 800 number to call AOL is a joke. can't get a real person on the
-
Were any i-phones sold in US yesterday, Sunday, 09/07?
Finally, my phone was eligible for an upgrade yesterday...hurried to my local (Nashville, TN) Apple store only to be told that they had the phones in stock but could not sell one because the AT & T servers had been down all day... Does that mean that