Java Serial Port Question !

Hello,
I am writing characters such as "open\r", "close\r" to the serial port of a PC from the Java program. This PC is connected to robot controller through the serial port.
Suppose, I am writing open\r to the serial port. After writing open\r, the controller immediately echos "open" back to the serial port, which my Java program can read & print. Then, approximately after 1 second, when the robot actually executes the open (Open Gripper) command, the controller sends "Done.>" this response. I want to monitor & read this response "Done.>" because I want to check controller's response ("Done.>") before sending next command.
1. Is it MUST to listen & read data at port at the time the data comes? Does the data gets lost if we don't read the data at the time it comes? For example, if data comes at 10000 millisecs, then is it MUST to start reading at 10000 or 10001? Would that data get lost if we start reading after say 3 seconds i.e. at 13000?
2. If some data ("Done") comes at the serial port from controller and the Java program does not read that and if suppose more data (".>")comes at the serial port after 1/2 second, then does the previous data("Done") gets erased?
3. My problem is --> the java program that I have written, can sometimes read & print controller's response --> "Done.>" and other times it does not find "Done.>"....That means the data --> "Done.>" is getting lost somewhere or Java program is not able to read it..The controller always sends "Done.>" when it excecutes "open" command.
Thank You !
Mayur
Below is the code I am using...
import java.io.*;
import java.util.*;
import javax.comm.*;
public class WriteReadEdit implements SerialPortEventListener {
CommPortIdentifier portId;
Enumeration portList;
OutputStream outputStream;
InputStream inputStream;
SerialPort serialPort;
public static void main(String[] args) {
          String command1 = "open\r";
          String command2 = "close\r";                    
          boolean EndCharacterQMark = false;
          WriteReadEdit readObject = new WriteReadEdit();
               readObject.Write(command1);
               try {
                    EndCharacterQMark = readObject.waitUntilDataComes();
                    System.out.println("EndCharacterQMark is: " + EndCharacterQMark);
               }     catch (IOException e) {}
                    if(EndCharacterQMark) {
                         EndCharacterQMark = false;
                         readObject.Write(command2);
                         try {
                              EndCharacterQMark = readObject.waitUntilDataComes();
                              System.out.println("EndCharacterQMark is: " + EndCharacterQMark);
                         }     catch (IOException e) {}
                    readObject.closePort();
synchronized boolean waitUntilDataComes() throws IOException {
     String total="";
     boolean EndCharQMark = false;
     StringBuffer inputBuffer = new StringBuffer();
     int newData = 0;
     while(true) {
                    if(!dataAvailable()) {
                         try {                              
                              wait();                              
                         }catch (InterruptedException e) {}
               try {
                    while (newData != -1) {                         
                         newData = inputStream.read();
                         inputBuffer.append((char)newData);
               }          catch (IOException ex) {
                         System.err.println(ex);
                    String dataAtPort = inputBuffer.toString();
                    for(int i = 0; i < dataAtPort.length(); i++) {                         
                              if(dataAtPort.indexOf("?")>1 || dataAtPort.indexOf(">")>1 ) {
                              EndCharQMark = true;
                              return EndCharQMark;
boolean dataAvailable() throws IOException {          
     return inputStream.available() > 0;
          void Write(String commandToSend) {
          String command = commandToSend;
          try {
                    outputStream.write(command.getBytes());                              
                    System.out.println("\nSuccessfully Written: " + command);
          } catch (IOException e) {System.out.println("IO Exception Occured: " + e);
void closePort() {
     serialPort.close();
     System.out.println("Port closed successfully.");
// Constructor()
public WriteReadEdit() {
          portList = CommPortIdentifier.getPortIdentifiers();
          while (portList.hasMoreElements()) {
          portId = (CommPortIdentifier) portList.nextElement();
                    if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
          if (portId.getName().equals("COM1")) {
          try {
          serialPort = (SerialPort) portId.open("writereadobjectApp", 2000);
               System.out.println("Opened the port for writing: " + portId.getName());
          } catch (PortInUseException e) {
          try {
               serialPort.setSerialPortParams(9600,
          SerialPort.DATABITS_8,
          SerialPort.STOPBITS_1,
          SerialPort.PARITY_NONE);
          } catch (UnsupportedCommOperationException e) {
                                        System.out.println("UnsupportedCommOperationException, Could not set the port: " + e);
                                   try {                                        
                                        outputStream = serialPort.getOutputStream();
                                        inputStream = serialPort.getInputStream();
                                   } catch (IOException e) {
                                   try {
                                        serialPort.addEventListener(this);
                                   } catch (TooManyListenersException e) {}
                                   serialPort.notifyOnDataAvailable(true);
synchronized public void serialEvent(SerialPortEvent event) {
     switch(event.getEventType()) {
     case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
     case SerialPortEvent.DATA_AVAILABLE:
     notifyAll();          
     break;

1. Usually there are buffers in the serial port controller. Apart from that, as long as the port is open, any data recieved will be added at the end of the InputStream of the comport so nothing will be lost.
2. Nope, see above. But there might just be some kind of limit there.
3. Download portmon http://www.sysinternals.com/ntw2k/freeware/portmon.shtml or any other prog that is able to monitor what's happening on you're serial port. This allows you to see if the response is really send by the robot.
You're code seem to me to be more complex then it needs to be. Check out javax.comm.CommPort.enableRecieveTimeout(int). Setting a timeout will cause the the read function to return when the timeout is passed or data is recieved. A timeout of of say 4sec whould make sure that when a reply is send, it is recieved and it's stops reading when it gets no reply.
In that case you could do with a sendMsg function wich dus not return until the correct response is recieved, or the timeout passed.
You migth consider putting all the communicatoin with the com port in a different Thread so the rest of the program runs on when that thread is listening to the port...
Hope this helps you a bit...

Similar Messages

  • Java & Serial Port

    Hello,
    I downloaded the Java SDK 1.3.1 and the docs today. I would like to write a small app that will talk to a serial port device and just receive the responses from it (much like a keypad). I'm not sure though if I need more then the SDK 1.3.1 or not. I see a "Communications API" that is avaliable but I'm not sure that I need this (dated 1998) or if it's included in the SDK that I downloaded. I checked the documentation but couldn't find anything.

    JustLee,
    Thanks! I checked it out and downloaded it but can't seem to get the sample applications to run. I keep getting an error stating "noclassdeffounderror" when I try to run them. I guess I must have really messed something up becaues now when I just run my basic "Hello World" application I get the same error message.
    Guess I'll keep toying with it.

  • Java Serial Port - byte by byte reception.

    I want to receive one character after the other over my serial port. Could some one tell me how to control the data flow during reception.
    case SerialPortEvent.DATA_AVAILABLE:
    ReadBuffer = new byte[1];
    try
    if(serialPort.isCTS())
    while (inputStream.available() > 0)
    int numBytes = inputStream.read(ReadBuffer);
    ReadString = new String(ReadBuffer);
    rb.append(ReadString);
    }

    case SerialPortEvent.DATA_AVAILABLE:{
    while(true)
    try
    ch = is.read();
    if(ch==-1)
    break;
    buf.append((char)ch);
    }catch(IOException ioe)
    }

  • [SOLVED] usb serial port emulation

    Hello
    I'm an Arch newbie. I just purchased an HP Neoware CA21 thin client, replaced the small DOM unit by a 1GB module, and installed Arch on it. I would like to use this device as a kind of data logger, 24x7 continuous operation.
      The device I'm reading is an ADC connected via a USB port, which provides a CDC/ACM interface. When I plug it into the CA21 USB port, /dev/ttyACM0 does appear. Under Ubuntu on a normal PC the same happens but I find I can only use it via the usbserial driver, which provides serial port emulation for a USB device, creating /dev/ttyUSB0. That's because I can't get the java serial port interface rxtx to recognise a ttyACMn device, for reasons I don't understand and am still investigating.
    So, I have a couple of newbie questions about Arch ...
    1/ is there an equivalent to usbserial, ie a serial port emulation for USB ports?
    2/ if not, or perhaps more correctly, how can my java app interface to ttyACM0? The Arduino crowd may know about this.
    3/ I'm kind of assuming rxtx works under Arch - is that right?
    Thanks for any help.
    Andrew
    Last edited by mistertransistor (2011-11-12 16:43:03)

    Well, kind of solved. I found that
    - adding the "options usbserial ..." line does not prevent ttyACM0 from appearing when the device is plugged in
    - once ttyACM0 is there, no amount of "modprobe usbserial ..." will make ttyUSB0 appear
    - however, if you "rmmod cdc-acm" and then "modprobe usbserial ..." you will get a ttyUSB0
    Having figured that out, I got a test app reading the USB port with no problems. However my real app gave some odd 'Main class not found  ...' error even though the exact same jarfile runs fine under Windows XP (you may be wondering why I develop there rather than under Ubuntu. Well, I have a dual-boot machine XP/Ubuntu and NetBeans runs *much* better under XP - quite puzzling).  Eventually I solved this by creating a new NetBeans project/application and copying in the code from the existing one - a total mystery to me).
    So now the device is in my garage collecting data from my seismograph. I'm writing to a USB stick, not sure about how long that will last but as I don't delete files much it's always writing in a new area and any given area gets very few write cycles.
    This is marked SOLVED but I still have not found how to read ttyACM0 and I would like to do that.
    Andrew

  • Send signal to serial port

    Hi, I have a trouble.
    I need to send a signal to serial port to pilot a relè.
    I can't find how to send a Vcc signal for some second on a pin in java.
    Someone have an idea?
    Thanks a lot!
    Edited by: Alberto.Marcigaglia on Aug 29, 2008 2:27 AM

    There are many results from the search below:
    http://www.google.com/search?q=java+serial+port
    I suggest that you use the 3-rd party RXTX package rather than the obsolete javax.comm package. There are a number of very detailled posts in these Sun forums regarding the installation and use of RXTX - search for them.

  • How to add control buttons using Java thorugh serial port?

    Hi everyone,
    I'm new to this forum.
    I have some questions on Java and serial port.
    I want to write a Java program to control my robot, through serial port. For example, when I click "Forward", the robot will go forward, and so on.
    Now I already have the buttons, so next I would like to ask how to interface the buttons with the serial port.
    I already have all the javax.comm things installed.
    below is the code for my buttons:
    import java.awt.*;
    public class ControlButtons extends java.applet.Applet
         GridLayout myLayout = new GridLayout(3, 3);
         Button button1 = new Button(" ");
         Button buttonForward = new Button("Forward");
         Button button2 = new Button(" ");
         Button buttonLeft = new Button("Left");
         Button buttonStop = new Button("Stop");
         Button buttonRight = new Button("Right");
         Button button3 = new Button(" ");
         Button buttonReverse = new Button("Reverse");
         Button button4 = new Button(" ");
         public void init()
              setLayout(myLayout);
              add(button1);
              button1.setVisible(false);
              add(buttonForward);
              add(button2);
              button2.setVisible(false);
              add(buttonLeft);
              add(buttonStop);
              add(buttonRight);
              add(button3);
              button3.setVisible(false);
              add(buttonReverse);
              add(button4);
              button4.setVisible(false);
    }Now I would like to ask for direction on how to add in the code to make it work with serial port.
    Thanks

    The plan is, I have a robot device connected to the serial port.We don't know anything about that device. We don't know how to control it. We don't know what you have to write to the device to make it do anything. Only you know what.
    For example, when I click "Forward", the robot will go forward, and so on.So what do you have to send to make it do that? and same for the other buttons.
    Next, you need to work out from the javax.comm API how to open the serial port and send data to it. This is a standard exercise in learning a new API. You must be able to do this. Again and again.
    But the program is useless. The button can be clicked, but didn't do anything.Because (a) they have no ActionListeners and (b) there is no code to send anything to the serial port.
    You have to write all that. So you also have to look up ActionListener in the Java API and how to attach it to a button. You can do that. We all do that kind of thing every day.
    So next I would like to ask how to interface the buttons with the serial port.You've been asking nothing else since you started, but you've also only done enough investigation of your own to create the buttons. That's only the start.
    The problem is what method and command should I use to make those buttons actually functioning.See above. You've been told part of it several times. The rest only you can answer, because it's your robot.

  • Java ME 8 Permission check failed when opening a serial port

    I have a larger Jave ME8.1 application that was going well until I tried to add one last piece, reading and writing data from a serial port. This was left to last because it is trivial, at least in most programming languages. The is IDE NetBeans 8.0.2 running on a Windows 7 PC. The platform is a Raspberry Pi B or B+ (I have tried both) with the most current Raspbian (12/24/2014 I believe). To simplify the process I created a new app with just the open and close code and this generates the same error I am experiencing in the larger application. The program is as follows:
    package javamecomapp;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.microedition.io.CommConnection;
    import javax.microedition.io.Connector;
    import javax.microedition.midlet.MIDlet;
    * @author ****
    public class JavaMEcomApp extends MIDlet {
        static int BAUD_RATE = 38400;
        static String SERIAL_DEVICE = "ttyAMA0";
        static CommConnection commConnection = null;
        static OutputStream os = null;
        static InputStream is = null;
        static String connectorString;
        private int rtnValue = -1;
        @Override
        public void startApp() {
            java.lang.System.out.println("Opening comm port.");
            try {
                rtnValue = JavaMEcomApp.openComm();
            } catch (IOException ex) {
                Logger.getLogger(JavaMEcomApp.class.getName()).log(Level.SEVERE, null, ex);
        @Override
        public void destroyApp(boolean unconditional) {
            java.lang.System.out.println("Closing comm port.");
            try {
                rtnValue = JavaMEcomApp.closeComm();
            } catch (IOException ex) {
                Logger.getLogger(JavaMEcomApp.class.getName()).log(Level.SEVERE, null, ex);
            private static int openComm()throws IOException {
                java.lang.System.out.println("Opening comm port.");
                connectorString = "comm:" + SERIAL_DEVICE + ";baudrate=" + BAUD_RATE;
                commConnection = (CommConnection)Connector.open(connectorString);
                is  = commConnection.openInputStream();
                os = commConnection.openOutputStream();
            return 0;
        private static int closeComm()throws IOException {
            java.lang.System.out.println("Closing comm port.");
                is.close();
                os.close();
                commConnection.close();
            return 0;
    If I comment out the JavaMEcomApp.openComm and closeComm lines it runs fine. When they are included, the following error is dumped to the Raspberry Pi terminal:
    Opening comm port.
    Opening comm port.
    [CRITICAL] [SECURITY] iso=2:Permission check failed: javax.microedition.io.CommProtocolPermission "comm:ttyAMA0;baudrate=38400" ""
    TRACE: <at java.security.AccessControlException: >, startApp threw an Exception
    java.security.AccessControlException:
    - com/oracle/meep/security/AccessControllerInternal.checkPermission(), bci=118
    - java/security/AccessController.checkPermission(), bci=1
    - com/sun/midp/io/j2me/comm/Protocol.checkForPermission(), bci=16
    - com/sun/midp/io/j2me/comm/Protocol.openPrim(), bci=31
    - javax/microedition/io/Connector.open(), bci=77
    - javax/microedition/io/Connector.open(), bci=6
    - javax/microedition/io/Connector.open(), bci=3
    - javamecomapp/JavaMEcomApp.openComm(), bci=46
    - javamecomapp/JavaMEcomApp.startApp(), bci=9
    - javax/microedition/midlet/MIDletTunnelImpl.callStartApp(), bci=1
    - com/sun/midp/midlet/MIDletPeer.startApp(), bci=5
    - com/sun/midp/midlet/MIDletStateHandler.startSuite(), bci=246
    - com/sun/midp/main/AbstractMIDletSuiteLoader.startSuite(), bci=38
    - com/sun/midp/main/CldcMIDletSuiteLoader.startSuite(), bci=5
    - com/sun/midp/main/AbstractMIDletSuiteLoader.runMIDletSuite(), bci=130
    - com/sun/midp/main/AppIsolateMIDletSuiteLoader.main(), bci=26
    java.security.AccessControlException:
    - com/oracle/meep/security/AccessControllerInternal.checkPermission(), bci=118
    - java/security/AccessController.checkPermission(), bci=1
    - com/sun/midp/io/j2me/comm/Protocol.checkForPermission(), bci=16
    - com/sun/midp/io/j2me/comm/Protocol.openPrim(), bci=31
    - javax/microedition/io/Connector.open(), bci=77
    - javax/microedition/io/Connector.open(), bci=6
    - javax/microedition/io/Connector.open(), bci=3
    - javamecomapp/JavaMEcomApp.openComm(), bci=46
    - javamecomapp/JavaMEcomApp.startApp(), bci=9
    - javax/microedition/midlet/MIDletTunnelImpl.callStartApp(), bci=1
    - com/sun/midp/midlet/MIDletPeer.startApp(), bci=5
    - com/sun/midp/midlet/MIDletStateHandler.startSuite(), bci=246
    - com/sun/midp/main/AbstractMIDletSuiteLoader.startSuite(), bci=38
    - com/sun/midp/main/CldcMIDletSuiteLoader.startSuite(), bci=5
    - com/sun/midp/main/AbstractMIDletSuiteLoader.runMIDletSuite(), bci=130
    - com/sun/midp/main/AppIsolateMIDletSuiteLoader.main(), bci=26
    Closing comm port.
    Closing comm port.
    TRACE: <at java.lang.NullPointerException>, destroyApp threw an Exception
    java.lang.NullPointerException
    - javamecomapp/JavaMEcomApp.closeComm(), bci=11
    - javamecomapp/JavaMEcomApp.destroyApp(), bci=9
    - javax/microedition/midlet/MIDletTunnelImpl.callDestroyApp(), bci=2
    - com/sun/midp/midlet/MIDletPeer.destroyApp(), bci=6
    - com/sun/midp/midlet/MIDletStateHandler.startSuite(), bci=376
    - com/sun/midp/main/AbstractMIDletSuiteLoader.startSuite(), bci=38
    - com/sun/midp/main/CldcMIDletSuiteLoader.startSuite(), bci=5
    - com/sun/midp/main/AbstractMIDletSuiteLoader.runMIDletSuite(), bci=130
    - com/sun/midp/main/AppIsolateMIDletSuiteLoader.main(), bci=26
    java.lang.NullPointerException
    - javamecomapp/JavaMEcomApp.closeComm(), bci=11
    - javamecomapp/JavaMEcomApp.destroyApp(), bci=9
    - javax/microedition/midlet/MIDletTunnelImpl.callDestroyApp(), bci=2
    - com/sun/midp/midlet/MIDletPeer.destroyApp(), bci=6
    - com/sun/midp/midlet/MIDletStateHandler.startSuite(), bci=376
    - com/sun/midp/main/AbstractMIDletSuiteLoader.startSuite(), bci=38
    - com/sun/midp/main/CldcMIDletSuiteLoader.startSuite(), bci=5
    - com/sun/midp/main/AbstractMIDletSuiteLoader.runMIDletSuite(), bci=130
    com/sun/midp/main/AppIsolateMIDletSuiteLoader.main(), bci=26
    I have tried this with three different serial ports, /dev/ttyAMA0 (yes I did disable the OS from using it), an arduino board /dev/ttyACM0, and a USB to RS485 adaptor /dev/ttyUSB0. All of these ports could be connected and use normally with both a C program and terminal program in the Pi. The API Permissions were set in the project properties / Application Descriptor / API Permissions to jdk.dio.DeviceMgmtPermission "/dev/ttyAMA0". This of course was changed as I tested different devices.
    I found a reference suggesting adding the line "authentication.provider = com.oracle.meep.security.NullAuthenticationProvider" to the end of the jwc_properties.ini file. This had no effect. I found references that during development in eclipse and NetBeans, the app is already elevated to the top level so this should not be an issue until deployment. This does not appear to be the case.
    I am out of time and need a solution quickly. Any suggestions are welcome.

    Terrence,
       Thank you for responding and confirming the issues I'm having with static addressing.  As far as the example above, I do have the standard LEDs working correctly, however, the example I'm referring to above is from the JavaME samples using the GPIO Port for the LEDS, according to the Device I/O Preconfigured List you referenced:
    GPIO Ports
    The following GPIO ports are preconfigured.
    Devicel ID
    Device Name
    Mapped
    Configuration
    8
    LEDS
    PTB22
    PTE26
    PTB21
    direction = 1 (Output only)
    initValue = 0
    GPIOPins:
    controllerNumber = 1
    pinNumber = 22
    mode = 4 (Push-pull mode)
    controllerNumber = 4
    pinNumber = 26
    mode = 4 (Push-pull mode)
    controllerNumber = 1
    pinNumber = 21
    mode = 4 (Push-pull mode)
    So is the assumption that using GPIOPort for accessing the GPIO port for Device ID 8 as listed in the Device I/O Preconfigured list not supported?

  • How to access the serial port in Java?

    How can I initialise and access the serial port for writing and reading data from it? Are there any code examples available?

    I tried that and I tried compiling and executing one of its examples, the one below:
    import java.io.*;
    import java.util.*;
    import javax.comm.*;
    public class SimpleWrite {
    static Enumeration portList;
    static CommPortIdentifier portId;
    static String messageString = "Hello, world!\n";
    static SerialPort serialPort;
    static OutputStream outputStream;
    public static void main(String[] args) {
    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")) {
    try {
    serialPort = (SerialPort)
    portId.open("SimpleWriteApp", 2000);
    } catch (PortInUseException e) {}
    try {
    outputStream = serialPort.getOutputStream();
    } catch (IOException e) {}
    try {
    serialPort.setSerialPortParams(9600,
    SerialPort.DATABITS_8,
    SerialPort.STOPBITS_1,
    SerialPort.PARITY_NONE);
    } catch (UnsupportedCommOperationException e) {}
    try {
    outputStream.write(messageString.getBytes());
    } catch (IOException e) {}
    But when I execute this I get the error:
    Exception in thread "main" java.lang.NoClassDefFoundError: SimpleWrite
    What is wrong with this example??

  • How to read and write from the serial port using java

    can anyone tel me how to capture data from a serial port and display on the screen and also store it in a database.

    Java Comm API, JDBC

  • Java program to receive byte from serial port

    hello everyone, i am recently working one a project which require communication between pic16f877 and PC. My pic continuiously measure a voltage and send the result (a byte ranging from 0 to 255) to the rs232 port. One the pc side, my java program keep reading the serial port and it works for values 0~127 and 160~255. But if the byte value is between 127 and 160, it cannot received correctly, i get something like 375,8224,or even 65532 etc(no obvious path but more likely to be 300+,700+,8000+ or 65500+). I have been trying very hard to solve this and i think the problem is due to the pc software. I am feeling so frustrated and any suggestion will be much appreciated.
    p.s. : i used Bufferedreader.read() in my program
    --mengyao                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    fumengyao wrote:
    hello everyone, i am recently working one a project which require communication between pic16f877 and PC. My pic continuiously measure a voltage and send the result (a byte ranging from 0 to 255) to the rs232 port. One the pc side, my java program keep reading the serial port and it works for values 0~127 and 160~255. But if the byte value is between 127 and 160, it cannot received correctly, i get something like 375,8224,or even 65532 etc(no obvious path but more likely to be 300+,700+,8000+ or 65500+). I have been trying very hard to solve this and i think the problem is due to the pc software. I am feeling so frustrated and any suggestion will be much appreciated.
    p.s. : i used Bufferedreader.read() in my program
    --mengyaothis may not matter in your case - but don't use a Reader, use a Stream (BufferedInputStream maybe)

  • 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 bean to get information from serial port

    we are migrating from 6i to 10g. In 6i, we used mscomm32.ocx to access to com port. Now in 10g we need a java bean. Anybody has a java bean to access to serial port or anything similar?
    My email is [email protected]
    Thanks in advance.

    we set properties to the serial port, open the port, read (listen) from port, ... Here there are some pieces of code to you see it:
    -- Si está abierto el puerto puedo leer
    IF (MsCommLib_ImsComm.PortOpen(:ITEM('IF_OCX_COM').INTERFACE)=-1) THEN
    -- Miro si hay caracteres
    a:=MsCommLib_ImsComm.InBufferCount(:ITEM('IF_OCX_COM').INTERFACE);
    IF a>0 THEN
    set_item_property('COMUNICACION_ICS.ESPERA',DISPLAYED,PROPERTY_FALSE);
    --Datos de un bloque nuevo, hay que insertar la fecha
    IF :global.estado = 0 THEN
    --Leo la fecha en la que se ha leído los datos
    --SELECT SYSDATE INTO fecha
    --FROM DUAL;   
    fecha := To_Date(:System.Current_Datetime,'dd-mon-yyyy hh24:mi:ss');
    -- Borro la pantalla si hay mas de 1920 caracteres
    :global.tc := :global.tc + 21;
    IF :global.tc > 1920 then
    :comunicacion_ics.if_txt_com_rec :='';
    :global.tc := 0;
    end if;
    --Introduzco la fecha en el control de texto, para su posterior proceso
    :comunicacion_ics.if_txt_com_rec := :comunicacion_ics.if_txt_com_rec||CHR(10)
    ||'__' || To_Char(fecha,'DD-MM-YYYY,HH24:Mi:SS')||chr(10);
    guarda := Fichero.Escribe(:global.fic,CHR(10)||'__' || To_Char(fecha,'DD-MM-YYYY,HH24:Mi:SS')
    ||chr(10));
    if guarda < 0 then
    raise e;
    end if;
    END IF;
    -- Indico que se están recibiendo datos de este bloque
    :global.estado := 2;
    --Leo la cadena
    linea_ics := Var_To_Char(MsCommLib_ImsComm.Input(:item('IF_OCX_COM').INTERFACE));
    linea_ics := replace(linea_ics,chr(13),CHR(10)); -- CHR(10)
    --La añado al control de texto para que se vea
    -- Borro la pantalla si hay mas de 1920 caracteres
    :global.tc := :global.tc + a;
    IF :global.tc > 1920 then
    :comunicacion_ics.if_txt_com_rec :='';
    :global.tc := 0;
    end if;
    :comunicacion_ics.if_txt_com_rec := :comunicacion_ics.if_txt_com_rec||
    linea_ics;
    --Escribo la linea en el fichero
    -- Propiedades de Buffers
    -- Tamaño del Buffer de Entrada
    :prop_com.txt_in_buf := MsCommLib_ImsComm.InBufferSize(:ITEM('IF_OCX_COM').INTERFACE);
    -- Tamaño del Buffer de Salida
    :prop_com.txt_out_buf := MsCommLib_ImsComm.OutBufferSize(:ITEM('IF_OCX_COM').INTERFACE);
    -- Tamaño de la cadena de Entrada
    :prop_com.txt_input_len := MsCommLib_ImsComm.InputLen(:ITEM('IF_OCX_COM').INTERFACE);
    -- RThreshold
    :prop_com.txt_rthres := MsCommLib_ImsComm.RThreshold(:ITEM('IF_OCX_COM').INTERFACE);
    -- SThreshold
    :prop_com.txt_sthres := MsCommLib_ImsComm.SThreshold(:ITEM('IF_OCX_COM').INTERFACE);
    -- EOF Enable
    :prop_com.chk_eof_enable := MsCommLib_ImsComm.EOFEnable(:ITEM('IF_OCX_COM').INTERFACE);
    -- Propiedades Hardware
    -- Parity replace
    :prop_com.txt_par_repl := MsCommLib_ImsComm.ParityReplace(:ITEM('IF_OCX_COM').INTERFACE);
    -- NULL Discard
    :prop_com.chk_null_discard := MsCommLib_ImsComm.NULLDiscard(:ITEM('IF_OCX_COM').INTERFACE);
    -- RTS Enable
    :prop_com.chk_rts := MsCommLib_ImsComm.RTSEnable(:ITEM('IF_OCX_COM').INTERFACE);
    -- NULL DTR
    :prop_com.chk_dtr := MsCommLib_ImsComm.DTREnable(:ITEM('IF_OCX_COM').INTERFACE);
    Thanks. Inma

  • Java and serial ports

    i want to be able to use java to access my serial port to
    remote dial other systems....

    Download javax.comm from the Sun website and use that.
    http://java.sun.com/products/javacomm/index.html
    Follow the install instructions VERY carefully .

  • Java enabled phones supporting serial port access

    Does anybody know a Java enabled mobile phone beside the Motorola iden family that supports access to the serial port ? As far as I can see there are no such phones on the market.

    simens sl45 and m50

  • Question of commapi - BlackBox could not find serial port.

    Hi,
    I have installed jdk1.5.0_04 and commapi2.0_win32 at following directory
    c:\Java\netbeans-4.1
    c:\Java\jdk1.5.0_04
    c:\Java\commapi
    C:\Program Files\Java\jre1.5.0_04
    Then I do exactly what installation instruction ask me to do
    Copy win32com.dll to c:\Java\jdk1.5.0_04\bin
    Copy comm.jar to c:\Java\jdk1.5.0_04\lib
    Copy javax.comm.properties to c:\Java\jdk1.5.0_04\lib
    However, when I run BlackBox,BlackBox still gives me a message that
    says "No serial ports found!"
    Can any one help me out, thanks in advance ?
    Daniel

    Many forum posts about installation to java 1.4. Also see:
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=453195
    and
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=444673
    I had success on winXP when I installed to the JRE below Program Files/java, no success when installed to c:\j2sdk etc etc.
    The directions for setting the classpath seem bogus; I did not need to specify a class path. Simply went to the commapi/samples/BlackBox folder, then typed java BlackBox. It found a couple of ports. I think this means that (despite the post in the forum to the contrary) that the comm API can deal with the NT hardware abstraction layer (HAL) just fine.
    I'm very new to this, hope this helps.
    chris...

Maybe you are looking for

  • Set Default Value for a Date Navigator

    Hi all Is it possible to set a default value for a date navigator.I mean with out picking the date from the Navigator, on load of the view itself i need a particualr date to be displayed (say 12/31/2000). Thanks in advance

  • Do you know ActionScript? dispatchEvent help needed

    I have a .swf file that loads in a .as class file. What I want to do is the following The class file dispatches an event called "loadEvtStatus" When inside of the class, i can trip a function for the event Problem. How do i listen for the event on th

  • UWL Custom Attribute ABAP_BOR to the second degree

    Hello, I'm trying to retrieve information from ABAP_BOR at the second level. Example : Transaction <b>SWO1</b> we display Object Type <b>BUS2009</b> This contains the attibute <b>Requisitioner</b> and we can retreive the data with the following xml c

  • Automatic start workflow for ALL records

    Hi Experts, Does anyone know a way to start workflow automatically for ALL records without human interference? I want to start workflows every day. For instance to recalculate, re-validate, re-assign or syndicate ALL records of a table. Kind regards,

  • Picture blurs slightly just prior to transition

    When viewing my iDVD on my TV the image on the screen goes a bit blurry just before making a transition to the next picture. Note, the only time this does not happen is when the transition type is set to "none". I don't notice this when viewing on my