473,729 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem to listout the ports in javax.comm package

107 New Member
hi, currently i am doing the project to send the sms from PC to Mobile and vice versa using GSM modem. I successfully done this process in Hyperterminal.

First i connect the GSM modem in COM1 port

then set the baud rate to 9600

and execute the AT commands in hyperterminal and its works fine..

But my problem is that to do the similar process in java..

javax.comm package is used to interact with the ports..

I used the below code

Expand|Select|Wrap|Line Numbers
  1.         portList = CommPortIdentifier.getPortIdentifiers();
  2.  
  3.         while (portList.hasMoreElements()) {
  4.             portId = (CommPortIdentifier) portList.nextElement();
  5.             if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
  6.                 if (portId.getName().equals("COM1")) {
  7.                 //if (portId.getName().equals("/dev/term/a")) {
  8.                     try {
  9.                         serialPort = (SerialPort)
  10.                             portId.open("SimpleWriteApp", 2000);
  11.                     } catch (PortInUseException e) {}
  12.                     try {
  13.                         outputStream = serialPort.getOutputStream();
  14.                     } catch (IOException e) {}
  15.                     try {
  16.                         serialPort.setSerialPortParams(9600,
  17.                             SerialPort.DATABITS_8,
  18.                             SerialPort.STOPBITS_1,
  19.                             SerialPort.PARITY_NONE);
  20.                     } catch (UnsupportedCommOperationException e) {}
  21.                     try {
  22.                         outputStream.write(messageString.getBytes());
  23.                     } catch (IOException e) {}
  24.                 }
  25.             }
  26.  
  27.  
But the problem is that results the port count is 0(Null).
Please i need the solution.. Its Urgent..

Thanks in Advance..
Oct 3 '08 #1
9 6474
JosAH
11,448 Recognized Expert MVP
Note that saying "It's urgent" doesn't help you much: it may be urgent to you but
it isn't urgent to us and we won't hurry and treat you in a priviledged way because
you mentioned your urgency; you'd better had started your project a bit earlier.

w.r.t. your question: Sun's comm package only handles parallel and serial ports;
it doesn't understand, nor recognizes any usb ports.

kind regards,

Jos
Oct 3 '08 #2
rajujrk
107 New Member
Note that saying "It's urgent" doesn't help you much: it may be urgent to you but
it isn't urgent to us and we won't hurry and treat you in a priviledged way because
you mentioned your urgency; you'd better had started your project a bit earlier.

w.r.t. your question: Sun's comm package only handles parallel and serial ports;
it doesn't understand, nor recognizes any usb ports.

kind regards,

Jos
But Even it didn't list out the PARALLEL and SERIAL ports

Why?
Oct 10 '08 #3
JosAH
11,448 Recognized Expert MVP
What happens when you append a line (after line #4) like this:

Expand|Select|Wrap|Line Numbers
  1. System.out.println(portID.getName());
  2.  
Is anything printed at all?

kind regards,

Jos
Oct 10 '08 #4
rajujrk
107 New Member
What happens when you append a line (after line #4) like this:

Expand|Select|Wrap|Line Numbers
  1. System.out.println(portID.getName());
  2.  
Is anything printed at all?

kind regards,

Jos

AFter the Below Statement
Expand|Select|Wrap|Line Numbers
  1. portList = CommPortIdentifier.getPortIdentifiers(); 
  2.  
the getPortIdentifi ers() method return no values . So the below while says always false
Expand|Select|Wrap|Line Numbers
  1.         while (portList.hasMoreElements()) { 
  2.  
  3.          }
  4.  
What happened in the getPortIdentifi ers() Method?
Oct 10 '08 #5
JosAH
11,448 Recognized Expert MVP
What happened in the getPortIdentifi ers() Method?
Did you properly install all three files? i.e. the jar in the lib/ext directory, the dll
in the bin directory and the .properties file in the lib directory.

kind regards,

Jos
Oct 10 '08 #6
rajujrk
107 New Member
Did you properly install all three files? i.e. the jar in the lib/ext directory, the dll
in the bin directory and the .properties file in the lib directory.

kind regards,

Jos
ya, i installed it in lib/ext

I include the following files

1. comm.jar
2. javax.comm.prop erties

What is the third file?

I have another file as win32.dll
Oct 11 '08 #7
JosAH
11,448 Recognized Expert MVP
Store that .properties file in /lib instead. So:

1) the .jar in /lib/ext
2) the .properties in /lib
3) the .dll in /bin

