本文整理匯總了Java中com.google.android.things.pio.PeripheralManagerService.openUartDevice方法的典型用法代碼示例。如果您正苦於以下問題:Java PeripheralManagerService.openUartDevice方法的具體用法?Java PeripheralManagerService.openUartDevice怎麽用?Java PeripheralManagerService.openUartDevice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.things.pio.PeripheralManagerService
的用法示例。
在下文中一共展示了PeripheralManagerService.openUartDevice方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: UartLowpanModule
import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
/**
* Create a new UartLowpanModule.
*
* @param lowpanDriverCallback @see {@link LowpanDriverCallback}
* @param uartName UART port name where the module is attached. Cannot be null.
* @param baudRate Baud rate used for the module UART.
* @param hardwareFlowControl hardware flow control setting for uart device
* {@link UartDevice#HW_FLOW_CONTROL_NONE},
* {@link UartDevice#HW_FLOW_CONTROL_AUTO_RTSCTS}
* @see UartDevice#HW_FLOW_CONTROL_NONE}
* @see UartDevice#HW_FLOW_CONTROL_AUTO_RTSCTS}
* @param handler optional {@link Handler} for UartDevice.
*/
public UartLowpanModule(@NonNull LowpanDriverCallback lowpanDriverCallback, String uartName,
int baudRate, int hardwareFlowControl,
UnexpectedCloseListener unexpectedCloseListener,
@NonNull Handler handler) throws IOException {
mLowpanDriverCallback = lowpanDriverCallback;
mUartName = uartName;
mHardwareFlowControl = hardwareFlowControl;
mHandler = handler;
mBaudRate = baudRate;
mUnexpectedCloseListener = unexpectedCloseListener;
final PeripheralManagerService manager = new PeripheralManagerService();
resetFrameState();
mDevice = manager.openUartDevice(mUartName);
mDevice.setBaudrate(mBaudRate);
mDevice.setDataSize(8);
mDevice.setHardwareFlowControl(mHardwareFlowControl);
mDevice.registerUartDeviceCallback(mUartDeviceCallback, mHandler);
}
示例2: startup
import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
@Override
public void startup() {
PeripheralManagerService mPeripheralManagerService = new PeripheralManagerService();
try {
mDevice = mPeripheralManagerService.openUartDevice(arduino.getUartDeviceName());
mDevice.setDataSize(arduino.getDataBits());
mDevice.setParity(UartDevice.PARITY_NONE);
mDevice.setStopBits(arduino.getStopBits());
mDevice.setBaudrate(arduino.getBaudRate());
} catch (IOException e){
try {
close();
} catch (Exception e1) {
e1.printStackTrace();
}
throw new IllegalStateException("Sensor can't start", e);
}
}
示例3: HpmSensor
import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
public HpmSensor(String uartName, Handler handler) throws IOException {
mHandler = handler;
// Open and setup UARTdevice
PeripheralManagerService manager = new PeripheralManagerService();
mDevice = manager.openUartDevice(uartName);
mDevice.setBaudrate(9600);
mDevice.setDataSize(8);
mDevice.setParity(UartDevice.PARITY_NONE);
mDevice.setStopBits(1);
}
示例4: init
import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
private void init(String uartName) throws IOException {
try {
PeripheralManagerService manager = new PeripheralManagerService();
mDevice = manager.openUartDevice(uartName);
mDevice.setBaudrate(Sim900Constants.BAUD_RATE);
mDevice.setDataSize(Sim900Constants.DATA_BITS);
mDevice.setParity(UartDevice.PARITY_NONE);
mDevice.setStopBits(Sim900Constants.STOP_BITS);
} catch (IOException | RuntimeException e) {
close();
throw e;
}
}
示例5: initSerial
import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
public void initSerial() {
try {
PeripheralManagerService manager = new PeripheralManagerService();
mDevice = manager.openUartDevice("UART0");
mDevice.registerUartDeviceCallback(mUartCallback);
configureUartFrame(mDevice);
} catch (IOException e) {
Log.w(TAG, "Unable to access UART device", e);
}
}
示例6: NmeaGpsModule
import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
/**
* Create a new NmeaGpsModule.
*
* @param uartName UART port name where the module is attached. Cannot be null.
* @param baudRate Baud rate used for the module UART.
* @param handler optional {@link Handler} for software polling and callback events.
*/
public NmeaGpsModule(String uartName, int baudRate, Handler handler) throws IOException {
try {
PeripheralManagerService manager = new PeripheralManagerService();
UartDevice device = manager.openUartDevice(uartName);
init(device, baudRate, handler);
} catch (IOException | RuntimeException e) {
close();
throw e;
}
}