[英]Transport end point error
我正在嘗試通過藍牙從我的android發送文本,以顯示在arduino的串行監視器中。 我有一個按鈕,當我點擊它時應該發送文本,但我不斷收到此錯誤。 誰知道問題是什么?
01-12 01:53:10.849: E/BluetoothSocket(25004): java.io.IOException: Transport endpoint is not connected
01-12 01:53:10.849: E/BluetoothSocket(25004): at android.bluetooth.BluetoothSocket.writeNative(Native Method)
01-12 01:53:10.849: E/BluetoothSocket(25004): at android.bluetooth.BluetoothSocket.write(BluetoothSocket.java:372)
01-12 01:53:10.849: E/BluetoothSocket(25004): at android.bluetooth.BluetoothOutputStream.write(BluetoothOutputStream.java:89)
01-12 01:53:10.849: E/BluetoothSocket(25004): at java.io.OutputStream.write(OutputStream.java:80)
01-12 01:53:10.849: E/BluetoothSocket(25004): at com.example.BluetoothExample.Send.stream(Send.java:120)
01-12 01:53:10.849: E/BluetoothSocket(25004): at com.example.BluetoothExample.Send$2.onClick(Send.java:57)
01-12 01:53:10.849: E/BluetoothSocket(25004): at android.view.View.performClick(View.java:2579)
01-12 01:53:10.849: E/BluetoothSocket(25004): at android.view.View$PerformClick.run(View.java:9246)
01-12 01:53:10.849: E/BluetoothSocket(25004): at android.os.Handler.handleCallback(Handler.java:587)
01-12 01:53:10.849: E/BluetoothSocket(25004): at android.os.Handler.dispatchMessage(Handler.java:92)
01-12 01:53:10.849: E/BluetoothSocket(25004): at android.os.Looper.loop(Looper.java:130)
01-12 01:53:10.849: E/BluetoothSocket(25004): at android.app.ActivityThread.main(ActivityThread.java:3735)
01-12 01:53:10.849: E/BluetoothSocket(25004): at java.lang.reflect.Method.invokeNative(Native Method)
01-12 01:53:10.849: E/BluetoothSocket(25004): at java.lang.reflect.Method.invoke(Method.java:507)
01-12 01:53:10.849: E/BluetoothSocket(25004): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
01-12 01:53:10.849: E/BluetoothSocket(25004): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:662)
01-12 01:53:10.849: E/BluetoothSocket(25004): at dalvik.system.NativeStart.main(Native Method)
我有一個非常簡單的arduino代碼。
int incomingByte;
char val;
void setup() {
pinMode(2, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
val = Serial.read();
Serial.println(val);
}
delay(100);
}
您是否嘗試將println()
更改為write()
? 如下所示:
if (Serial.available() > 0) {
val = Serial.read();
Serial.write(val);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.