Java and serial port communication

Hello,
In my code i have parsed a file through which i have extracted the port name and baud rate .
Now i want to open the port with this portname and baud rate.
I have a device moxa card which has 16 port and want to open each and and read and write data into it.
thanking you.

RXTX seems to be a decent library for serial/parallel communication using Java.
[http://www.rxtx.org/]

Similar Messages

  • GPIB and serial port communication errors via an executalbe file.

    I have a data acquisition program that communicates with instruments via the serial port and GPIB bus. When I create an executable file and run it on another PC I get GPIB and serial port errors when the program tries to initialize these ports. Are there additional vi's I need to include when I build the executable?

    When you installed the GPIB board on the other pc, did you install just NI-GPIB? Did you configure the GPIB board? You also need NI-VISA if your're using VISA calls in your program. You can either install the full NI-VISA or just the run-time version.

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

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

  • How can collect the data from laptop sound card and serial port at the same time?

    I'm working on a project, I need to collect the data from laptop sound card, and also from serial port at the same time.
    The attachments are my VIs for sound card and serial port communication, I'm wondering that can I combine these two VIs together? Or can I run these two VI at the same time?
    Thank you!
    Attachments:
    AC_Radar_Receive.vi ‏46 KB
    RadarAudioPlug.vi ‏774 KB

    A smarter way is just to put all your code in the same VI.
    Two parallel loops if rates are different.
    Attachments:
    RadarAudioPlug.vi ‏450 KB

  • Serial Port Communication Class

    Hi
    Does anyone know if there is a java class doing serial port communication using RS485 4 wireport.
    Thanks

    There's the Java Communications API that does serial port communication. Don't know whether it handles whatever it was you said.

  • Serial port communication IRP_MJ_READ

    Hello, i would like to ask you about serial port communication. I am currently trying to make application for communication with my stepper motor (Microcon), but it doesnt work. If i try to communicate with original software, my serial port monitor gives me values 
    IRP_MJ_WRITE  when i write some values and
    IRP_MJ_READ when i try to read from serial port
    But when i am using LabView i am only able to send IRP_MJ_WRITE function using VISA write component (so this one works good), but when i use VISA read component my serial port monitor gives me only IRP_DEVICE_CONTROL. Have you any sugestion where can be problem? I have no idea how to get this IRP_MJ_READ function using LabView VISA component.
    Solved!
    Go to Solution.

    Are you monitoring the using PortMon software ? Only thing I can see here is that check the command what you send, there might be some space which you might have introduced while typing,
    or
    Are you still running stepper motor control software while running the labview ? In this case there will be conflict.
    When you are using original stepper motor software and when you send command wirte down the hex value (see in portmon or anyother monitoring software) and try sending same hex values using labview. Sending command, sending hex are same but just give it a try,
    Use bytes at port function before VISA read to read all the available data.
    Search for Microcon drivers in Instrument driver network in NI website if you want easy & fast solution.

  • Java applets in a browser, and Serial port input

    I know that there is a special package for serial port input in java. (java.Comm.SerialPort)
    What I am trying to figure out before a final decision on design is made, is if there is anyway of reading serial port input into a java applet that is running inside of a browser.
    I have found lots of reference to Serial port input, but nothing that really goes in the direction that I am lookind for.
    Any little tid bits of information pertaining to this would be greatly appreciated.
    Cuervo

    You should also consider that applets are not allowed to access their client system's hardware without being signed; in other words, the user must agree (by clicking a button) to disable the applet security features. Why would you use an applet to do this? Applets are meant to be an extension of a website. You should use an application in this situation.

  • Cisco Router 2600 Serial Port communications

    I am working on configuring communications Router to Router through serial port. I have seen some videos and read some documentations. My configuration is as follows: 
    R1 (DCE) -> f0/0 192.168.1.1/24 - s0/0 192.168.2.1/24 <-----> Router2 ->(DTE)  S0/1 192.168.2.2/24 f0/0 192.168.3.1.
    I have configured the routing tables at both routers. It works when I ping from router to router and router to hosts successfully. Nevertheless, I can ping from hosts to the default gateways, but I cannot ping from hosts to the serial ports (adjacency). In short I cannot communicate from Network1 to Network2. Please do I have to do any extra configuration.

    Router 1 (KelliR)
    KelliR#show ip interface brief
    Interface                  IP-Address      OK? Method Status                Protocol
    Ethernet0/0                192.168.1.1     YES manual up                    up
    Serial0/0                  192.168.3.1     YES manual up                    up
    TokenRing0/0               unassigned      YES unset  administratively down down
    Serial0/1                  unassigned      YES unset  administratively down down
    KelliR#show ip route
    Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
           E1 - OSPF external type 1, E2 - OSPF external type 2
           i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
           ia - IS-IS inter area, * - candidate default, U - per-user static route
           o - ODR, P - periodic downloaded static route
    Gateway of last resort is not set
    C    192.168.1.0/24 is directly connected, Ethernet0/0
    S    192.168.2.0/24 [1/0] via 192.168.3.2
    C    192.168.3.0/24 is directly connected, Serial0/0
    ============================================
    Router 2 (HelderR)
    HelderR#
    HelderR#show ip interface brief
    Interface                  IP-Address      OK? Method Status                Protocol
    Ethernet0/0                192.168.2.1     YES manual up                    up
    Serial0/0                  192.168.3.2     YES SLARP  up                    up
    TokenRing0/0               unassigned      YES unset  administratively down down
    Serial0/1                  unassigned      YES unset  administratively down down
    HelderR#show ip route
    Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
           E1 - OSPF external type 1, E2 - OSPF external type 2
           i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
           ia - IS-IS inter area, * - candidate default, U - per-user static route
           o - ODR, P - periodic downloaded static route
    Gateway of last resort is not set
    S    192.168.1.0/24 [1/0] via 192.168.3.1
    C    192.168.2.0/24 is directly connected, Ethernet0/0
    C    192.168.3.0/24 is directly connected, Serial0/0
    ============================================
    Even with  f0/0 and s0/0 configured with the addresses in any router, no host at its respective routers is able to ping the s0/0. Hosts are able to ping its ethernet ports.
    See ping comand below:
    From router KelliR
    KelliR#ping 192.168.3.2
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:
    Success rate is 100 percent (5/5), round-trip min/avg/max = 32/33/36 ms
    KelliR#ping 192.168.2.1
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
    Success rate is 100 percent (5/5), round-trip min/avg/max = 32/34/36 ms
    KelliR#ping 192.168.2.101
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.2.101, timeout is 2 seconds:
    Success rate is 100 percent (5/5), round-trip min/avg/max = 32/33/36 ms
    KelliR#
    ==================================================================================
    From router HelderR
    HelderR#ping 192.168.3.1
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:
    Success rate is 100 percent (5/5), round-trip min/avg/max = 32/33/36 ms
    HelderR#ping 192.168.1.1
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
    Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 ms
    HelderR#ping 192.168.1.101
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.1.101, timeout is 2 seconds:
    Success rate is 100 percent (5/5), round-trip min/avg/max = 32/34/36 ms
    HelderR#
    ====================================================
    From Host connected to KelliR
    C:\>ping 192.168.1.1
    Pinging 192.168.1.1 with 32 bytes of data:
    Reply from 192.168.1.1: bytes=32 time=2ms TTL=255
    Reply from 192.168.1.1: bytes=32 time=1ms TTL=255
    Reply from 192.168.1.1: bytes=32 time=1ms TTL=255
    Reply from 192.168.1.1: bytes=32 time=1ms TTL=255
    Ping statistics for 192.168.1.1:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 1ms, Maximum = 2ms, Average = 1ms
    C:\>ping 192.168.3.1
    Pinging 192.168.3.1 with 32 bytes of data:
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    Ping statistics for 192.168.3.1:
        Packets: Sent = 4, Received = 0, Lost = 4 (100% loss)
    =====================================================
    From Host connected to HelderR
    C:\Users\Helder>ping 192.168.2.1
    Pinging 192.168.2.1 with 32 bytes of data:
    Reply from 192.168.2.1: bytes=32 time=3ms TTL=255
    Reply from 192.168.2.1: bytes=32 time=1ms TTL=255
    Reply from 192.168.2.1: bytes=32 time=1ms TTL=255
    Reply from 192.168.2.1: bytes=32 time=1ms TTL=255
    Ping statistics for 192.168.2.1:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 1ms, Maximum = 3ms, Average = 1ms
    C:\Users\Helder>ping 192.168.3.2
    Pinging 192.168.3.2 with 32 bytes of data:
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    Ping statistics for 192.168.3.2:
        Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

  • Serial port communication on Mac OS X with netbeans environment?

    I'm new to java. i wrote a cross platform application with realbasic that communicates with a serial port. i am trying to rewrite this application using good OOP technique using java and netbeans. i am developing on Mac OS X with netbeans. I am having a very difficult time finding some sample code and documentation on the best way to communicate with a serial port on OS X. i have looked into javax.comm and rxtx but am having trouble finding good docs and examples for OS X. also what ever the solution ends up being it needs to be cross platform.
    Any help would be greatly appreciated.
    thanks
    Jeff

    Same error here: I've tried building in both 32 and 64 bit modes, following the instructions above, and still receive the same error. Both LD_LIBRARY_PATH and DYLB_LIBRARY_PATH are set, as well as JAVA_OPTS pointing to the appropriate directory (in this e.g., /opt/dbxml/lib).
    Is there a way to get the "next" version of dbxml as a beta? Or is there another workaround in addition to what's posted here?
    Thanks,
    B
    Stats:
    java version "1.6.0_07"
    dbxml-2.4.16
    OS X 10.5.7
    tomcat 6.0.18
    <error stack trace below>
    ava.lang.UnsatisfiedLinkError: /opt/dbxml/lib/libdb_java-4.6.jnilib:
         at java.lang.ClassLoader$NativeLibrary.load(Native Method)
         at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1822)
         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1739)
         at java.lang.Runtime.loadLibrary0(Runtime.java:823)
         at java.lang.System.loadLibrary(System.java:1030)
         at com.sleepycat.db.internal.db_javaJNI.<clinit>(db_javaJNI.java:52)
         at com.sleepycat.db.internal.DbEnv.<init>(DbEnv.java:264)
         at com.sleepycat.db.EnvironmentConfig.createEnvironment(EnvironmentConfig.java:1023)
         at com.sleepycat.db.EnvironmentConfig.openEnvironment(EnvironmentConfig.java:976)
         at com.sleepycat.db.Environment.<init>(Environment.java:29)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
    </end stack trace>
    Edited by: hamhoagie on May 28, 2009 12:28 PM
    Edited by: hamhoagie on May 28, 2009 12:29 PM

  • Java and parallel port

    I don't know if this is forum I should ask this question but I didn't find any corresponding
    to java and ports control.
    I'm using Aurox 11.0 linux.
    I wonder if I could control each output (DATA pin) of parallel port separately in
    Java Communications API?. I can control outputs in Java with JNI but I need to run
    program as root. If I would want to create applet which would use parallel port
    I would have to create server with which this applet would communicate (Limitations of
    applets). But this server would have to run as root. It would affect security of system.

    Because of C++ ioperm function. This function requires root privileges. I have JNI Java
    program which can control outputs of parallel port on the level of one byte (write
    whole byte - all DATA outputs) and C++ program which can control outputs of port separately (control of each pin) and both are based on ioperm function. Both require
    root privileges. So my question is: can I control each output pin separately with Java Communications API?. Maybe if I used wholly Java code I could access port with user privileges?.

  • JVM serial Port communication

    I am would like my java stored procedure to communicate with my serial port. I have a problem with relative pathnames are not allowed(com1:). how do I bypass this? Source code included:
    # Java source code
    package com.bannasoft.serial;
    import java.io.*;
    public class SerialTest {
    public static void sendit() {
    Runtime rt = Runtime.getRuntime();
    Process p = null;
    String portname = "com1:";
    String cmd[] = {
    "c:\\winnt\\system32\\cmd.exe", "/c",
    "start", "/min",
    "c:\\winnt\\system32\\mode.com", portname,
    "baud=9600", "parity=n", "data=8",
    "stop=1",
    try {
    p = rt.exec( cmd );
    if( p.waitFor() != 0 ) {
    System.out.println("Error: " + cmd );
    System.exit( -1 );
    byte data[] = "Serial Text.".getBytes();
    FileOutputStream fos = new FileOutputStream( portname );
    BufferedOutputStream bos = new BufferedOutputStream( fos );
    fos.write( data, 0, data.length );
    fos.close();
    catch( Exception e ) {
    e.printStackTrace();
    # Java Compile and load
    C:\work>javac SerialTest.java
    C:\work>loadjava -user scott/tiger@wc-sbenna2:1521:ORA817 -thin -resolve \
         -resolver "((* SCOTT) (* SYS))" SerialTest.class
    # modify the init.ora
    utl_file_dir = c:\winnt\system32
    # As System in oracle grant promisions
    I don't know that all of these grants are required.
    SYSTEM: ORA817>call dbms_java.grant_permission('SCOTT','java.io.FilePermission','c:\winnt\system32\cmd.exe','execute');
    SYSTEM: ORA817>call dbms_java.grant_permission('SCOTT','java.lang.RuntimePermission','c:\winnt\system32\cmd.exe','execute');
    SYSTEM: ORA817>call DBMS_JAVA.GRANT_PERMISSION('SCOTT','SYS:java.io.FilePermission', '*', 'read,write,execute');
    SYSTEM: ORA817>call DBMS_JAVA.GRANT_PERMISSION('SCOTT','java.lang.RuntimePermission', 'writeFileDescriptor', 'execute');
    # Create procedure as scott
    SCOTT: ORA817>create or replace procedure test1
              as language JAVA
              name 'com.bannasoft.serial.SerialTest.sendit()';
    # Set output on
    SCOTT: ORA817>set serverout on size 4000;
    SCOTT: ORA817>call dbms_java.set_output(4000);
    # execute procedure
    SCOTT: ORA817> exec test1();
    java.lang.SecurityException: relative pathnames are not allowed(com1:)
    at
    oracle.aurora.rdbms.SecurityManagerImpl.checkFileIsAbsolute(SecurityManagerImpl.
    java)
    at oracle.aurora.rdbms.SecurityManagerImpl.checkWrite(SecurityManagerImpl.java)
    at java.io.FileOutputStream.<init>(FileOutputStream.java)
    at java.io.FileOutputStream.<init>(FileOutputStream.java)
    at com.bannasoft.serial.SerialTest.sendit(SerialTest.java:27)
    PL/SQL procedure successfully completed.

    http://java.sun.com/developer/Books/javaprogramming/cookbook/11.pdf

  • Serial port communication through JSP

    i am developing web application and i want to connect RFID reader to serial port to client computer.so when user put thr card on RFID READER and press Read Button on JSP page .the information stored on card display on the web page.
    this is requirement of my application.
    can i do this with JSP page or i have to change the technology
    plz help me
    plz reply as asoon as possible
    thanx in advance
    THANKS & REGARDS
    vikas

    http://java.sun.com/developer/Books/javaprogramming/cookbook/11.pdf

  • Serial port communication problems

    Hello.  I am trying to control a MKS Instruments 651C Pressure Controller via RS-232.  Right now, I am just trying to establish basic communication with the device over the serial port.  I can connect to the device with windows hyperterminal using the following settings:
    Bits per second: 9600
    Data bits: 8
    Parity: None
    Stop bits: 1
    Flow control: None
    Once I connect, I go to File-->Properties, Settings tab,and click on ASCII Settings button.  I must check the following boxes (not checked by default) for any communication to occur:
    Send line ends with line feeds
    Echo typed characters locally
    Append line feeds to incoming line ends
    Force incoming data to 7-bit ASCII
    Once I have all that set, I can communicate with my device via hyperterminal.  What I would like to do now is to use LabVIEW to control the device, so I need to be able to send/receive data over the RS-232 connection via LabVIEW.  I have been using the Basic Serial Write and Read vi, but I am not getting any response from my device.  Looking at the block diagram for the basic read/write, I saw that  Enable Termination Char was hardwired to false, so I changed it to a control and set it to true.  I also changed Termination Char to a control and set it to 0xD for CR.  I still cannot get a response from the device.
    I'm guessing that I am still not setting everything for the serial port setup correctly.  Can anyone give me some suggestions on what else to modify to match my hyperterminal settings?  Thanks!
    Solved!
    Go to Solution.

    Have you tried running NI-Spy to see what is actually happening on the serial port? This may help you narrow down what is happening. I also wonder if you are having an issue since you are using 8-bit ASCII when you open the port but in hyperterminal you are telling it to use 7-bit ASCII to read the data.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Unable to connect to SRW224P via web base and serial port on the front until reboot switch

    Just installed new SRW224P switch 4 days ago and we lose connectivy to the SRW224P manage switch. Try to Web in to device and also direct serial port unable to get connected, reboot and it works for a little bit but then we loose connectivity again. Also the computers connected to the switch loose their IP address and sometimes unable to get a DHCP address assigned back from are server.
    Any suggestions?
    (Edited for guideline compliance.Thanks!)Message Edited by JOHNDOE_06 on 05-14-2007 09:20 AM

    I ended up doing a replacement with linksys, the new one has been in place for 2 weeks and it seems to be running ok.

Maybe you are looking for

  • SAP CRM - no confidence in UI by SAP?

    After reading this blog and looking at the article attached to the blog.  I had an interesting question: Can Rich Internet Applications finally be accepted as a credible application development platform for SAP? Does SAP have any confidence in its ow

  • Export to Flash CS3 doesn't work

    Hello, I have Captivate 4 and Flash CS3 (full versions) - WinXP. When I want export Captivate project to Flash - "File -> Export -> Project to -> Flash CS3" I will get only notify: "Cannot initialize Cpativate FLA Exporter. You may need to restart Fl

  • R/3 4.6C  to SAP WAS J2EE engine

    Hi, I am new ABAP Programming and more into J2EE. I would like to know different approachs available to communicate or send data from ABAP to J2EE engine/Web Applicaiton asynchronously. I am looking for SAP WAS 6.40 Thanks in Advance

  • CommandLink broken by AUTO_SCROLL and Tomahawk-1.1.3.jar

    Hi, I have been experiencing problems with a simple commandLink component on a JSF web page, using the MyFaces implementation downloaded from BEA. The link raised a JavaScript error when used (IE6 reported "Object expected"). (I'm using Workshop for

  • CO assignment object for sales revenue account

    while doing the intercompany billing after PGI, system is throwing an error 'account assignment object is required for sales revenue account xxxxxx'.  However, the sales revenue account is created as a revenue element and the profit centre accounting