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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? serialport.java

?? 發(fā)送短信 接收短信 多種接口com/net/modem 開發(fā)庫
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
// SMSLib for Java v3
// A Java API library for sending and receiving SMS via a GSM modem
// or other supported gateways.
// Web Site: http://www.smslib.org
//
// Copyright (C) 2002-2009, Thanasis Delenikas, Athens/GREECE.
// SMSLib is distributed under the terms of the Apache License version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.smslib.helper;

import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * An RS-232 serial communications port.
 * <p>
 * <b>Please note: </b>This is a wrapper around
 * <code>javax.comm.SerialPort</code> (and so <code>gnu.io.SerialPort</code>).
 * The API definition is taken from Sun. So honor them!
 * </p>
 * <code>SerialPort</code> describes the low-level interface to a serial
 * communications port made available by the underlying system.
 * <code>SerialPort</code> defines the minimum required functionality for
 * serial communications ports.
 * 
 * @author gwellisch
 */
public class SerialPort
{
	/**
	 * Wrapper for SerialPortEventListeners
	 */
	private class SerialPortEventListenerHandler implements InvocationHandler
	{
		private SerialPortEventListener realListenerObject;

		public SerialPortEventListenerHandler(SerialPortEventListener realListenerObj)
		{
			this.realListenerObject = realListenerObj;
		}

		/**
		 * It's a simple interfaces. just call the only available method with
		 * the (only) given argument
		 */
		public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
		{
			this.realListenerObject.serialEvent(new SerialPortEvent(args[0]));
			// The original interfaces is void
			return null;
		}
	}

	static private Class<?> classSerialPort;

	/** RTS/CTS flow control on input. */
	public static final int FLOWCONTROL_RTSCTS_IN;

	/** 8 data bit format. */
	public static final int DATABITS_8;

	/** Number of STOP bits - 1. */
	public static final int STOPBITS_1;

	/** No parity bit. */
	public static final int PARITY_NONE;

	/** RTS/CTS flow control on output. */
	public static final int FLOWCONTROL_RTSCTS_OUT;
	static
	{
		try
		{
			classSerialPort = Class.forName("javax.comm.SerialPort");
		}
		catch (ClassNotFoundException e1)
		{
			try
			{
				classSerialPort = Class.forName("gnu.io.SerialPort");
			}
			catch (ClassNotFoundException e2)
			{
				throw new RuntimeException("SerialPort class not found");
			}
		}
		try
		{
			// get the value of constants
			Field f;
			f = classSerialPort.getField("FLOWCONTROL_RTSCTS_IN");
			FLOWCONTROL_RTSCTS_IN = f.getInt(null);
			f = classSerialPort.getField("DATABITS_8");
			DATABITS_8 = f.getInt(null);
			f = classSerialPort.getField("STOPBITS_1");
			STOPBITS_1 = f.getInt(null);
			f = classSerialPort.getField("PARITY_NONE");
			PARITY_NONE = f.getInt(null);
			f = classSerialPort.getField("FLOWCONTROL_RTSCTS_OUT");
			FLOWCONTROL_RTSCTS_OUT = f.getInt(null);
		}
		catch (Exception e)
		{
			throw new RuntimeException(e);
		}
	}

	private Object realObject;

	protected SerialPort(Object myRealObject)
	{
		this.realObject = myRealObject;
	}

	/**
	 * Registers a SerialPortEventListener object to listen for SerialEvents.
	 * Interest in specific events may be expressed using the notifyOnXXX calls.
	 * The serialEvent method of SerialPortEventListener will be called with a
	 * SerialEvent object describing the event. The current implementation only
	 * allows one listener per SerialPort. Once a listener is registered,
	 * subsequent call attempts to addEventListener will throw a
	 * TooManyListenersException without effecting the listener already
	 * registered. All the events received by this listener are generated by one
	 * dedicated thread that belongs to the SerialPort object. After the port is
	 * closed, no more event will be generated. Another call to open() of the
	 * port's CommPortIdentifier object will return a new CommPort object, and
	 * the lsnr has to be added again to the new CommPort object to receive
	 * event from this port.
	 * 
	 * @param lsnr
	 *            The SerialPortEventListener object whose serialEvent method
	 *            will be called with a SerialEvent describing the event.
	 * @throws java.util.TooManyListenersException
	 *             (Wrapped as RuntimeException) If an initial attempt to attach
	 *             a listener succeeds, subsequent attempts will throw
	 *             TooManyListenersException without effecting the first
	 *             listener.
	 */
	public void addEventListener(final SerialPortEventListener lsnr)
	{
		try
		{
			Method method = ReflectionHelper.getMethodOnlyByName(classSerialPort, "addEventListener");
			// Determine the exact interface argument type (javax.comm.SerialPortEventListener or gnu.io.SerialPortEventListener)
			Class<?> eventI = method.getParameterTypes()[0];
			InvocationHandler handler = new SerialPortEventListenerHandler(lsnr);
			// Create proxy class on the found interface type
			Class<?> proxyClass = Proxy.getProxyClass(eventI.getClassLoader(), eventI);
			// Bind our proxy object to the original addListener
			method.invoke(this.realObject, proxyClass.getConstructor(InvocationHandler.class).newInstance(handler));
		}
		catch (InvocationTargetException e)
		{
			throw new RuntimeException(new RuntimeException(e.getTargetException().toString()));
		}
		catch (Exception e) // Catching exception isn't nice, but sufficient here.
		{
			throw new RuntimeException(e);
		}
	}

