Im developing SMS application in java for reading SMS.Im sending AT commands to GSM mode for sending an SMS,messages is sending successfully ,but im not getting any response from the modem.If i send the AT commands through Hyperterminal im getting the response.Whats the exact problem?
InputStream inputStream;
OutputStream out;
this.inputStream = serialPort.getInputStream();
this.out = serialPort.getOutputStream();
out.write(("AT"+"\r").getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
out.write(("AT+CMGF=1"+"\r").getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
out.write(("AT+CMGS=\""+"+91xxxxxxxxxx"+"\""+"\r").getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
out.write(("TEST "+cntrlZ).getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
//Im using SerialPortEventListener to read the input from modem
int a = inputStream.available();
System.out.println(inputStream.available() + " BYTES AVAILABLE ");
inputStream.read(readBuffer, 0, a);
I also tried to read after sending each AT commands,but im not getting anything as a response from the modem.
After setting the flow control for the serial port its working fine.
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN | SerialPort.FLOWCONTROL_RTSCTS_OUT);