本文整理汇总了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;
}
}