Also read their installation notes.

kind regards,

Jos
Oct 11 '08 #8
rajujrk
107 New Member
Store that .properties file in /lib instead. So:

1) the .jar in /lib/ext
2) the .properties in /lib
3) the .dll in /bin

Also read their installation notes.

kind regards,

Jos

Ya its working fine now..

I put .properties file in lib/ext

i change its loc to lib

Now its works fine

Thank you..
Oct 11 '08 #9
Bharti Goel
1 New Member
hi,

I am trying to do this same task. For me it is recognizing the ports but not sending the sms. It works fine via hyperterminal. Is it possible for you to send me your code?

Thanks a lot.

regards
Bharti
Dec 8 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6562
by: Hal Vaughan | last post by:
I'm using JDK 1.4.1 for Java 2. According to the API docs, I can use javax packages, but when I add: import javax.crypto; I get an error that it can't find the package. Is there some special way to get javax packages? According to a web page at Sun, the crypto is supposed to be included with 1.4. (That's how they write it -- no 1.4.1 or 1.4.2, just written as 1.4.)
4
5393
by: jesper | last post by:
Hi I am currently following the tutorial from IBM (http://www-106.ibm.com/developerworks/xml/edu/x-dw-xjaxb-i.html) I have three problems at the moment. 1. It says else where that when the source code files are generated using the XJC, it is possible to compile the generated source code using javac generated\*.java generated\impl\*.java , but this only gives me 97 errors.?
13
11030
by: Bob Greschke | last post by:
We have some equipment that communicates at 57600 baud RS232. The path from the PC is USB to a Phillips USB hub, then off of that a TUSB3410 USB/Serial converter. The driver for the 3410 chip creates a "normal" comm port (like COM3). There is a C++ program that has no problem talking to the equipment, but two Python programs have trouble. One is a big, scary, controller program, and the other, since that is the one I'm having trouble...
0
2108
by: Raquel | last post by:
I downloaded UDB PE8.1.3 on Win XP. JDK gets downloaded along with it (Java version 1.3.1). However, when I am trying to compile a java program which uses DataSource interface for Connections (by importing javax.sql.*), it gives me an error message that it could not locate javax.sql package. Found the following on Sun's website: "If your driver vendor bundles the javax.sql package with its product, as many are expected to do, you do...
3
1531
by: Steve | last post by:
Hi All and seasons greetings. Is there an easy way of getting a list of current Comm ports on a machine? I suspect that most machines these days have 1 and 2, but there could be others and I would like to get a list of them to offer the end user. Many thanks, Steve.
12
11336
oll3i
by: oll3i | last post by:
when i launch the application from sun application server the console opens throws something i cannt even read what and closes before the application opened and threw nullpointerexception now it suddenly stopped even opening ? but when i run it form bat with JAVA_CLIENT parameter it throws javax.ejb.EJBException: nested exception is: java.rmi.RemoteException: package library.common; import java.sql.ResultSet;
3
16555
by: psroga | last post by:
Can anyone look at this code and let me know why pthread_mutex_unlock and pthread_mutex_lock are giving me the "phtread_mutex_unlock" was not defined in this scope error. I am compiling the code on g++. # g++ -v Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man -- infodir=/usr/share/info --enable-shared --enable-threads=posix -- enable-checking=release --with-system-zlib...
1
14054
by: shrik | last post by:
hi everybody. I have following problem. There are two pages. index.jsp and main.jsp in my application Index.jsp contains logging interface in . It submits password and userid to loginform bean. following are entries in struts-config.xml file <action input="index.jsp" name="loginform" path="/login" scope="session" type="com.myapp.struts.loginaction"> <forward name="success" path="/main.jsp"/>
1
2311
by: Neverhood | last post by:
Hi folks, I'm trying to make a small game about being a drug dealer, with a 10x8 grid JPanel. On top of that i have another 10x8 grid JPanel as glassPane for the player icon. I have all the properties of the player in a player object class with getter and setter methods for fx his X and Y position in the grid. When i set up his X and Y position myself everything works fine and he is painted the right place. My problem is when my keyPressed...
0
8930
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9158
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6026
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4799
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3244
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2171
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.