本文整理汇总了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.
}
}
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}