HOWTO – Debug an AOSP – CM java application

Just a little reminder for the future

Run DDMS and select the process that you want to debug (for example, com.android.calendar).

Now, in eclipse, you can attach to the emulator or device:

  1. Run > Open Debug Dialog…
  2. Right-click “Remote Java Application”, select “New”.
  3. Pick a name, i.e. “android-debug” or anything you like.
  4. Set the “Project” to your project name.
  5. Keep the Host set to “localhost”, but change Port to 8700.
  6. Click the “Debug” button and you should be all set.

Note that port 8700 is attached to whatever process is currently selected in the DDMS console, so you need to sure that DDMS has selected the process you want to debug

 

Bluetooth HC-06 + Arduino + RX1 and TX1

Yes…I’m alive.
It’s about 1 year that I didn’t post something on this wonderful blog but I’ve been quite busy.

But some days ago I bought a bluetooth module (HC-06, the cheapest module for Arduino) in order to integrate wireless capability in my HomeTemp project, and I want to share a simple thing about its configuration:

DO NOT WIRE THE MODULE TO RX1 (pin 0) AND TX1 (pin 1).

I tried the easiest way to connect the module to an Arduino UNO board, using the standard RX1 and TX1 pin, but the behavior was a little confusing:

  • The module sends correctly data via bluetooth
  • The module does not receive any data via bluetooth

I didn’t understand why…maybe a “conflict” with the standard Serial USB communication. But after some experiments  I found a post somewhere that suggests to use the “SoftwareSerial” Arduino Library and use two others PIN (10 and 11). With this simple configuration the following example works like a charm 🙂 Not all pins support change interrupts, check the SoftwareSerial page and check which pins should work.

Pair the device with your PC (the default pairing PIN is 1234) and then open a serial console (on Mac OSX I use “screen /dev/tty.XXXYYZZZ). You are now able to read and send data.

I hope it could be helpful to someone.


#include <SoftwareSerial.h>
#define LED_PIN 12

SoftwareSerial bluetoothSerial(10, 11);

void setup() {
  pinMode(LED_PIN, OUTPUT);  

  
  Serial.begin(57600);

  bluetoothSerial.begin(9600);
  bluetoothSerial.println("I'm ready");
  
  digitalWrite(LED_PIN, LOW);
  delay(300);
  digitalWrite(LED_PIN, HIGH);
  delay(300);
  digitalWrite(LED_PIN, LOW);
  delay(300);
  digitalWrite(LED_PIN, HIGH);
  delay(300);
  digitalWrite(LED_PIN, LOW);
  
  Serial.print("Ready to go");  

}

void loop() {

  if (bluetoothSerial.available() > 0) {
    char inChar = bluetoothSerial.read();
    if (inChar == '1') {
        digitalWrite(LED_PIN, HIGH);
        bluetoothSerial.print("ON");
    }
    else if (inChar == '0'){
        digitalWrite(LED_PIN, LOW);
        bluetoothSerial.print("OFF");
    }
  } 

}