当前位置: 首页>>代码示例>>Java>>正文


Java UsbSerialProber.acquire方法代码示例

本文整理汇总了Java中com.hoho.android.usbserial.driver.UsbSerialProber.acquire方法的典型用法代码示例。如果您正苦于以下问题:Java UsbSerialProber.acquire方法的具体用法?Java UsbSerialProber.acquire怎么用?Java UsbSerialProber.acquire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hoho.android.usbserial.driver.UsbSerialProber的用法示例。


在下文中一共展示了UsbSerialProber.acquire方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResume

import com.hoho.android.usbserial.driver.UsbSerialProber; //导入方法依赖的package包/类
public void onResume() {
  if (driver == null) {
    driver = UsbSerialProber.acquire(usbManager);
    //    Log.d(TAG, "Resumed, mSerialDevice=" + driver);
    if (driver == null) {
      // No serial device.
    } else {
      try {
        driver.open();
        onDeviceStateChange();
      } catch (IOException e) {
        //        Log.e(TAG, "Error setting up device: " + e.getMessage(), e);
        try {
          driver.close();
          onDeviceStateChange();
        } catch (IOException e2) {
          // Ignore.
        }
        driver = null;
        return;
      }
      // Cans has a device.
    }
  }
}
 
开发者ID:leorleor,项目名称:double-rainbow-fpv,代码行数:26,代码来源:UsbSerialTransfer.java

示例2: onResume

import com.hoho.android.usbserial.driver.UsbSerialProber; //导入方法依赖的package包/类
@Override
protected void onResume() {
    super.onResume();
    mSerialDevice = UsbSerialProber.acquire(mUsbManager);
    Log.d(TAG, "Resumed, mSerialDevice=" + mSerialDevice);
    if (mSerialDevice == null) {
        mTitleTextView.setText("No serial device.");
    } else {
        try {
            mSerialDevice.open();
        } catch (IOException e) {
            Log.e(TAG, "Error setting up device: " + e.getMessage(), e);
            mTitleTextView.setText("Error opening device: " + e.getMessage());
            try {
                mSerialDevice.close();
            } catch (IOException e2) {
                // Ignore.
            }
            mSerialDevice = null;
            return;
        }
        mTitleTextView.setText("Serial device: " + mSerialDevice);
    }
    onDeviceStateChange();
}
 
开发者ID:ThinkeryAustin,项目名称:RobotDisplay,代码行数:26,代码来源:DemoActivity.java

示例3: setupUsbDevice

import com.hoho.android.usbserial.driver.UsbSerialProber; //导入方法依赖的package包/类
private void setupUsbDevice() {
	mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
	mSerialDevice = UsbSerialProber.acquire(mUsbManager);
	if (mSerialDevice == null) {
		Toast.makeText(this, "Cannot find USB device", Toast.LENGTH_SHORT)
				.show();
	} else {
		try {
			mSerialDevice.open();
		} catch (IOException e) {
			Log.e(TAG, "Error setting up device: " + e.getMessage(), e);
			try {
				mSerialDevice.close();
			} catch (IOException e2) {
				// Ignore.
			}
			mSerialDevice = null;
			return;
		}
	}
	mSerialIoManager = new SerialInputOutputManager(mSerialDevice,
			mListener);
	mExecutor.submit(mSerialIoManager);
}
 
开发者ID:tecip-nes,项目名称:sniffer154,代码行数:25,代码来源:SnifferDeviceService.java

示例4: openDeviceFinish

import com.hoho.android.usbserial.driver.UsbSerialProber; //导入方法依赖的package包/类
public void openDeviceFinish(UsbDevice device) {
	try {
		//TODO: update code flow to remove need for use of the deprecated acquire() method
   		mSerialDevice = UsbSerialProber.acquire(mUsbManager, device);
   		
   		if (mSerialDevice != null) {
        	Log.i(TAG, "SERIAL DEVICE FOUND: " + mSerialDevice);
        	
        	mSerialDevice.open();
        	mSerialDevice.setParameters(mSettingBaud, UsbSerialDriver.DATABITS_8, UsbSerialDriver.STOPBITS_1, UsbSerialDriver.PARITY_NONE);
        		        	
        	ioManagerReset();

        	mStatus = STATUS_OPEN_STOPPED;
        	
        	deviceOpenEvent_Fire();
        	
        	return;	//this is the only successful exit path for this method
   		} else {
   			Log.w(TAG, "COULD NOT ACQUIRE SERIAL DEVICE NUMBER: " + mSettingDeviceNumber);
   		}
       } catch (Exception ex) {
           Log.e(TAG, "ERROR OPENING DEVICE", ex);
       }
	
	deviceClose();	        
       mStatus = STATUS_CLOSED_FROMERROR;
}
 
开发者ID:theksmith,项目名称:Steering-Wheel-Interface,代码行数:29,代码来源:ElmInterface.java

示例5: connect

import com.hoho.android.usbserial.driver.UsbSerialProber; //导入方法依赖的package包/类
public boolean connect() {

	manager = (UsbManager) Client.client.getSystemService(Context.USB_SERVICE);
	driver = UsbSerialProber.acquire(manager);

	if (driver != null) {
	    try {
		driver.open();
		
		driver.setParameters(USBSettings.serial_speed, 
				     UsbSerialDriver.DATABITS_8, 
				     UsbSerialDriver.STOPBITS_1, 
				     UsbSerialDriver.PARITY_NONE);
	    } catch (IOException e) {
		Toast.makeText(Client.client, "Error setting up device: " + e.getMessage(), Toast.LENGTH_SHORT).show();
		Log.e("USB", "Error setting up device: " + e.getMessage(), e);
		try {
		    driver.close();
		} catch (IOException e2) {
                      // Ignore.
		}
		driver = null;
		return false;
	    }
	    message(mainHandler, Client.STATUS_USB, new Integer(1));
	    return true;
	}
	return false;
    }
 
开发者ID:herjulf,项目名称:Read-Sensors,代码行数:30,代码来源:ConnectUSB.java


注:本文中的com.hoho.android.usbserial.driver.UsbSerialProber.acquire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。