 | 
October 3rd, 2008, 04:24 PM
| | Member | | Join Date: Aug 2008 Age: 26
Posts: 38
| | 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 -
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 the problem is that results the port count is 0(Null).
Please i need the solution.. Its Urgent..
Thanks in Advance..
| 
October 3rd, 2008, 04:30 PM
|  | Moderator | | Join Date: Mar 2007 Location: Voorschoten, the Netherlands Age: 52
Posts: 8,760
| |
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
| 
October 10th, 2008, 06:50 AM
| | Member | | Join Date: Aug 2008 Age: 26
Posts: 38
| | 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?
| 
October 10th, 2008, 08:08 AM
|  | Moderator | | Join Date: Mar 2007 Location: Voorschoten, the Netherlands Age: 52
Posts: 8,760
| |
What happens when you append a line (after line #4) like this: -
System.out.println(portID.getName());
-
Is anything printed at all?
kind regards,
Jos
| 
October 10th, 2008, 12:17 PM
| | Member | | Join Date: Aug 2008 Age: 26
Posts: 38
| | Quote: |
Originally Posted by JosAH What happens when you append a line (after line #4) like this: -
System.out.println(portID.getName());
-
Is anything printed at all?
kind regards,
Jos |
AFter the Below Statement -
portList = CommPortIdentifier.getPortIdentifiers();
-
the getPortIdentifiers() method return no values . So the below while says always false -
while (portList.hasMoreElements()) {
-
-
}
-
What happened in the getPortIdentifiers() Method?
| 
October 10th, 2008, 12:30 PM
|  | Moderator | | Join Date: Mar 2007 Location: Voorschoten, the Netherlands Age: 52
Posts: 8,760
| | 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
| 
October 11th, 2008, 08:09 AM
| | Member | | Join Date: Aug 2008 Age: 26
Posts: 38
| | 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
| 
October 11th, 2008, 08:24 AM
|  | Moderator | | Join Date: Mar 2007 Location: Voorschoten, the Netherlands Age: 52
Posts: 8,760
| |
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
| 
October 11th, 2008, 08:38 AM
| | Member | | Join Date: Aug 2008 Age: 26
Posts: 38
| | 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..
|  | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | 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 205,248 network members.
|