或者相关资料也可以,http://www.gjwtech.com/serialcomm.htm 这个网站的就不用给我了。
解决方案 »
- 没有被明显的调用或引用然而注释以后与注释前的结果却不同,请给予指点!
- oracle jdbc char 字段 PreparedStatement 查询问题
- Java华容道游戏
- 对于equals和==的比较 有人能有函数把地址给打出来吗?
- 纯java如何通过Thin连接Oracle9i并查询数据库,纯java如何调用jdbc
- 简单的JAVA包问题,在线求解
- 字串转换输出?高手帮忙!!!
- 谁知道在哪能下到《java技术手册》?
- 关于jar包中使用URLConnection的问题
- 请帮我看看这小段代码,为什么不能在循环中执行sql?
- 晕啊,郁闷几天啊!
- 如果一个jar包执行需要其他的jar,在manifest文件怎么写呢?
以下是一个发送at命令到com口的程序:
import java.io.*;
import java.util.Enumeration;
import javax.comm.*;public class SimpleWrite
{ static Enumeration portList;
static CommPortIdentifier portId;
static SerialPort serialPort;
static OutputStream outputStream;
static InputStream inputStream;
static char c34;
static char c26 = '\032';
static String mString1 = "AT+CSCA=+8613800200500" + "\n";
static String mString2="AT+CMGF=1" + "\n";
static String mString3="AT+CMGS=\"+86136.....\"" + "hello" + '\032'+"\n";
//static String messageString1 = "AT+CMGS=\"136.....\"\n\r";
//static String messageString2 = "Got this Message? \u001A\r";
public SimpleWrite()
{
} public static void main(String args[])
throws Exception
{
CommPortIdentifier commportidentifier = CommPortIdentifier.getPortIdentifier("COM2");
serialPort = (SerialPort)commportidentifier.open("sms app", 3000);
try
{
outputStream = serialPort.getOutputStream();
inputStream = serialPort.getInputStream();
}
catch(IOException ioexception)
{
}
try
{
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE); }
catch(UnsupportedCommOperationException unsupportedcommoperationexception)
{
} try
{
outputStream.write(mString1.getBytes());
outputStream.write(mString2.getBytes());
outputStream.write(mString3.getBytes());
outputStream.flush();
outputStream.close(); }
catch(IOException ioexception1)
{
}
}}