Mam takie problem program wysyła komendy at na portc COM jednak nic sie nie dzieje. Gdy te same komendy wpisuje przez terminal portu szeregowego modul gsm wysyla wiadomosc SMS. W czym moze być problem ponizej wklej kod programu
package zapis;
import java.io.*;
import java.util.*;
import gnu.io.*;
public class prawiefinal {
static Enumeration portList;
static CommPortIdentifier portId;
static String messageString = "AT+CMGF=1 \r";
static String messageString2 = "AT+CMGS=\"+48668870895\"\r";
static String messageString3 = "TESTY \032\r\n";
static SerialPort serialPort;
static OutputStream outputStream;
public static void main(String[] args) throws InterruptedException {
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals("COM3")) {
try {
serialPort = (SerialPort)
portId.open("COM3", 2000);
} catch (PortInUseException e) {System.out.println("err");}
try {
outputStream = serialPort.getOutputStream();
} catch (IOException e) {System.out.println("err1");}
try {
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {System.out.println("err2");}
try {
outputStream.write(messageString.getBytes());
Thread.sleep(3000);
outputStream.write(messageString2.getBytes());
Thread.sleep(3000);
outputStream.write(messageString3.getBytes());
Thread.sleep(3000);
outputStream.write(26);
outputStream.flush();
System.out.println(messageString);
Thread.sleep(3000);
outputStream.close();
serialPort.close();
} catch (IOException e) {System.out.println("err3");}
}
}
}
}
}