How to close the COM Port ??????????

Dear all :
I have written an application that send AT commands to a modem , Once I opened a com port , i don't know how to close it . I got the null pointer exception when i create a new channel , because the inputStream and outputStream is owned by the previous channel . So , some one can teach me how to close the com port that opened before ?
my source code for open port :
public void Connect_Com(CommPortIdentifier portId) {
Integer i = new Integer((int) (Math.random()* 1000));
String channel = "channel" + i.toString();
System.out.println(channel);
try {
System.out.println("preparing to open port");
serialPort = (SerialPort) portId.open(channel, 2000);
} catch (PortInUseException e) {}
try {
inputStream = serialPort.getInputStream();
System.out.println("getting inputStream");
          } catch (IOException e) {}
try {
serialPort.addEventListener(this);
          } catch (TooManyListenersException e) {}
serialPort.notifyOnDataAvailable(true);
try {
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}

serialPort.close() ?
From the documentation of SerialPort:
- SerialPort extends CommPort.
- CommPort.close() closes the communications port.

Similar Messages

  • How to set the debug port for Eclipse for OracleAS 10g Enterprise

    Hello All,
    I am using OracleAS 10g Enterprise, and using dcmctl to startup the server.
    But i do not know how to set the debug port in the startup script for debugging with Eclipse.
    I have tried to add the following options to the dcmctl.bat, but still failed:
    -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=4000
    i.e in the dcmctl.bat script:
    set jvmargs=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=4000
    set ex=%ohome%\jdk\bin\java -Djava.net.preferIPv4Stack=true %jvmargs%
    Do anyone know how to configure the debug port setting?
    Thank you for your great help!.

    Hi, have you double checked that your oc4j is started with Sun's JVM or any other JVM that recognizes the kind of remote debug option as above? You can find the JVM used by oc4j in the ORACL_HOME/opmn/conf/opmn.xml.
    To double check that your oc4j is started in debug mode, you can test with another remote debugger. Say, with the jdb in sun's jdk jdb -connect com.sun.jdi.SocketAttach:hostname=yourHost,port=4000 (Personally, I also use Jdeveloper or Jswat to double check.) If you can connect with jdb, then you have to check your Eclipse. Can its remote debugger connect to any java application at all?

  • Communicating via the Com port (comm)

    Hi Folks,
    I'm trying to communicate to the com port on my device but apparently can't "see" any available com ports.
    Actually I'm trying to communicate via the Infrared port on my device and have been able to do so on a Nokia using COM0, however, on an Orange SPV, no ports are available. I'm using the Connector class from GCF.
    I've used
    System.getProperty("microedition.commports")
    and on the Nokia get a load of ports back, however, on the other device I get back null. The device does have a IrDA port so I feel like I should be able to access it, I just don't know how.
    I wondered if there is other ways to get hold of a port?
    Reading http://developers.sun.com/mobility/midp/questions/properties/index.html it implies that the above property is implementation specific, does that mean Midlet Manager implementation specific (the SPV device uses Intent Java).
    Thanks for any suggestions or any tips / links on IrDA / serial communication with ME :)
    Cheers,
    Toby

    Start with the NI modbus library.
    http://sine.ni.com/nips/cds/view/p/lang/en/nid/201​711
    Or download portmon and use it to watch the data as modscan is working. Then use VISA and serial port commands to transfer data bytes until it matches what modscan is transmitting. You'll learn more doing it this way.
    Also download the modbus protocol pdf file.
    http://forums.ni.com/ni/board/message?board.id=170​&message.id=197677&query.id=96682#M197677
    Message Edited by unclebump on 03-10-2008 06:04 PM

  • How to open the comm ports?

    Hi,
    im using javacomm to detect my comm ports.i have two serial
    and a parallel port (com1,com2 and LPT1) but it found no ports and throws
    as follows,
    found: javax.comm.CommPortEnumerator@e83912
    found: 0 open ports
    i placed .properties file in ..\jdk1.5.0\jre\lib
    comm jar file in ..\jdk1.5.0\jre\lib\ext
    and WIN32COM.DLL in ..jre\bin
    am i doing right?
    Here is the code,
    import javax.comm.CommPortIdentifier;
    import javax.comm.SerialPort;
    import javax.comm.PortInUseException;
    import java.util.Enumeration;
    import java.util.Vector;
    public class TestEnumeration {
    public static void main(String args[]) {
    Vector portslist = TestEnumeration.getAvailableSerialPorts();
    System.out.println("found: "+portslist.size()+" open ports");
    public static Vector getAvailableSerialPorts() {
    CommPortIdentifier pId=null;
    SerialPort sPort=null;
    Enumeration pList=null;
    boolean foundport=false;
    pList = CommPortIdentifier.getPortIdentifiers();
    String port=null;
    Vector ports=new Vector();
    if(!pList.hasMoreElements()) {
    System.out.println("found: "+pList);
    return ports;
    while (pList.hasMoreElements()) {
    pId = (CommPortIdentifier) pList.nextElement();
    if (pId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
    foundport=true;
    try {
    sPort = (SerialPort)pId.open("serialport", 1000);
    } catch (PortInUseException e) {
    foundport=false;
    System.out.println(pId.getName()+ " is closed");
    } finally {
    if(sPort!=null) {
    try { sPort.close(); } catch(Exception e) {}
    if(foundport) {
    ports.add(pId.getName());
    System.out.println(pId.getName()+ " is open");
    return ports;
    please help me on how to open the comm ports..

    Try this, It workd for me. Before doing this make sure you have serial ports on you r computer by following these steps:
    open "regedit"
    go to "HKEY_LOCAL_MACHINE" > HARDWARE > DEVICEMAP
    and check if there is any serial ports. If htere is any, then use following program to enumerate throught the ports:
    class SimpleRead() {
    portList = CommPortIdentifier.getPortIdentifiers();
         while (portList.hasMoreElements()) {
         portId = (CommPortIdentifier) portList.nextElement();
         if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
              if (portId.getName().equals(defaultPort)) {
              System.out.println("Found port: "+defaultPort);
              portFound = true;
              SimpleRead reader = new SimpleRead();
         if (!portFound) {
         System.out.println("port " + defaultPort + " not found.");
    }

  • Output Signal From a Desktop Flash application to the COM port

    How do I script to connect /send a signal to the COM port of
    the PC from a Desktop Flash application.
    The Signals can be variables such as "1/2/3/4" . The signals
    will be send on a corresponding click in the flash application. For
    eg: if I click button "A" in the Flash application, it sends a
    signal "1" to the COM Port. If I click the Button"B", it send the
    signal"2" to the COM Port.
    Please advise if it can be done directly or through a Third
    Party software.

    maybe this helps:
    http://www.phidgets.com/downloads.php?example_id=27

  • Using VISA can not find the com port

    I use visa read but can't find any com port in Windows 7.
    How can i find the com port in Windows 7?? 
    由 jw2002 在 06-28-2009 09:20 AM
    上編輯的訊息
    由 jw2002 在 06-28-2009 09:20 AM
    上編輯的訊息
    Solved!
    Go to Solution.

    Windows 7 is not officially supported by National Instruments as it hasn't even been released. That means you won't get any official support from NI on this.
    That said, does your computer actually recognize a serial port? Do you have an actual serial port, or do you have some sort of virtual COM port, or are you using some sort of adapter, such as a USB to serial port box? If it's any of the latter, the most likely reason is a driver issue which needs to be written to be compatible with Windows 7. 

  • How to find the listener port on windows?

    Hi Friends,
    We have a client who is still using Oracle 8.0.6 on NT 4.0
    I have a laptop with oracle client 10g.
    I want to connect to the NT database to check it.
    How do I know what port does the listener used ? what is the command to run at the c:\ command prompt?
    I tried> c:\ lsnrctl stat but the command is not recognized
    I tried to find the lsnrctl and bin but there is not.
    Please help
    Thanks a lot

    ytterp2009 wrote:
    Please help.. and please do NOT post [duplicate posts|http://forums.oracle.com/forums/thread.jspa?threadID=935282&tstart=0]
    How to find the listener port on windows?The Internet Protocol stack comes with a number of utilities - one of these, called netstat, is very useful to determine which processes are doing what to which IP ports on that platform. Unfortunately, different flavours are implemented. So the Windows one does not support the parameters and output than the Unix/Linux one.
    You can use the following on Windows (run it via a command console) to see what processes are listening on what address and port number:
    c:\> netstat -n -a -p tcp
      -n = display IP addresses and ports in numeric format
      -a = list all ports (including ones used for listening
      -p tcp = only display protocol entries for TCP An Oracle listener entry should look something as follows:
    Proto   Local Address  Foreign Address   State
    TCP     0.0.0.0:1521   0.0.0.0:0         LISTENINGSeeing IP +0.0.0.0+ means that the Listener is accepting connections on all your network interfaces - which is standard. The port number is typically 1521. The foreign address is meaningless for a port in listening state.
    PS. Why not simply check the listener.ora configuration file? Because what is actually happening may not be what you thought you configured to happen..

  • Using VISA and RS232 devise , loosing the COM port .

    Using VISA and R232 devise communicating fine with labview and I can  Read and Write.
    however, I want to turn OFF the devise, then turn it ON again (part of the test), and be able to continue .
    The COM port is not communicating . unless I turn both the devise off  and Exit  LV then restart again.
    How to do that without restarting LV.
    thanks

    " Is there a better way to make sure its closed and driver is not hanging onto the connection? "
    you could try a command like " devcon disable usb\vid_0CD5*0003~" and then "devcon enable usb\vid_0CD5*0003~"
    ( you will need to figure out the ID of your device, my example is for a LabJack U3. )
    Get the devcon.exe-utility from microsoft.
    but as mentioned before, just watch what happens with device Manager (' run devmgmt.msc')...
    to enable/disable a device in a VBS script you can use below example,   (As Administrator!)
    Option explicit
    Dim oShell
    set oShell= Wscript.CreateObject("WScript.Shell")
    oShell.Run "RunAs /user:Domain\USER ""cmd"
    WScript.Sleep 100
    oShell.Sendkeys "USERPASSW"
    WScript.Sleep 500
    oShell.Sendkeys "devcon disable usb\vid_0CD5*0003~"
    WScript.Sleep 1000
    WScript.Sleep 100
    oShell.Sendkeys "devcon enable usb\vid_0CD5*0003~"
    WScript.Sleep 1000
    oShell.Sendkeys "exit~"
    Wscript.Quit
    My reason for doing it this way is that my USB device didn't respond to any of my calls from Labview. Enable/Disable solved the issue...
    The thing I particularly hate about above VBS-script is that I need to send the Admin password in plain text...

  • Signal From a Desktop lash application to the COM port

    How do I script to connect /send a signal to the COM port of
    the PC from a Desktop Flash application.
    The Signals can be variables such as "1/2/3/4" . The signals
    will be send on a corresponding click in the flash application. For
    eg: if I click button "A" in the Flash application, it sends a
    signal "1" to the COM Port. If I click the Button"B", it send the
    signal"2" to the COM Port.
    Please advise if it can be done directly or through a Third
    Party software.

    maybe this helps:
    http://www.phidgets.com/downloads.php?example_id=27

  • How to change the default port of webdispatcher

    Hello Everyone,
    We wish to  know to how to change the default port of SAP webpatcher port from 81$$ to 80.
    Appreciate your response.
    Thanks,
    Vadi

    Hello Vadi
    you have to change the PORT value in your profile parameter from 81$$ to 80
    icm/server_port_0 = PROT=HTTP,PORT=81$$ to
    icm/server_port_0 = PROT=HTTP,PORT=80
    Also, in SMICM, then change http service port and activate it and above parameter will require SAP restart
    $$ is used generally to accomodate multiple port services running in SMICM and so as to avoid the parameter setting according to instance number of any system.
    thanks
    Bhudev

  • How to close the detach popup on click of a button in the panel collection

    Hi,
    I'm using Jdeveloper 11.1.2.3.0.
    I have an af table surrounded by panel collection. There is a button on panel collection to commit the changes in the table.
    Clicked detach button to view the table in full browser.
    On click of Commit button, the detach popup is not closed. I have set partialSubmit of that button to false. Then also detach popup is not closed.
    Can anybody suggest me how to close the detach popup on click of a button in the toolbar.
    Thanks,
    Vinod

    Hi Frank,
    Thanks for your response. Popup is not closed.
    I tried this approach, when the view tree is navigated on the Detach, I see that the tree is same as if it is traversed on the page without detach.
    Printed client id and UI component class in the while loop, result is as below.
    r1:0:pc1:t3 class oracle.adf.view.rich.component.rich.layout.RichToolbar
    r1:0:pc1 class oracle.adf.view.rich.component.rich.output.RichPanelCollection
    r1:0:ph2 class oracle.adf.view.rich.component.rich.layout.RichPanelHeader
    r1:0:pgl1 class oracle.adf.view.rich.component.rich.layout.RichPanelGroupLayout
    r1 class oracle.adf.view.rich.component.rich.fragment.RichRegion
    pgl1 class oracle.adf.view.rich.component.rich.layout.RichPanelGroupLayout
    db2 class oracle.adf.view.rich.component.rich.layout.RichDecorativeBox
    db1 class oracle.adf.view.rich.component.rich.layout.RichDecorativeBox
    psl1 class oracle.adf.view.rich.component.rich.layout.RichPanelStretchLayout
    ps1 class oracle.adf.view.rich.component.rich.layout.RichPanelSplitter
    f1 class oracle.adf.view.rich.component.rich.RichForm
    Tried with setting partialsubmit property to false on the command button, still the popup is not closed and my Faces Message are shown behind the detach popup.
    Thanks,
    Vinod

  • Can the Com port on the EX90 be connecting to an AMX NI700 to receive command?

    if so, what are the pinouts for the EX90? (TX/RX/GND) The AMX uses pin 3 for TX, Pin 2 for RX and Pin 5 for GND. I have been using an RJ45 cable and trying to match pins but I am still not getting a TX signal. Also, does the COM port need to be enabled?

    The EX90 is not really build to be controlled by an additional control system.
    (in general thats a thing for the integrator prodcucts).
    The Serial port is not a RS232 (+/-25 Volt), instead of their using TTL level.
    So a direct connection without a proper cable might cause a hardware fault!
    I think the serial port was on by default, but that might have changed on the current software versions, thats what works fine for me:
    xconf // serial
    *c xConfiguration SerialPort BaudRate: 38400
    *c xConfiguration SerialPort LoginRequired: Off
    *c xConfiguration SerialPort Mode: On
    The serial port is also on the bottom of the device, its ok to use it if you need to
    troubleshoot boot issues, but besides that not really usable.
    Dont expect Cisco to do any support for this if you run in to strange behavior when
    controling the system with a 3rd party control.
    Btw, what I would strongly recommenced is to use the telnet/ssh cli or http(s) API.
    could picture that this might work with the AMX700, so why even think of using a serial port, ...

  • HT3625 How to change the audio port function (input, output) on OSX 10.9.2 !!!! :(

    The thing is that i saw some videos, and search for options of how to change the audio port.  And even apple says that i have to change it from system preferences, but when i try to change it, the option doesn't appear me.

  • How to close the window openned by System Exec VI automatica​lly?

    Hello,
    I am using System Exec VI to lauch an exe file built from a LabVIEW program. When running System Exec VI, the window of exe file pop out and stays there even after all tasks are completed. I have to close it every time manually. Anyone here know how to close the exe file window automatically when it's done?
    Thanks,
    Jean
    Message Edited by Jean_CLD on 03-25-2010 11:25 AM
    Message Edited by Jean_CLD on 03-25-2010 11:29 AM
    Solved!
    Go to Solution.

    If I understand the question correctly you need to add an invoke node at the end of your application to exit. Depending on the whether it is running as a stand alone application or within LabVIEW it will either exit or stop execution. I've attached the VI I use in my applications.
    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
    Attachments:
    Exit application.vi ‏13 KB

  • How long does the number porting process take?

    Hello Everybody! I just got my iphone (witch I LOVE it by the way) but I was wondering, how long does the number porting process take?
    I ported my phone number over from SprintPCS last night at around 7pm EST and right now it's 8am EST and my Palm seems to still be working... Is this normal?
    I'm still receiving incoming calls to my Palm, Text messages to my Palm, but yet I can do outgoing calls from my iphone... I'm kinda confused...
    I mean I received the text on my iphone from sprint telling me: "Welcome to AT&T" as well as receiving the e-mail saying my new phone number is the same one I've had for 6 years now... Is 13 hours considered normal?
    Thanx! :-D

    QueenYvette,
    If it continues to be an issue tomorrow, I would recomend calling again, and getting in contact with AT&T's porting department. They are familiar with resolving any issues that may arise.
    Powering off both phones is to make sure that the old phone is not maintaining an active connection with the old carrier that can interfere with the last steps of the porting process. If at all possible its a good idea to leave the old phone powered off, and restart the new phone about once an hour so that it will resync with the towers.
    Hope this helps,
    Nathan C.

Maybe you are looking for

  • How can I fix this compatibility problem?

    After running software updates, including to Microsoft Office, I can't open mail attachments or connect with shared calendars. How can I fix this?

  • Printer asks for a proxy

    I am trying to set up web ePrint but the printer can't access the network and is adking for a proxy setup. How do I find out what that is? This question was solved. View Solution.

  • Script Prepartion in shell

    Hi, I tried to automated Re-Org script Prepartion for tables. Geneally We check first with Dba_tables to confirm partitions,then dba_tab_partitions, then dbs_tab_subpartitions. In the same way,We check index also. I unable to complete above things in

  • I can't get Firefox to even attempt to download. What am I doing wrong?

    When I try to download Firefox, nothing happens. Even when I click the "click here if screen doesn't pop up" and even after I "click here" nothing happens. I am not sure what I am doing wrong or/and why it doesn't work.

  • How to transfer music from old shuffle to new one

    Old shuffle was defective...apple sent a new one...now need to transfer music from old shuffle to new one. Please help. Apple support says.....can't be done....but...go to apple community and ask for help.    HELP!!!!!!!