Java comm problem

hi,
i'm new to comm api,
i want to know how to communicate with modem using the comm api.
coz i have run following code.
used diff AT commands to set modem properties.
but
I could just see the DTR bit of modem set and TD and RD bit were set just a fraction of sec. and then the program went into loop.
but i couldn't read anything from the inputStream.
Can anyone help me out?
Following is the code i used and output i got.
import javax.comm.*;
import java.util.*;
import java.io.*;
import java.io.DataOutputStream;
public class TestCommPort implements SerialPortEventListener
CommPortIdentifier portId;
Enumeration portIds;
SerialPort serialPort;
DataOutputStream outputStream;
BufferedReader inputStream;
static String centralPagingNo="1234567";
public static void main(String arg[])
     TestCommPort testCommPort =new TestCommPort();
     testCommPort.portIds=CommPortIdentifier.getPortIdentifiers();
     while (testCommPort.portIds.hasMoreElements())
          testCommPort.portId=(CommPortIdentifier)testCommPort.portIds.nextElement();
          if(testCommPort.portId.getName().equals("COM2"))
          System.out.println(testCommPort .portId.getName());
          try {
          testCommPort.serialPort = (SerialPort) testCommPort.portId.open("TestCommPort", 2000);
                    try{
                         testCommPort.serialPort.addEventListener(testCommPort);
               catch(java.util.TooManyListenersException tme){System.out.println(tme.getMessage());}
     catch (PortInUseException e) {System.out.println(e.getMessage());}
          try {
                    testCommPort.outputStream = new DataOutputStream(testCommPort.serialPort.getOutputStream());
                    testCommPort.inputStream = new BufferedReader(new InputStreamReader(testCommPort.serialPort.getInputStream()));
          catch (IOException e) {}
     try {
               if(testCommPort.serialPort.isDSR()==true)
               System.out.println("the dsr bit is set");
               if(testCommPort.serialPort.isRTS()==true)
               System.out.println("the rts bit is set");
               if(testCommPort.serialPort.isCD()==true)
               System.out.println("the cd bit is set");
               else
               System.out.println("the cd bit is not set");
               if(testCommPort.serialPort.isCTS()==true)
               System.out.println("the cts bit is set");
               try {
                    testCommPort.serialPort.setSerialPortParams(15200,
                    SerialPort.DATABITS_8,
                    SerialPort.STOPBITS_1,
                    SerialPort.PARITY_NONE);
                    } catch (UnsupportedCommOperationException e) {}
               try {
                    testCommPort.outputStream.writeChars("AT");
                    System.out.println("initializing modem");
                    testCommPort.outputStream.writeChars("ATQ0 <CR>");
                    testCommPort.outputStream.writeChars("ATM1 <CR>");
                    testCommPort.outputStream.writeChars("ATL2 <cr>");
                    testCommPort.outputStream.writeChars("ATV1 <cr>");
                    System.out.println("result code format option set to Verbose mode");
                    testCommPort.outputStream.writeChars("ATSr? <cr>");
                    System.out.println("reading sr registers");
                    System.out.println(testCommPort.inputStream.readLine());
                    testCommPort.outputStream.writeChars("ATI4 <CR>");
                    System.out.println(testCommPort.inputStream.readLine());
                    testCommPort.outputStream.writeChars("ATX4 <CR> ");
                    testCommPort.outputStream.writeChars("ATE1 <CR>");
                    testCommPort.outputStream.writeChars("ATDT 8655979; <CR>");
                    System.out.println(testCommPort.inputStream.readLine());
          } catch (IOException e) {}
     } catch (Exception e){System.out.println(e.getMessage());}
     public void serialEvent(SerialPortEvent se)
          if(se.getEventType()==SerialPortEvent.DSR)
          System.out.println("the data set is ready");
and the output is:
COM2
the dsr bit is set
the rts bit is set
the cd bit is not set
the cts bit is set
initializing modem
result code format option set to Verbose mode
reading sr registers

I was also getting strange results in a similar scenario.
I was using "AT\n" and getting strange results. The above solution, using "AT\r\n" fixed everything.
Just wanted to pass that along.
Thanks for the info.

Similar Messages

  • 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.

  • Java comm

    I HAVE A PROBLEM WITH JAVA-COMM.
    I USE THE JAVA-COMM FOR COMMUNICATION WITH GSM BUT I HAVE A PROBLEM WITH THE COMMUNICATION WHEN I RECEIVE THE REPLYES OF THE AT'COMMANDS.
    THE TIMEOUT NOT FUNCTION AND THE PROGRAMM GO IN BLOCK BECAUSE IT WAIT THE REPLY WHO NOT DELIVERED.
    I USE THE LISTENER. THERE IS ANOTHER METOD FOR ACCEPT THE REPLIES AND SET THE TIMEOUT?
    THANK.

    What platform are you using ? (Windows/Solaris...)
    Can your program print a list of all serial interfaces available and is your chosen interface in that list ?
    When your program outputs the AT command, does anything happen ?
    Does your serialEvent() method in the listener receive ANYTHING ?
    i.e. just print the eventType.
    Once you can see the DATA_AVAILABLE event, you can read data.
    The biggest problem I've had with the package is making sure it sees the interfaces in the first place.

  • Deploying Java Comm API

    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,
    Joy

    I�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!

  • Java comm api in 64-bit Linux

    I apologise if this is off-topic. I can't find a suitable forum, I tried posting in the Java plugin forum, but no luck there. I would appreciate any ideas to find a solution.
    I am trying to use the java comm api to read and write to the serial port but I am getting the following error:
    Error loading LinuxSerialParallel: java.lang.UnsatisfiedLinkError: /usr/lib64/libLinuxSerialParallel.so: Can't load IA 32-bit .so on a AMD 64-bit platform
    I am using openSUSE 10.2 (X86-64) which uses Linux 2.6.18.2-34-default x86_64.
    I tried Switching to a 32-bit version of java (1.4.2) from within Eclipse and I always run Eclipse in 32-bit java (/usr/share/eclipse/eclipse -vm /usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre/bin/java) but I still get this error.
    Is there anything I can do to get the java comm api working on a 64-bit system?
    Is the java comm api still being developed and maintained? It does not look like it is?
    I've done some searching on the web and I find there is an open source version of the java comm api called RXTX but the website at http://www.rxtx.org/ is not very readable. I don't think I know enough to install this on my system.
    I would appreciate any ideas to get this working.
    Thanks,
    Martin

    I'm stuck again so I would appreciate some more help.
    I've managed to install the Sun 1.6 JDK and configure
    and make rxtx.Any small amount of progress is still progress. :)
    >
    But it still does not work, I get the following error
    when I run the SerialDemo:<snip>
    >
    It seems to be com.sun.comm which is not finding its
    native binary not rxtx! No, it's finding the shared library, unless there are a few more lines at the start of your error message that look like this:
    Error loading LinuxSerialParallel: java.lang.UnsatisfiedLinkError:
    no LinuxSerialParallel in java.library.pathIt's not finding the function it is looking for in that library.
    This is what confuses me, the
    instructions say install the Solaris version of comm
    api (http://www.rxtx.org/ how-to said Solaris Sparc
    and the rxtx INSTALL file said Solaris x86 so I tried
    both in turn and neither worked) Same here after downloading the latest stuff to my x86 Linux box. I received a similar UnsatisfiedLinkError. I checked the shared libraries and the functions were not in it.
    normally these would
    call the Solaris binary drivers but I assume this has
    to be redirected to rxtx which calls its own
    binaries?Yes. There is a part of RXTX called JCL (Java Comm for Linux) that handles that.
    http://www.geeksville.com/~kevinh/linuxcomm.html
    However, I think the problem is that Sun's API has changed since the RXTX How-To was written. Try downloading the 'comm.jar' at the bottom of the page. It says:
    comm.jar, 2.0.3, generic, English (3rd party backward compatibility, only), EnglishUnzip it and copy the comm.jar file to the 'jre/lib/ext' folder of the JDK/JVM where everything else RXTX created was placed.
    After doing this the SerialDemo app started for me without errors.
    Jim S.

  • Troubles with Java Comm API

    I am trying to use the Java Comm API with Windows 2000 and I can enumerate the ports (I am almost sure that the problem is the dll). Do anybody knows a solution?

    Where is the problem?

  • Exception while using Java Comm and Java Web Start together

    Hello Java Experts!
    Here's the problem that's been bothering me. The application i'm developing uses Java Comm API to listen to Serial Ports. The application works absolutely fine when it is run locally.
    Now, I need to deploy this remotely using java web start. All resources(dependent jar files) are present on the server and are referenced properly in the JNLP file. All jar files are signed properly.
    Still, it throws the following exception.
    java.lang.NullPointerException: name can't be null
         at java.io.FilePermission.init(Unknown Source)
         at java.io.FilePermission.<init>(Unknown Source)
         at java.lang.SecurityManager.checkDelete(Unknown Source)
         at javax.comm.CommPortIdentifier.getPortIdentifiers(CommPortIdentifier.java:70)
    The exact line of code where it apparently seems to error out is...
    Enumeration portList = CommPortIdentifier.getPortIdentifiers();
    Are there any security issues involved here? Can a application deployed through java web start access serial ports on the system?
    Any pointers as to what the problem might be would be much appreciated.
    Thanks in advance!

    I have the IBM Communications API. I've
    been told that it works with Java Web Start but I
    have not tried it. IBM has changed it's download site
    so.... I can't point you to it. But I have it(55k zip'ed)
    and can send it to you if you post your E-Mail address
    of where you would like it sent.
    Bruce Houghton
    PS If it does work with Web Start please post the
    news here. I will be watching.

  • Java Comms

    Hi
    I had a program working using Java Comms API 2.0 and JDK 1.2.2. Since installing JDK 1.3.1_01 my app does not work. Has anyone experienced this problem and if so what did you do?
    Thanks

    If you still have problems, you might have to change your CLASSPATH variable. To see if this is necessary, try "clobbering" the classpath with the following command:
    set CLASSPATH=
    Java will work even if CLASSPATH is set for an earlier version of the SDK software. However, if your CLASSPATH contains classes.zip, and you don't plan to continue using those earlier versions, remove that setting from the CLASSPATH now. In any case, if CLASSPATH is set, it should include the current directory -- this makes it possible to compile and then run classes in the current directory.

  • Get an Exception while running a Java Comm Application...

    Hello,
    I am rakesh.Recently i have downloaded an example for JavaCommAPI.[ BlackBox applet].When i try to run this application it is giving an error that it cannt find the class SerialPort EventListener.I am using java1.3 and java1.4.1 versions.
    Excepecting your answers.
    ... Rakesh

    You didn't put the optional Java Comm JAR in your classpath.

  • Java Session problem while sending mail(using javamail) using Pl/SQL

    Hello ...
    i am using Java stored procedure to send mail. but i'm getting java session problem. means only once i can execute that procedure
    pls any help.

    props.put("smtp.gmail.com",host);I doubt javamail recognizes the 'smtp.gmail.com' property. I think it expects 'mail.host'. Of course since it cannot find a specified howt it assumes by default localhost
    Please format your code when you post the next time, there is a nice 'code' button above the post area.
    Mike

  • Java Programming Problem

    Hi all,
    I was looking for this java programming problem which had to do with a large building and there was some gallons of water involved in it too somehow and we had to figure out the height of the buiding using java. This problem is also in one of the java books and I really need to find out all details about this problem and the solution. NEED HELP!!
    Thanks
    mac

    Yes, it will. The water will drain from the bottom of
    the tank until the pressure from the water inside the
    tank equals the pressure from the pipe. In other
    words, without a pump, the water will drain out until
    there is the same amount of water in the tank as in
    the pipe The water pressure depends on the depth of the water, not the volume. So once the depth of the water inside the pipe reaches the same depth as the water inside the tank it will stop flowing. This will never be above the height of the tank.
    I found this applet which demonstrates our problem. If you run it you can drag the guy up to the top, when water in his hose reaches the level of the water in the tank it will stop flowing out.

  • Java Uninstall Problem

    Java Uninstall Problem
    This all came about because of a failed uninstall, using Your Uninstaller.
    The {Java runtime which is all I want) is not listed now & I tried all the other fix bad uninstall type features, all to no avail.} )
    When I DL & run the latest package (jxpiinstall-6u11-fcs-bin-b90-windows-i586-25_nov_2008.exe}
    & run it I get:
    1st message:
         "This software has already been installed on your computer.
         Would you like to install it?"
    If I say no, it exits.
    If I say yes, I get this second message:
         :This action is only valid for products that are currently installed."
    So Now I have no Java & have no idea what to do.
    Any help would be greatly appreciated.
    Thanks, Neuromancer23

    Sorry...after posting it i realized there was a more appropriate forum, of which it took quiet awhile to find.)
    Now that I know where to find the forum list I will never double-post again.
    I'll close the question if I can

  • Java comm package to remotely monitor a zigbee device

    hai...
    I have a java program to poll a sensor device every 2 min.... The program uses java comm to read and write data to it. I have java servlet program that has to access the serial port at the same time as the polling program to read/write data from it..... I.It works individually....it is not possible to access the serial port at the same time..... Can any time slice help..... or anything which could get it done
    plz can anyone help with it....
    the project has to completed within a week
    Thanks in advance
    smn

    A servlet? Really? And it's supposed to be doing something every two minutes? That's a pretty weird idea to start with. Next you're going to be telling us that it needs to access the serial port on the client system rather than the one on the server. Go on, am I right?

  • Error in the latest Java comm api for Linux

    installed latest Java comm api for Linux, tried test application for the Sun package:
    $ java SimpleRead
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at SimpleRead.main(SimpleRead.java:67)
    Caused by: java.lang.NullPointerException
    at javax.comm.CommPortIdentifier.findConfFile(CommPortIdentifier.java:199)
    at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:117)
    ... 1 more
    What deis this message mean? How to make you serial port support work?

    and what does this error message mean??
    The package was installed accordingly to "Java(tm) Communications API Linux Installation Instructions":
    $ls /usr/lib/libLinuxSerialParallel.so
    /usr/lib/libLinuxSerialParallel.so
    $env|grep CLASS
    CLASSPATH=<..skipped..>:/opt/commapi/jar/comm.jar:/opt/commapi/jar/commtest.jar
    $ ls /opt/jdk1.5.0_04/jre/lib/javax.comm.properties
    /opt/jdk1.5.0_04/jre/lib/javax.comm.properties
    What else does it need?

  • Sun Java security problems

    Please any one tel me about Sun Java security problems
    with Desktop application

    Hi.
    If you're using SSGD 4.41, please download the Admin guide from here:
    http://docs.sun.com/app/docs/doc/820-4907
    There, at page #41 you'll find useful info concerning "Client Connections and Security Warnings".
    Hope this helps,
    Rob

Maybe you are looking for