TX 포트에서 글쓰기를 계속하기 위해 Arduino가 구성되어 있습니다. 안드로이드 Things Developer Preview 3 (내 RX/TX 케이블이 올바르게 구성되어 있고 전압은 정상입니다).Android Things 3 Rxtberry PI 3에서 rxtx를 읽을 수 없습니다.
Android Things libs의 PeripheralManagerService를 사용하여 데이터를 읽고 데이터를 쓰는 데 오랜 시간이 걸립니다.
04-11 16 : 나는 응용 프로그램을 시작할 때
는 오류가 26 : 13.665 163-163 /? (0 : 44) : name = "ttyAMA0"dev = "tmpfs"ino = 1203에 대해 avc : {읽기 쓰기}를 거부했습니다. scontext = u : r : 주변 사람 : s0 tcontext = u : object_r : 장치 : s0 tclass = chr_file 허용 = 1
04-11 16 : 26 : 13.665 163-163 /?/dev/ttyAMA0 "dev ="tmpfs "ino = 1203 scontext = u : r : 주변 사람 : s0 tcontext = u : object_r : 장치 : s0 tclass = chr_file 허용 = 1
04-11 16 : 26 : 13.665 163-163 /?/dev/ttyAMA0 "dev ="tmpfs "ino = 1203 ioctlcmd = 5401 scontext = u : r : peripheralman : s0 tcontext에 대해 I/peripheralman : type = 1400 audit (0.0 : 46) : avc : {ioctl}을 거부했습니다. = U : object_r : 장치 : S0 인 TClass = chr_file 허용 =
1 내 코드 :
public class MainActivity extends Activity {
private final int BUFFER_SIZE = 64;
private UartDevice rxtx;
public void configureUartFrame(UartDevice uart) throws IOException {
// Configure the UART port
uart.setBaudrate(9600);
}
public void writeUartData(UartDevice uart, String msg) throws IOException {
byte[] buffer = msg.getBytes();
int count = uart.write(buffer, buffer.length);
Log.d(TAG, "Wrote " + count + " bytes to peripheral");
}
public void readUartBuffer(UartDevice uart) throws IOException {
byte[] buffer = new byte[BUFFER_SIZE];
int count;
while ((count = uart.read(buffer, buffer.length)) > 0) {
Log.d(TAG, "Read " + count + " bytes from peripheral");
Log.d("Message", new String(buffer));
}
}
@Override
protected void onStart() {
super.onStart();
try {
writeUartData(rxtx, "teste");
readUartBuffer(rxtx);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PeripheralManagerService manager = new PeripheralManagerService();
manager.getUartDeviceList();
List<String> portList = manager.getUartDeviceList();
if (portList.isEmpty()) {
Log.i(TAG, "No UART port available on this device:");
} else {
Log.i(TAG, "List of RXTX available ports: - " + portList);
}
try{
rxtx = manager.openUartDevice(portList.get(0));
configureUartFrame(rxtx);
}catch (IOException e){
e.printStackTrace();
}
}}
누군가가 무엇을 할 수 알아?
몇 일 후에 결국 죽을 링크 대신 텍스트 코드 및 관련 오류를 게시 (복사 및 붙여 넣기)하면 더 많은 도움을받을 수 있습니다. 그냥 생각 : –
Ok! 나는 편집했다. thx – Stould
RPi3 헤더의 RX/TX 핀 (8/10)에 직접 연결 하시겠습니까? 아니면 USB-TTL 케이블입니까? 기본 UART를 사용하는 경우 문서별로 올바르게 모드를 구성 했습니까? https://developer.android.com/things/hardware/raspberrypi.html#configuring_the_uart_mode – Devunwired