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