Protocol serialPort = new Protocol(); serialPort.open("0;baudrate=9600;bitsperchar=8;stopbits=1;parity=none;autorts=off;autocts=off;blocking=off",1, true);......
(3)发送数据,通过serialPort对象的openOutputStream()方法,获取OutputStream数据流,并赋给os对象,代码为OutputStream os = serialPort.openOutputStream()。然后,读取Palm内部数据库gpsd的每条记录内容,将内容按字节通过串行通讯传送到PC,并通过os.write(),将数据写入串口。主要代码为:
byte [] rnl={13,10}; for (int i=0;i { Graphics.getGraphics().drawString("send record No."+i,30,100); os.write(db.getRecord(i)); os.write(rnl); } os.flush(); ......
public void serialEvent(SerialPortEvent event) { switch(event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPo