最近接受一个老项目,其中用到了comm.jar这个包,但是没有相关文档参考,查了好多资料,也没找到,谁哪里有的话,麻烦给我发一份,谢谢了!
解决方案 »
- MyFaces 2.0.4 java.lang.NullPointerException at javax.faces.component.UIViewRoot
- java写的Client如何处理webservice返回的复杂数据类型
- 刚刚工作的新手,请教一个struts简单问题.
- iBATIS的简单问题,大家帮帮我
- 调用axis服务出错的问题
- 各位高人,我在win2000下配置iis 和tomcat完以后,ie下http://localhost 成功显示,可是运行jsp和serverlet的例子时,却直接显示源代码,
- 怎么在Struts中取得浏览器所用的协议?JSP中哪个对象包含了与协议有关的东东?
- 请教:JAVA中有没有办法能直接访问内存地址,
- 使用用RATIONAL ROSE,设计好一个类后, 怎样生成某种编程语言(比如是JAVA)的对应程序代码呢?
- java 线程
- 传说中JAVA底层的面试题第二季(标题党)
- double类型除数结果疑问(新手问题)
前几天为了回答一个多线程读写串口问题的帖子,在公司下了一个看了一下,现在家里没有
CommPortIdentifier portId;
Enumeration en = CommPortIdentifier.getPortIdentifiers();
// iterate through the ports.
while(en.hasMoreElements()) {
portId = (CommPortIdentifier) en.nextElement();
System.out.println(portId.getName());
if(portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
System.out.println(portId.getName());
}
} portId = CommPortIdentifier.getPortIdentifier("COM1");
SerialPort sPort = (SerialPort) portId.open("串口所有者名称", 1000);
System.out.println("start-----------");
final InputStream is = sPort.getInputStream();
sPort.addEventListener(new SerialPortEventListener() {
public void serialEvent(SerialPortEvent e) {
//System.out.println("-->" + e.getEventType());
if(e.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
try {
//System.out.println(is.available());
int x = 0;
byte[] msgPack = new byte[35];
while(true) {
int j = is.read(msgPack, x, msgPack.length - x);
System.out.println("j=" + j);
if(j <= 0)
break;
x += j;
if(false)
break;
// System.out.println("x->" + x);
// for(int i = 0;i < 4;i++) {
// int newData;
// if((newData = is.read()) != -1) {
// msgPack[i] = (byte) newData;
// System.out.println(newData);
// } else {
// break;
// }
// System.out.println("--------");
// }
}
System.out.println("x-> " + x);
for(byte a : msgPack) {
System.out.print(Integer.toHexString(a) + " ");
}
System.out.println();
System.out.println(new String(msgPack, 0, 34));
if(1 == 1)
return;
} catch(Exception es) {
es.printStackTrace();
}
}
}
});
sPort.notifyOnDataAvailable(true);
sPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);