	/**
	 * Closes the communications port. The application must call
	 * <code>close</code> when it is done with the port. Notification of this
	 * ownership change will be propagated to all classes registered using
	 * <code>addPortOwnershipListener</code>.
	 */
	public void close()
	{
		try
		{
			Method method = classSerialPort.getMethod("close", (java.lang.Class[]) null);
			method.invoke(this.realObject);
		}
		catch (InvocationTargetException e)
		{
			throw new RuntimeException(new RuntimeException(e.getTargetException().toString()));
		}
		catch (Exception e)
		{
			throw new RuntimeException(e);
		}
	}

	/**
	 * Enables receive threshold, if this feature is supported by the driver.
	 * When the receive threshold condition becomes true, a read from the input
	 * stream for this port will return immediately. enableReceiveThreshold is
	 * an advisory method which the driver may not implement. By default,
	 * receive threshold is not enabled. An application can determine whether
	 * the driver supports this feature by first calling the
	 * enableReceiveThreshold method and then calling the
	 * isReceiveThresholdEnabled method. If isReceiveThresholdEnabled still
	 * returns false, then receive threshold is not supported by the driver. If
	 * the driver does not implement this feature, it will return from blocking
	 * reads at an appropriate time. See getInputStream for description of exact
	 * behaviour.
	 * 
	 * @param i
	 *            when this many bytes are in the input buffer, return
	 *            immediately from read.
	 * @throws UnsupportedCommOperationException -
	 *             (Wrapped as RuntimeException) is thrown if receive threshold
	 *             is not supported by the underlying driver.
	 */
	public void enableReceiveThreshold(int i)
	{
		try
		{
			Method method = classSerialPort.getMethod("enableReceiveThreshold", int.class);
			method.invoke(this.realObject, i);
		}
		catch (InvocationTargetException e)
		{
			throw new RuntimeException(new RuntimeException(e.getTargetException().toString()));
		}
		catch (Exception e)
		{
			throw new RuntimeException(e);
		}
	}

	/**
	 * Enables receive timeout, if this feature is supported by the driver. When
	 * the receive timeout condition becomes true, a <code>read</code> from
	 * the input stream for this port will return immediately.
	 * <p>
	 * <code>enableReceiveTimeout</code> is an advisory method which the
	 * driver may not implement. By default, receive timeout is not enabled.
	 * </p>
	 * <p>
	 * An application can determine whether the driver supports this feature by
	 * first calling the <code>enableReceiveTimeout</code> method and then
	 * calling the <code>isReceiveTimeout</code> method. If
	 * <code>isReceiveTimeout</code> still returns false, then receive timeout
	 * is not supported by the driver.
	 * </p>
	 * <p>
	 * See <code>getInputStream</code> for description of exact behaviour.
	 * </p>
	 * 
	 * @param rcvTimeout
	 *            when this many milliseconds have elapsed, return immediately
	 *            from read, regardless of bytes in input buffer.
	 */
	public void enableReceiveTimeout(int rcvTimeout)
	{
		Class<?>[] paramTypes = new Class<?>[] { int.class };
		try
		{
			Method method = classSerialPort.getMethod("enableReceiveTimeout", paramTypes);
			method.invoke(this.realObject, rcvTimeout);
		}
		catch (InvocationTargetException e)
		{
			throw new RuntimeException(new RuntimeException(e.getTargetException().toString()));
		}
		catch (Exception e)
		{
			throw new RuntimeException(e);
		}
	}

