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


Java PeripheralManagerService.openUartDevice方法代码示例

本文整理汇总了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);
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:35,代码来源:UartLowpanModule.java

示例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);
    }
}
 
开发者ID:mplacona,项目名称:arduwrap,代码行数:20,代码来源:Dht22Driver.java

示例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);
}
 
开发者ID:jpuderer,项目名称:Taxi-Datalogger,代码行数:12,代码来源:HpmSensor.java

示例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;
    }

}
 
开发者ID:MacSimmy,项目名称:Sim900AndroidThings,代码行数:15,代码来源:Sim900.java

示例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);
    }
}
 
开发者ID:bregydoc,项目名称:MarsWeatherSimulator,代码行数:11,代码来源:SerialControl.java

示例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;
    }
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:18,代码来源:NmeaGpsModule.java


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