Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

Android processing app crashes when using usb / processing serial library (Serial.list(this)) probs

$
0
0

hi - I'm having trouble debugging why my android app is crashing when trying to use processing android serial to talk via Processing android app to arduino. i can successfully install and launch the app on android, but the app keeps crashing. I'm using really simple code just to see if I can talk via an OTG cable via serial from Android to Arduino via processing app. But when I plug in the OTG USB cable that's plugged into arduino UNO, I can choose the android app to open up that I have installed from Processing to android, but right away it says "Unfortunately, this app has stopped".

I'm wondering how to go about debugging this. Is it the wrong port (Serial.list(this)[0]) that is doing this? or something else? I'm not sure how to debug why the app's crashing. I just recently started using Processing 0251 for Android. Even just the line "println(Serial.list(this));" triggers the app to shut down.

Thanks in advance!

I used this link to help getting set up:

Processing code in Android mode:

import com.yourinventit.processing.android.serial.*;

Serial SerialPort;
boolean Toggle;

void setup()
{fullScreen();
background(255,0,0);
  println(Serial.list(this)); //this line alone makes the app crash even if i dont have any other code
  SerialPort = new Serial(this, Serial.list(this)[0], 9600);
}

void draw()
{
}

void mousePressed() {
  Toggle = !Toggle;
    // while (SerialPort.available() > 0) {
  SerialPort.write( Toggle?"1":"0");
    // }
}

Arduino Code:

    #define NUMBER_OF_CHANNELS 8
    #define PINLED1 13
    volatile char lastReceivedCharFromSerialIn = '\0';

    void setup() {
      pinMode(PINLED1, OUTPUT);
      Serial.begin(9600);
    }

    void loop() {
      digitalWrite( PINLED1, lastReceivedCharFromSerialIn == '1');
    }

    void serialEvent() {
      while (Serial.available()) {
        // get the new byte:
        lastReceivedCharFromSerialIn = (char)Serial.read();
      }
    }

Viewing all articles
Browse latest Browse all 941

Trending Articles