	/**
	 * Returns an input stream. This is the only way to receive data from the
	 * communications port. If the port is unidirectional and doesn't support
	 * receiving data, then <CODE>getInputStream</CODE> returns null.
	 * <P>
	 * The read behaviour of the input stream returned by
	 * <CODE>getInputStream</CODE> depends on combination of the threshold and
	 * timeout values. The possible behaviours are described in the table below:
	 * <P>
	 * <table border="1">
	 * <tr>
	 * <th colspan=2>Threshold</th>
	 * <th colspan=2>Timeout</th>
	 * <th rowspan=2>Read Buffer Size</th>
	 * <th rowspan=2>Read Behaviour</th>
	 * </tr>
	 * <tr>
	 * <th>State</th>
	 * <th>Value</th>
	 * <th>State</th>
	 * <th>Value</th>
	 * </tr>
	 * <tr>
	 * <td> disabled </td>
	 * <td> - </td>
	 * <td> disabled </td>
	 * <td> - </td>
	 * <td> n bytes </td>
	 * <td> block until any data is available </td>
	 * </tr>
	 * <tr>
	 * <td> enabled </td>
	 * <td> m bytes </td>
	 * <td> disabled </td>
	 * <td> - </td>
	 * <td> n bytes </td>
	 * <td> block until min(<I>m</I>,<I>n</I>) bytes are available </td>
	 * </tr>
	 * <tr>
	 * <td> disabled </td>
	 * <td> - </td>
	 * <td> enabled </td>
	 * <td> x ms </td>
	 * <td> n bytes </td>
	 * <td> block for <I>x</I> ms or until any data is available </td>
	 * </tr>
	 * <tr>
	 * <td> enabled </td>
	 * <td> m bytes </td>
	 * <td> enabled </td>
	 * <td> x ms </td>
	 * <td> n bytes </td>
	 * <td> block for <I>x</I> ms or until min(<I>m</I>,<I>n</I>) bytes are
	 * available </td>
	 * </tr>
	 * </table>
	 * <P>
	 * Note, however, that framing errors may cause the Timeout and Threshold
	 * values to complete prematurely without raising an exception.
	 * <P>
	 * Enabling the Timeout OR Threshold with a value a zero is a special case.
	 * This causes the underlying driver to poll for incoming data instead being
	 * event driven. Otherwise, the behaviour is identical to having both the

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线免费精品视频| 91精品在线麻豆| 一区二区三国产精华液| 欧美无砖专区一中文字| 精品无人区卡一卡二卡三乱码免费卡 | 亚洲精品欧美二区三区中文字幕| 欧美伊人久久久久久久久影院| 国内精品伊人久久久久av一坑| 亚洲激情男女视频| 久久精品视频免费观看| 欧美日韩国产电影| 99精品视频一区二区| 久久国产精品99精品国产| 一区二区三区中文字幕电影| 国产偷国产偷精品高清尤物| 欧美精选一区二区| 91丨porny丨在线| 国产精品自在欧美一区| 青椒成人免费视频| 亚洲大片免费看| 亚洲美女免费视频| 中文字幕 久热精品 视频在线| 日韩一区二区三区视频在线观看| 在线这里只有精品| 99视频精品免费视频| 国产激情视频一区二区在线观看 | 午夜精品久久久久久久蜜桃app| 欧美国产成人在线| 久久综合给合久久狠狠狠97色69| 欧美一区二区三区在线看| 在线免费观看一区| 波多野结衣亚洲| 国产精品夜夜嗨| 国产一区三区三区| 久久99精品久久久久久国产越南| 日韩黄色小视频| 人人精品人人爱| 青青草国产成人99久久| 蜜臀av性久久久久蜜臀aⅴ四虎| 亚洲大片精品永久免费| 午夜欧美视频在线观看| 香蕉加勒比综合久久| 亚洲成精国产精品女| 亚洲一区二区三区四区在线免费观看 | 蜜臀av一区二区在线免费观看| 五月婷婷色综合| 日韩精品午夜视频| 欧美bbbbb| 九色综合国产一区二区三区| 久久精品国产免费看久久精品| 日本欧美一区二区在线观看| 久久国产精品露脸对白| 久久av中文字幕片| 国产一区在线视频| 国产成人精品一区二区三区网站观看| 精品中文字幕一区二区小辣椒 | 国产成人一级电影| 国产91丝袜在线18| 91蜜桃视频在线| 欧美日韩国产免费| 91精品国产综合久久久久久久| 欧美大片一区二区| 国产女同性恋一区二区| 国产精品二区一区二区aⅴ污介绍| 亚洲欧洲精品天堂一级 | 久久老女人爱爱| 国产精品欧美精品| 亚洲一区二区在线观看视频| 免费xxxx性欧美18vr| 国产老肥熟一区二区三区| 成人国产精品免费| 在线观看一区日韩| 日韩一区二区三免费高清| 欧美激情资源网| 亚洲免费电影在线| 日本不卡视频一二三区| 国产69精品一区二区亚洲孕妇| 91捆绑美女网站| 欧美一激情一区二区三区| 欧美韩国日本一区| 亚洲.国产.中文慕字在线| 麻豆国产一区二区| 99久精品国产| 日韩一级免费观看| 亚洲欧美怡红院| 日本亚洲天堂网| 成人精品免费看| 欧美嫩在线观看| 国产欧美日产一区| 午夜精品一区在线观看| 成人综合婷婷国产精品久久免费| 91在线精品一区二区| 日韩一区二区视频| 亚洲精品国产精华液| 久久成人18免费观看| 91在线精品一区二区三区| 日韩精品自拍偷拍| 亚洲特黄一级片| 看国产成人h片视频| 色哦色哦哦色天天综合| 精品国产91乱码一区二区三区| 亚洲狠狠丁香婷婷综合久久久| 激情综合色播五月| 精品视频免费在线| 国产精品久久99| 国产精品一区二区在线播放| 欧美老人xxxx18| 亚洲欧美日韩国产手机在线 | 狠狠网亚洲精品| 欧美色涩在线第一页| 国产精品久久久久久久浪潮网站 | 亚洲欧洲综合另类| 国产成人精品免费在线| 欧美一区二区三区思思人| 一区二区三区在线看| 国产不卡免费视频| 欧美精品一区二区三| 日韩电影网1区2区| 色狠狠综合天天综合综合| 国产三级三级三级精品8ⅰ区| 奇米色一区二区| 欧美日韩一区二区三区高清| 亚洲人成网站影音先锋播放| 成人国产一区二区三区精品| 久久人人97超碰com| 久久精品国产免费| 日韩欧美一卡二卡| 麻豆国产欧美一区二区三区| 91麻豆精品国产91久久久久久久久 | 国产91精品一区二区| 精品国产91九色蝌蚪| 人禽交欧美网站| 制服丝袜av成人在线看| 午夜精品视频一区| 欧美精品少妇一区二区三区| 亚洲va国产va欧美va观看| 欧美午夜影院一区| 亚洲mv大片欧洲mv大片精品| 欧美性欧美巨大黑白大战| 艳妇臀荡乳欲伦亚洲一区| 日本高清不卡一区| 亚洲自拍偷拍综合| 欧美日韩高清一区二区不卡| 午夜精品久久久久| 91精品婷婷国产综合久久| 日韩电影一二三区| 欧美成人激情免费网| 经典一区二区三区| 国产欧美一区视频| 99re免费视频精品全部| 亚洲另类春色国产| 欧美裸体一区二区三区| 日本欧美在线观看| 久久精品夜色噜噜亚洲aⅴ| 懂色av中文字幕一区二区三区| 中文字幕第一区第二区| 91色.com| 爽好久久久欧美精品| 日韩你懂的在线观看| 国产伦精品一区二区三区免费迷 | 欧美一区国产二区| 美女脱光内衣内裤视频久久网站 | 91色婷婷久久久久合中文| 亚洲成人动漫av| 欧美一级xxx| 国产99久久久国产精品潘金网站| 亚洲蜜臀av乱码久久精品| 制服丝袜激情欧洲亚洲| 国产乱妇无码大片在线观看| 国产精品不卡一区| 欧美日韩在线播放| 激情五月激情综合网| 中文字幕在线观看不卡| 欧美视频在线观看一区| 久久福利视频一区二区| 中国色在线观看另类| 在线精品视频一区二区三四| 久久国产精品免费| 亚洲丝袜另类动漫二区| 69成人精品免费视频| 国产精品资源在线看| 亚洲乱码国产乱码精品精的特点 | 91.麻豆视频| 国产成人午夜视频| 亚洲一级电影视频| 久久九九久久九九| 在线观看免费亚洲| 国产精品18久久久久久久久久久久| 亚洲图片你懂的| 久久中文娱乐网| 欧美日韩国产免费一区二区 | 色婷婷综合久色| 蜜臀av性久久久久蜜臀aⅴ四虎| 成人免费在线观看入口| 日韩欧美国产系列| 在线观看一区二区视频| 国产精品一区二区男女羞羞无遮挡 | 亚洲三级在线免费观看| 欧美成人伊人久久综合网| 99视频在线观看一区三区|