2010年11月22日 星期一

ADB driver in Ubuntu

1. lsusb

at first, we need to know how your computer recognize your android device. Just type "lsusb" and all the usb devices that connect to your computer will be listed. see what you got at the output. in my case, i have a Motorola Milestone, and this is my output:

Bus 001 Device 059: ID 22b8:41db Motorola PCS

remember this and let proceed to second step...

2. sudo vim /etc/udev/rules.d/51-android.rules
and add this line:
SUBSYSTEM=="usb", SYSFS{"Motorola PCS"}=="22b8", MODE="0666"

this helps your computer to know what is this USB device, and hence recognizable

3.
sudo chmod a+rx /etc/udev/rules.d/51-android.rules
service udev restart

restart the USB device service


and your device should be listed as an ADB device by now :)



2010年9月1日 星期三

Java NIO DatagramChannel

Steps of using DatagramChannel

1.initializing DatagramChannel and bind it to specific port number, and connect it to the destination so that we can perform read and write later through this channel

DatagramChannel channel = DatagramChannel.open();
channel.socket().bind(new InetSocketAddress(9999));
channel.connect(new InetSocketAddress("wallyjue.blogspot", 80));


2. prepare the buffering space for receiving data, note that if the received packet contains more data than the Buffer can contain, the remaining data is discarded silently.
ByteBuffer buf = ByteBuffer.allocate(48);
buf.clear();

channel.receive(buf);


reference:
1. http://tutorials.jenkov.com/java-nio/index.html
2. http://onjava.com/pub/a/onjava/2002/09/04/nio.html
3. http://openjdk.java.net/projects/nio/javadoc/java/nio/channels/DatagramChannel.html