[問題] 關於使用java comm來寄sms的問題
小第算是java的新手 最近寫了一個寄sms的程式
public class Main {
public static void main(String[] args) throws PortInUseException, IOException, NoSuchPortException, UnsupportedCommOperationException {
String port1="COM6";
OutputStream outputStream;
InputStream inputStream;
int msg;
try {
//建立com port連線
SerialPort serialPort1 = (SerialPort) CommPortIdentifier.getPortIdentifier(port1).open("Main", 2000);
try {
serialPort1.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
inputStream = serialPort1.getInputStream();
outputStream = serialPort1.getOutputStream();
outputStream.write("at+cmgf=0\r\n".getBytes()); //進入PDU模式
outputStream.write("at+cmgs=18\r\n".getBytes());
outputStream.write("0011000c918896356712340004aa0441424344".getBytes());
outputStream.write(new byte[]{(byte)0x1a});
/*String aaa=Integer.toHexString(26);
System.out.println(aaa);
outputStream.write(aaa.getBytes());*/
int size = 0;
while(true)
{
while(( size = inputStream.available()) > 0 )
{
byte [] feedback= new byte [size];
msg=inputStream.read(feedback,0,feedback.length);
System.out.println(new String(feedback));
}
}
} catch (UnsupportedCommOperationException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (NoSuchPortException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
在ctrl+z的地方,也就是0x1A的地方,一直失敗
無法完成寄信,使用過很多種ctrl+z的方式
回傳值只有停在
at+cmgf=0
OK
這邊
請問這邊的問題是出在那裡呢??
謝謝大家
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.171.99.142
→
12/26 14:35, , 1F
12/26 14:35, 1F
→
12/26 14:44, , 2F
12/26 14:44, 2F
→
12/26 14:45, , 3F
12/26 14:45, 3F
→
12/26 15:13, , 4F
12/26 15:13, 4F