使用 android 东西访问 GPIO 树莓派 3 时出现问题

Problem access to GPIO rasbery pi 3 with android things

我想用 android 和 raspberry Pi 3 打开 LED。我按照 https://developer.android.com/things/sdk/pio/gpio 中的说明进行了操作。我正在使用最后一个 android things 版本 (1.0.15)。 有什么评论为什么我会收到这样的错误吗?

2009-01-01 03:30:07.762 667-667/com.inflashpay.inflash E/Request Permission: List of available ports: [BCM2] 2009-01-01 03:30:07.774 667-667/com.inflashpay.inflash E/Request Permission: Unable to access GPIO com.google.android.things.pio.PioException: android.os.ServiceSpecificException: BCM2 failed to apply the required pin mux: No such file or directory (code 2)

已添加:

private static final String LED = "BCM2";
private Handler mHandler = new Handler();
private Gpio mLedGpio;
    PeripheralManager service = PeripheralManager.getInstance();
    Log.i(TAG, "Available GPIO: " + service.getGpioList());
    try {

        mLedGpio = service.openGpio(LED);
        mLedGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
        Log.i(TAG, "Start blinking LED GPIO pin");
        // Post a Runnable that continuously switch the state of the GPIO, blinking the
        // corresponding LED
        mHandler.post(mBlinkRunnable);
    } catch (IOException e) {
        Log.e(TAG, "Error on PeripheralIO API", e);
    }

代码听起来不错,但问题可能出在 GPIO 名称上。

查看 Raspberry Pi

的引出线图

您可以看到 BCM2 不可用(尽管 BCM21 可用)

您可以看到另一个使用彩虹帽 on this sample 上的别针的示例。我有 运行 并验证它有效。随时将项目与您的项目进行比较或克隆 repo 并尝试该代码。

我修改了 CONFIG 文件,因为我需要使用显示器,需要在那里更改分辨率,当我将其恢复为默认时问题已解决。