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
- 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) {}
- }
- }
Please i need the solution.. Its Urgent..
Thanks in Advance..