Android Things UART not receiving data (RPi3)

旧街凉风 提交于 2019-12-11 04:58:42

问题


I have a Raspberry Pi 3 with Android Things running on it, and I'm trying to write an application that makes use of UART serial. I used the sample code in Android Things documentation for sending data, and it worked perfectly, but the code supposed to receive data returns empty bytes.

while ((count = uart.read(buffer, buffer.length)) > 0) {
    Log.d(TAG, "Read " + count + " bytes from peripheral");
}

There's an interrupt for when the UART buffer gets some data in, and that gets triggered calling the reading function, but reading the buffer returns nothing but zeros. In fact the loop isn't even entered at all.

I'm using a 5V FTDI Cable with a 5/3.3V Level shifter to send and receive data from the Raspberry.

How can I fix this?


回答1:


Raspberry pi 3 has some issue with uart, check these answers:

  • UART peripherals on Android Things for Raspberry Pi 3

  • Uart / GPS driver sample buffer overflow




回答2:


Use Docklight to verify UART data with the help of USB-TTL Converter. Check all the Connections like

Tx -> Rx
Rx -> Tx
GND -> GND

.

Send data from Docklight.



来源:https://stackoverflow.com/questions/41497073/android-things-uart-not-receiving-data-rpi3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!