本文整理汇总了Java中com.hoho.android.usbserial.util.SerialInputOutputManager类的典型用法代码示例。如果您正苦于以下问题:Java SerialInputOutputManager类的具体用法?Java SerialInputOutputManager怎么用?Java SerialInputOutputManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SerialInputOutputManager类属于com.hoho.android.usbserial.util包,在下文中一共展示了SerialInputOutputManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startIoManager
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
private void startIoManager(UsbSerialPort port) {
if (port != null) {
if (DEBUG) Log.i(TAG, "Starting io manager...");
mDecoder.reset();
mSerialIoManager = new SerialInputOutputManager(port, mListener);
mExecutor.submit(mSerialIoManager);
new Handler(Looper.myLooper()).postDelayed(new Runnable() {
@Override
public void run() {
int randomMessageIndex = new Random(SystemClock.elapsedRealtimeNanos())
.nextInt(WELCOME_MESSAGES.length);
Log.d(TAG, "Sending a welcome message, index: " + randomMessageIndex);
BmwIBusService.this.sendTextMessageToObc(
WELCOME_MESSAGES[randomMessageIndex]);
}
}, 3000);
}
}
示例2: setupUsbDevice
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的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);
}
示例3: sendIBusMessage
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
/**
* Sends a IBus message
*
* @return {@code true} if message sent successfully otherwise returns {@code false}.
*/
public boolean sendIBusMessage(IBusRawPacket packet) {
if (mSerialIoManager == null
|| mSerialIoManager.getState() != SerialInputOutputManager.State.RUNNING) {
if (DEBUG) Log.w(TAG, "Attempt to send ODB message when serial IO manager is not running");
return false;
}
if (DEBUG) Log.i(TAG, "Sending message to IBus: " + HexDump.toHexString(packet.toByteArray()));
mSerialIoManager.writeAsync(packet.toByteArray());
return true;
}
示例4: startIoManager
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
private void startIoManager() {
if (sPort != null) {
Log.i(TAG, "Starting io manager ..");
mSerialIoManager = new SerialInputOutputManager(sPort, mListener);
mExecutor.submit(mSerialIoManager);
}
}
示例5: startIoManager
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
private void startIoManager() {
if (sPort != null) {
MLog.i(TAG, "Starting io manager ..");
mSerialIoManager = new SerialInputOutputManager(sPort, mListener);
mExecutor.submit(mSerialIoManager);
}
}
示例6: startIoManager
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
/**
* シリアル通信を開始する.
*/
private void startIoManager() {
if (mSerialPort != null) {
if (debugFlag) {
Toast.makeText(mContext, "Starting io manager.", Toast.LENGTH_SHORT).show();
}
mSerialIoManager = new SerialInputOutputManager(mSerialPort, mListener);
mExecutor.submit(mSerialIoManager);
listener.onChangeStatus(STATUS_UART_START);
}
}
示例7: closeDevice
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
/**
* USBシリアルデバイスクローズ.
*/
private void closeDevice() {
Iterator<UsbSerialDevice> index = mUsbSerialDevices.iterator();
while (index.hasNext()) {
UsbSerialDevice device = index.next();
final UsbManager mUsbManager = (UsbManager) this.getSystemService(Context.USB_SERVICE);
UsbDeviceConnection connection = mUsbManager.openDevice(device.getSerialPort().getDriver().getDevice());
if (connection == null) {
SerialInputOutputManager manager = device.getSerialInputOutputManager();
if (manager != null) {
manager.stop();
}
device.setSerialInputOutputManager(null);
UsbSerialPort serialPort = device.getSerialPort();
if (serialPort != null) {
try {
serialPort.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
device.setSerialPort(null);
setOnlineStatus(device.getServiceId(), false, false);
index.remove();
}
}
}
示例8: startIoManager
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
/**
* シリアル通信を開始する.
*/
private void startIoManager() {
if (mSerialPort != null) {
mByteBuffer.clear();
mSerialIoManager = new SerialInputOutputManager(mSerialPort, mListener);
mExecutor.submit(mSerialIoManager);
}
}
示例9: IOProcessor
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
public IOProcessor(UsbDevice device) throws IOException{
mSendBuffer = new ArrayDeque<>();
// Tweaked rom serial library example
UsbDeviceConnection connection = mManager.openDevice(device);
mSerialPort = mDriver.getPorts().get(0);
mSerialPort.open(connection);
mSerialPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE); // Arduino default settings
mListener = new InputListener();
mSerialIoManager = new SerialInputOutputManager(mSerialPort, mListener);
mExecutor.submit(mSerialIoManager);
}
示例10: startIoManager
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
private void startIoManager() {
if (usbSerialPort != null) {
Log.i(TAG, "Starting io manager ..");
serialIoManager = new SerialInputOutputManager(usbSerialPort, serialInputListener);
executor.submit(serialIoManager);
}
}
示例11: startIoManager
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
private void startIoManager() {
if (driver != null) {
Log.i(TAG, "Starting io manager ..");
serialListener = new DeviceBridge(driver, listener);
serialManager = new SerialInputOutputManager(driver, serialListener);
mExecutor.submit(serialManager);
listener.onAttach(driver, serialListener);
}
}
示例12: startIoManager
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
private void startIoManager() {
if (mSerialDevice != null) {
Log.i(TAG, "Starting io manager ..");
mSerialIoManager = new SerialInputOutputManager(mSerialDevice, mListener);
mExecutor.submit(mSerialIoManager);
}
}
示例13: startIoManager
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
/**
* Observe serial connection
*/
private void startIoManager() {
if (driver != null) {
Log.i(TAG, "Starting io manager.");
mSerialIoManager = new SerialInputOutputManager(port, mListener);
mExecutor.submit(mSerialIoManager);
}
}
示例14: connectSmartMeter
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
/**
* スマートメーター通信接続.
* @param response response.
* @param device 接続USBシリアルデバイス.
*/
public void connectSmartMeter(final Intent response, final UsbSerialDevice device) {
/* ID、パスワードチェック */
if (mPrefUtil.getBRouteId() == null || mPrefUtil.getBRoutePass() == null) {
if (response != null) {
MessageUtils.setIllegalDeviceStateError(response, "Not found b-route ID or Password.");
sendResponse(response);
}
return;
}
UsbSerialPort serialPort = device.getSerialPort();
SerialInputOutputManager manager = device.getSerialInputOutputManager();
if (manager != null) {
manager.stop();
device.setSerialInputOutputManager(null);
}
if (mSerialPort == null) {
mSerialPort = device.getSerialPort();
} else if (!(mSerialPort.equals(serialPort))) {
try {
mSerialPort.close();
} catch (IOException e) {
e.printStackTrace();
}
mSerialPort = device.getSerialPort();
}
mByteBuffer.clear();
device.setSerialInputOutputManager(new SerialInputOutputManager(mSerialPort, mListener));
updateUsbSerialDeviceTable(device);
if (mSerialIoManager != null) {
mSerialIoManager.stop();
mSerialIoManager = null;
}
mSerialIoManager = device.getSerialInputOutputManager();
mExecutor.submit(mSerialIoManager);
// 初期コマンド送信.
mPairingResponse = response;
mPairngServiceId = device.getServiceId();
mSequenceState = 0;
ExecuteProcess(BP35C2.Command.ECHOBACK_OFF, null);
}
示例15: setDevice
import com.hoho.android.usbserial.util.SerialInputOutputManager; //导入依赖的package包/类
/**
* Set USB serial port device
* @param port serial port to be set
*/
protected void setDevice(UsbSerialPort port)
{
sPort = port;
mSerialIoManager = new SerialInputOutputManager(sPort, mListener);
}