當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。