亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? serialconnection.java

?? sms program related to the j2me by which we can send sms
?? JAVA
字號:
import javax.comm.*;import java.io.*;import java.awt.TextArea;import java.awt.event.*;import java.util.TooManyListenersException;/**A class that handles the details of a serial connection. Reads from oneTextArea and writes to a second TextArea.Holds the state of the connection.*/public class SerialConnection implements SerialPortEventListener,					 CommPortOwnershipListener {//    private SerialDemo parent;/*    private TextArea messageAreaOut;    private TextArea messageAreaIn;    */    private SerialParameters parameters;    private OutputStream os;    private InputStream is;    private KeyHandler keyHandler;    private CommPortIdentifier portId;    private SerialPort sPort;    private boolean open;    private String receptionString="";    public String getIncommingString(){      byte[] bVal= receptionString.getBytes();      receptionString="";      return new String (bVal);  }    /**    Creates a SerialConnection object and initilizes variables passed in    as params.    @param parent A SerialDemo object.    @param parameters A SerialParameters object.    @param messageAreaOut The TextArea that messages that are to be sent out    of the serial port are entered into.    @param messageAreaIn The TextArea that messages comming into the serial    port are displayed on.    */    public SerialConnection(SerialParameters parameters) {        this.parameters = parameters;	open = false;   }   /**   Attempts to open a serial connection and streams using the parameters   in the SerialParameters object. If it is unsuccesfull at any step it   returns the port to a closed state, throws a   <code>SerialConnectionException</code>, and returns.   Gives a timeout of 30 seconds on the portOpen to allow other applications   to reliquish the port if have it open and no longer need it.   */   public void openConnection() throws SerialConnectionException {       // System.out.println("OK 0 ");	// Obtain a CommPortIdentifier object for the port you want to open.        	try {           // System.out.println(parameters.getPortName());	    portId = CommPortIdentifier.getPortIdentifier(parameters.getPortName());	} catch (NoSuchPortException e) {           // System.out.println("Yes the problem is here 1 ");            e.printStackTrace();	   // throw new SerialConnectionException(e.getMessage());	}catch(Exception e)        {          //  System.out.println("ErrorErrorErrorError");            e.printStackTrace();        }        //System.out.println(portId);        //System.out.println("OK 1 ");	// Open the port represented by the CommPortIdentifier object. Give	// the open call a relatively long timeout of 30 seconds to allow	// a different application to reliquish the port if the user	// wants to.	try {	    sPort = (SerialPort)portId.open("SMSConnector", 30000);	} catch (PortInUseException e) {            	    throw new SerialConnectionException(e.getMessage());	}        //System.out.println("OK 2 ");        sPort.sendBreak(1000);	// Set the parameters of the connection. If they won't set, close the	// port before throwing an exception.	try {	    setConnectionParameters();	} catch (SerialConnectionException e) {	    sPort.close();	    throw e;	}       // System.out.println("OK 3 ");	// Open the input and output streams for the connection. If they won't	// open, close the port before throwing an exception.	try {	    os = sPort.getOutputStream();	    is = sPort.getInputStream();	} catch (IOException e) {	    sPort.close();	    throw new SerialConnectionException("Error opening i/o streams");	}//System.out.println("OK 4 ");/*	// Create a new KeyHandler to respond to key strokes in the	// messageAreaOut. Add the KeyHandler as a keyListener to the	// messageAreaOut.	keyHandler = new KeyHandler(os);	messageAreaOut.addKeyListener(keyHandler);*/	// Add this object as an event listener for the serial port.	try {	    sPort.addEventListener(this);	} catch (TooManyListenersException e) {	    sPort.close();	    throw new SerialConnectionException("too many listeners added");	}//System.out.println("OK 5 ");	// Set notifyOnDataAvailable to true to allow event driven input.	sPort.notifyOnDataAvailable(true);	// Set notifyOnBreakInterrup to allow event driven break handling.	sPort.notifyOnBreakInterrupt(true);	// Set receive timeout to allow breaking out of polling loop during	// input handling.	try {	    sPort.enableReceiveTimeout(30);	} catch (UnsupportedCommOperationException e) {	}//System.out.println("OK 6 ");	// Add ownership listener to allow ownership event handling.	portId.addPortOwnershipListener(this);	open = true;    }    /**    Sets the connection parameters to the setting in the parameters object.    If set fails return the parameters object to origional settings and    throw exception.    */    public void setConnectionParameters() throws SerialConnectionException {	// Save state of parameters before trying a set.	int oldBaudRate = sPort.getBaudRate();	int oldDatabits = sPort.getDataBits();	int oldStopbits = sPort.getStopBits();	int oldParity   = sPort.getParity();	int oldFlowControl = sPort.getFlowControlMode();	// Set connection parameters, if set fails return parameters object	// to original state.	try {	    sPort.setSerialPortParams(parameters.getBaudRate(),				      parameters.getDatabits(),				      parameters.getStopbits(),				      parameters.getParity());	} catch (UnsupportedCommOperationException e) {	    parameters.setBaudRate(oldBaudRate);	    parameters.setDatabits(oldDatabits);	    parameters.setStopbits(oldStopbits);	    parameters.setParity(oldParity);	    throw new SerialConnectionException("Unsupported parameter");	}	// Set flow control.	try {	    sPort.setFlowControlMode(parameters.getFlowControlIn()			           | parameters.getFlowControlOut());	} catch (UnsupportedCommOperationException e) {	    throw new SerialConnectionException("Unsupported flow control");	}    }    /**    Close the port and clean up associated elements.    */    public void closeConnection() {	// If port is alread closed just return.	if (!open) {	    return;	}	// Remove the key listener.//	messageAreaOut.removeKeyListener(keyHandler);	// Check to make sure sPort has reference to avoid a NPE.	if (sPort != null) {	    try {		// close the i/o streams.	    	os.close();	    	is.close();	    } catch (IOException e) {		System.err.println(e);	    }	    // Close the port.	    sPort.close();	    // Remove the ownership listener.	    portId.removePortOwnershipListener(this);	}	open = false;    }    /**    Send a one second break signal.    */    public void sendBreak() {	sPort.sendBreak(1000);    }    /**    Reports the open status of the port.    @return true if port is open, false if port is closed.    */    public boolean isOpen() {	return open;    }    /**    Handles SerialPortEvents. The two types of SerialPortEvents that this    program is registered to listen for are DATA_AVAILABLE and BI. During    DATA_AVAILABLE the port buffer is read until it is drained, when no more    data is availble and 30ms has passed the method returns. When a BI    event occurs the words BREAK RECEIVED are written to the messageAreaIn.    */    public void serialEvent(SerialPortEvent e) { 	// Create a StringBuffer and int to receive input data.	StringBuffer inputBuffer = new StringBuffer();	int newData = 0;	// Determine type of event.	switch (e.getEventType()) {	    // Read data until -1 is returned. If \r is received substitute	    // \n for correct newline handling.	    case SerialPortEvent.DATA_AVAILABLE:		    while (newData != -1) {		    	try {		    	    newData = is.read();			    if (newData == -1) {				break;			    }			    if ('\r' == (char)newData) {			   	inputBuffer.append('\n');			    } else {			    	inputBuffer.append((char)newData);			    }		    	} catch (IOException ex) {		    	    System.err.println(ex);		    	    return;		      	}   		    }		// Append received data to messageAreaIn.		receptionString=receptionString+ (new String(inputBuffer));                //System.out.print("<-"+receptionString);		break;	    // If break event append BREAK RECEIVED message.	    case SerialPortEvent.BI:		receptionString=receptionString+("\n--- BREAK RECEIVED ---\n");	}    }    /**    Handles ownership events. If a PORT_OWNERSHIP_REQUESTED event is    received a dialog box is created asking the user if they are    willing to give up the port. No action is taken on other types    of ownership events.    */    public void ownershipChange(int type) {      /*	if (type == CommPortOwnershipListener.PORT_OWNERSHIP_REQUESTED) {	    PortRequestedDialog prd = new PortRequestedDialog(parent);	}        */    }    /**    A class to handle <code>KeyEvent</code>s generated by the messageAreaOut.    When a <code>KeyEvent</code> occurs the <code>char</code> that is    generated by the event is read, converted to an <code>int</code> and    writen to the <code>OutputStream</code> for the port.    */    class KeyHandler extends KeyAdapter {	OutputStream os;	/**	Creates the KeyHandler.	@param os The OutputStream for the port.	*/	public KeyHandler(OutputStream os) {	    super();	    this.os = os;	}	/**	Handles the KeyEvent.	Gets the <code>char</char> generated by the <code>KeyEvent</code>,	converts it to an <code>int</code>, writes it to the <code>	OutputStream</code> for the port.	*/        public void keyTyped(KeyEvent evt) {            char newCharacter = evt.getKeyChar();            if ((int)newCharacter==10) newCharacter = '\r';            System.out.println ((int)newCharacter);	    try {	    	os.write((int)newCharacter);	    } catch (IOException e) {		System.err.println("OutputStream write error: " + e);	    }        }    }        public void send(String message) {            byte[] theBytes= (message+"\n").getBytes();            for (int i=0; i<theBytes.length;i++){              char newCharacter = (char)theBytes[i];              if ((int)newCharacter==10) newCharacter = '\r';	      try {	    	os.write((int)newCharacter);              } catch (IOException e) {                  System.err.println("OutputStream write error: " + e);              }            }            //System.out.println (">'" +message +"' sent");        }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲黄一区二区三区| 九九九精品视频| 亚洲欧美一区二区久久| 久久久99久久精品欧美| 欧美电影免费观看高清完整版| 91精品在线一区二区| 91.com视频| 日韩欧美不卡在线观看视频| 欧美电影免费观看高清完整版在 | 久久精品一区二区三区不卡牛牛| 日韩精品一区二区三区三区免费 | 精品免费国产一区二区三区四区| 欧美一区欧美二区| 欧美电影免费观看高清完整版在线 | 中文字幕五月欧美| 最近中文字幕一区二区三区| 亚洲蜜臀av乱码久久精品蜜桃| 亚洲蜜臀av乱码久久精品| 亚洲国产欧美在线人成| 日韩精品午夜视频| 麻豆91在线看| 风间由美一区二区av101| 国产精品99久久久久久似苏梦涵| 国产成人av福利| 9l国产精品久久久久麻豆| 91成人国产精品| 欧美丰满高潮xxxx喷水动漫| 日韩免费高清电影| 日本一区二区综合亚洲| 一区二区三区在线免费| 首页国产丝袜综合| 国产精品一二三四五| 97久久超碰国产精品电影| 欧美日韩中文一区| 亚洲精品在线电影| 亚洲欧美精品午睡沙发| 日本麻豆一区二区三区视频| 国产成人日日夜夜| 欧美性感一区二区三区| 日韩免费观看高清完整版在线观看| 国产日产欧美一区二区视频| 亚洲欧美另类小说| 精品一区二区三区av| 99久久精品情趣| 91精品国模一区二区三区| 国产日韩欧美一区二区三区综合| 亚洲精品国产品国语在线app| 石原莉奈在线亚洲二区| 国产精品18久久久久久久网站| 91久久一区二区| 精品播放一区二区| 亚洲一区二区av在线| 激情欧美一区二区三区在线观看| 色一情一伦一子一伦一区| 精品国精品自拍自在线| 亚洲黄色小说网站| 国产精品18久久久久久vr| 欧美日韩一区二区电影| 日本一区二区三区电影| 日韩 欧美一区二区三区| 粉嫩绯色av一区二区在线观看| 欧美日韩国产一级二级| 国产精品污污网站在线观看| 天天综合色天天综合色h| 国产99久久久国产精品潘金 | 国产精品久久久久久久久免费樱桃| 午夜精品福利一区二区三区av| 成人夜色视频网站在线观看| 日韩一区二区在线观看视频| 亚洲激情六月丁香| 成人午夜激情影院| 日韩精品一区二区三区在线| 樱花影视一区二区| 成人午夜视频在线观看| 欧美刺激脚交jootjob| 午夜激情久久久| 色屁屁一区二区| 国产精品天美传媒沈樵| 精品一二三四区| 欧美日韩国产高清一区二区三区| ...中文天堂在线一区| 国产一区二区在线观看免费| 日韩一级大片在线| 亚洲一区在线观看免费| 91丨九色丨国产丨porny| 国产日韩欧美制服另类| 国内一区二区在线| 欧美成人在线直播| 久久国产综合精品| 91精品国产日韩91久久久久久| 亚洲观看高清完整版在线观看| 97精品久久久午夜一区二区三区| 久久精品一区二区三区不卡牛牛| 国模无码大尺度一区二区三区 | 日一区二区三区| 欧美在线免费视屏| 一区二区三区精品视频| 色综合久久88色综合天天6| 国产精品水嫩水嫩| 成人免费观看视频| 国产精品久久久爽爽爽麻豆色哟哟| 国产精品一区二区黑丝| 久久亚洲免费视频| 国产激情精品久久久第一区二区| 精品国产不卡一区二区三区| 国产在线播精品第三| 欧美精品一区二区三区一线天视频| 麻豆国产精品一区二区三区| 欧美一级片在线观看| 老司机午夜精品| 久久嫩草精品久久久久| 国产成人免费网站| 国产精品三级在线观看| bt7086福利一区国产| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | av在线这里只有精品| 中文字幕亚洲成人| 欧美无砖专区一中文字| 午夜精品久久久久久| 日韩欧美一区二区视频| 韩国av一区二区三区| 国产欧美精品一区| 91亚洲大成网污www| 一区二区三区精品在线| 欧美肥妇毛茸茸| 国产一区在线不卡| 国产精品第13页| 欧美在线播放高清精品| 日本不卡123| 久久精品男人天堂av| 91色综合久久久久婷婷| 亚洲激情图片一区| 日韩精品中午字幕| 不卡av电影在线播放| 亚洲综合无码一区二区| 日韩视频一区在线观看| 国产精品一品二品| 亚洲免费色视频| 91精品国产综合久久久蜜臀图片| 精品亚洲porn| 亚洲天堂av一区| 9191国产精品| 国产成人精品免费| 亚洲第一精品在线| 2021久久国产精品不只是精品| av在线播放不卡| 日本不卡一区二区三区| 日本一区二区视频在线观看| 欧美三区免费完整视频在线观看| 麻豆传媒一区二区三区| 亚洲欧美日韩国产中文在线| 91精品国产欧美一区二区18| 国产91丝袜在线观看| 亚洲bt欧美bt精品777| 国产日韩亚洲欧美综合| 欧美日韩一区二区三区四区 | 日韩视频国产视频| gogo大胆日本视频一区| 蜜桃视频在线一区| 中文字幕亚洲不卡| 久久综合久久鬼色中文字| 色婷婷精品久久二区二区蜜臀av | 精品一二三四区| 亚洲成人激情综合网| 国产色91在线| 91麻豆精品国产91久久久久久 | 久久精品在这里| 91精品国产aⅴ一区二区| 99riav一区二区三区| 美女视频一区二区三区| 一区二区三区色| 欧美经典一区二区三区| 欧美一区二区三区婷婷月色| 99re视频精品| 国产精品一区二区免费不卡| 日本成人中文字幕在线视频| 夜夜操天天操亚洲| 亚洲国产成人一区二区三区| 日韩一级黄色片| 欧美视频一区二区| 92国产精品观看| 国产成人午夜精品5599 | 欧美日韩国产免费| www.66久久| 国产成人精品一区二| 久久精品免费看| 丝袜诱惑亚洲看片| 亚洲国产综合色| 亚洲精品一二三| 中文字幕亚洲在| 欧美极品xxx| 久久精品欧美一区二区三区不卡| 日韩欧美在线影院| 欧美日韩色一区| 色婷婷综合视频在线观看| 972aa.com艺术欧美| 波波电影院一区二区三区| 国产精品一二三区| 国产精品资源站在线| 国产一区三区三区|