inventit / processing-android-serial

Android Serial Library for Processing
39 stars 14 forks source link

App crashes #8

Open dattasaurabh82 opened 8 years ago

dattasaurabh82 commented 8 years ago

So it is normal that first time the app crashes as it is not able to find the usb, but then when I plug in my Arduino over USB OTG and then it asks to select the app but then it crashes.

I'm running the code on Motorola Nexus Android version: 5.1.1 processing version: 3.0.2

My Library structure:

Documents/Processing/libraries/ArduinoSerial/README.md, library.properties, library/ slf4j-android.license.txt, usb-serial-for-android.license.txt, AndroidSerial.jar, slf4j-android-1.6.1-RC1.jar, usb-serial-for-android-v010.jar

My 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(); 
  }
}

My Processing Code:

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

Serial SerialPort;
boolean Toggle;

void setup()    
{
  println(Serial.list(this));

  // this simple initialisation works only when one Serial consumer (e.g. an Arduino)
  // is connected. Serial.list provides a list with all Usb Serial devices attached
  // to this machine.
  SerialPort = new Serial(this, Serial.list(this)[0], 9600);
}

void draw()
{

}

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

Device filter location:

.. projectFolder/res/xml/device_filter.xml

device_filter.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- 0x0403 / 0x6001: FTDI FT232R UART -->
    <usb-device vendor-id="1027" product-id="24577" />

    <!-- 0x2341 / Arduino -->
    <usb-device vendor-id="9025" />

    <!-- 0x16C0 / 0x0483: Teensyduino -->
    <usb-device vendor-id="5824" product-id="1155" />

    <!-- 0x10C4 / 0xEA60: CP210x UART Bridge -->
    <usb-device vender-id="4292" product-id="60000" />

</resources>

The Manifest File:

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="">
   <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="22" />
   <application android:debuggable="true" android:icon="@drawable/icon" android:label="">
      <activity android:name=".MainActivity">
         android:theme="@android:style/Theme.NoTitleBar"&gt;
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
         </intent-filter>
         <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter" />
      </activity>
   </application>
</manifest>
dbaba commented 7 years ago

Sorry for the delay. Just released the latest library. Could you please try a zip file at the release page?