Hi
I am doing a university project and trying to send a sms message from a java program but I can find and open a serial port but I am having problems
sending and reading data from the port.
My first problem is that when I sent AT\r I don't get a reply from my phone but when I open hyperterminal and send AT and press enter I get a reply OK
I have a serial port monitor and it shows that my java program is sending the same characters as in the hyperterminal but I don't get a reply. Can
anyone help?
my second problem is that I need to learn how to do event listening on the port for when data is ready to be read. Here is some of my code please help my due date is this friday.
public static void OpenSerialPort(CommPortIdentifier foundPort) {
if (foundPort != null)
PortID = foundPort;
else {
System.out.println("port null");
return;
}
try {
// Open port and cast as serial port
Port = PortID.open("SMS Program", 2000);
SerialPort myPort = (SerialPort) Port;
// set up the serial port parameters
myPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
myPort.setFlowControlMode(SerialPort.FLOWCONTROL_N ONE);
is = new DataInputStream(Port.getInputStream());
os = new PrintStream(Port.getOutputStream(), true);
char b[] = {0x61,0x74,0x0d};
os.print("at\r");
//os.write("at\r");
System.out.println("output: AT\r");
// is.read(inputBuffer);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}