Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 3rd, 2008, 04:24 PM
Newbie
 
Join Date: Aug 2008
Age: 26
Posts: 30
Default Problem to listout the ports in javax.comm package

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..
Reply
  #2  
Old October 3rd, 2008, 04:30 PM
Moderator
 
Join Date: Mar 2007
Location: Voorschoten, the Netherlands
Age: 52
Posts: 8,493
Default

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
Reply
  #3  
Old October 10th, 2008, 06:50 AM
Newbie
 
Join Date: Aug 2008
Age: 26
Posts: 30
Default

Quote:
Originally Posted by JosAH
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?
Reply
  #4  
Old October 10th, 2008, 08:08 AM
Moderator
 
Join Date: Mar 2007
Location: Voorschoten, the Netherlands
Age: 52
Posts: 8,493
Default

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
Reply
  #5  
Old October 10th, 2008, 12:17 PM
Newbie
 
Join Date: Aug 2008
Age: 26
Posts: 30
Default

Quote:
Originally Posted by JosAH
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 getPortIdentifiers() 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 getPortIdentifiers() Method?
Reply
  #6  
Old October 10th, 2008, 12:30 PM
Moderator
 
Join Date: Mar 2007
Location: Voorschoten, the Netherlands
Age: 52
Posts: 8,493
Default

Quote:
Originally Posted by rajujrk
What happened in the getPortIdentifiers() 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
Reply
  #7  
Old October 11th, 2008, 08:09 AM
Newbie
 
Join Date: Aug 2008
Age: 26
Posts: 30
Default

Quote:
Originally Posted by JosAH
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.properties

What is the third file?

I have another file as win32.dll
Reply
  #8  
Old October 11th, 2008, 08:24 AM
Moderator
 
Join Date: Mar 2007
Location: Voorschoten, the Netherlands
Age: 52
Posts: 8,493
Default

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
Reply
  #9  
Old October 11th, 2008, 08:38 AM
Newbie
 
Join Date: Aug 2008
Age: 26
Posts: 30
Default

Quote:
Originally Posted by JosAH
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..
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles