3

AndroidからBluetooth経由でテキストを送信して、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);
   }
4

1 に答える 1

0

を に変更してみprintln()ましたwrite()か? 以下のように:

if (Serial.available() > 0) {
     val = Serial.read();
     Serial.write(val);
}
于 2015-10-14T14:48:15.627 に答える