Monthly Archives: June 2014

Canon 4770N install on Ubuntu

sudo apt-get install cups-client cups-common cups-core-drivers cups-daemon cups-filters cups-ppdc cups-server-common debconf ghostscript libavahi-client3 libavahi-common3 libc-bin libc6 libcups2 libcupscgi1 libcupsimage2 libcupsmime1 libcupsppdc1 libgcc1 libstdc++6 libusb-1.0-0 lsb-base poppler-utils procps system-config-printer-gnome libxml2:i386

/etc/cups/cupsd.conf   set require user to be none, so everyone can access it



Description: Canon MF4700 Series
Location: ubuntu
Driver: Canon MF4700 Series UFRII LT ver.2.6 (grayscale, 2-sided printing)
Connection: usb://Canon/MF4700%20Series?serial=2127K2420E48&interface=1
Defaults: job-sheets=none, none media=na_letter_8.5x11in sides=one-sided
/etc/init.d/cups restart

PCAP Sample



  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. #include <pcap/pcap.h>
  6. #include <arpa/inet.h>
  7. main()
  8. {
  9.   char errbuf[PCAP_ERRBUF_SIZE];//存放错误信息的缓冲
  10.   pcap_if_t *it;
  11.   int r;
  12.   r=pcap_findalldevs(&it,errbuf);
  13.   if(r==1)
  14.   {
  15.     printf(“err:%s\n”,errbuf);
  16.     exit(1);
  17.   }
  18.   while(it)
  19.   {
  20.     printf(“:%s\n”,it>name);
  21.     it=it>next;
  22.   }
  23. }


SDK API version table

File Project.properies control target platform , SDK and NDK both use this


level 10 API is best to use as it support mutiple platform’s CPU. and it’s the lowest API that cover 99% of market

Native Code CPU Architecture Used Compatible Android Platform(s)
ARM, ARM-NEON Android 1.5 (API Level 3) and higher
x86 Android 2.3 (API Level 9) and higher
MIPS Android 2.3 (API Level 9) and higher

Platform Version API Level VERSION_CODE Notes
Android 4.4 19 KITKAT Platform Highlights
Android 4.3 18 JELLY_BEAN_MR2 Platform Highlights
Android 4.2, 4.2.2 17 JELLY_BEAN_MR1 Platform Highlights
Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights
Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights
Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH
Android 3.2 13 HONEYCOMB_MR2
Android 3.1.x 12 HONEYCOMB_MR1 Platform Highlights
Android 3.0.x 11 HONEYCOMB Platform Highlights
Android 2.3.4
Android 2.3.3
10 GINGERBREAD_MR1 Platform Highlights
Android 2.3.2
Android 2.3.1
Android 2.3
Android 2.2.x 8 FROYO Platform Highlights
Android 2.1.x 7 ECLAIR_MR1 Platform Highlights
Android 2.0.1 6 ECLAIR_0_1
Android 2.0 5 ECLAIR
Android 1.6 4 DONUT Platform Highlights
Android 1.5 3 CUPCAKE Platform Highlights
Android 1.1 2 BASE_1_1
Android 1.0 1 BASE

Eclipse Unresolved inclusion with NDK9

Following 4 steps should resolve the eclipse error on “can not find xxxx files” when develop NDK code.

1, C/C++ Build –> Tool Chain Editor –> Change Current tool chian to Linux GCC,  keep Current builder to be Andriod Builder

2. C/C++ General: Language Mapping , set C header File to be GNU C and C++ header File to be GNU C++

3. Manually add include path under  C/C++ General —> Path and Symbols

4.  Clean –> rebuilt project,   or remove project, and re-import from existing code.



import      android.util.Log;

Log.i(“MyActivity”, “Call back been called”);


NDK :log

LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog

#include <android/log.h>

__android_log_print(ANDROID_LOG_INFO, “JNIMsg”, “Get Param: %s From Java”, c_msg);

NDK: Debut mode   ndk-build  “NDK_DEBUG = 1”

NDK8 “ndk-build clean” error fix:

A NDK GDB guide

rebuilt ubuntu NDK environment

sudo echo ‘SUBSYSTEM==”usb”, ATTR{idVendor}==”0bb4″, MODE=”0666″, GROUP=”victor”‘ > /etc/udev/rules.d/51-android.rules

sudo chmod a+ /etc/udev/rules.d/51-android.rules

sudo mkdir -p /usr/local/java
sudo cp ~/Downloads/jdk1.8.0_05/ /usr/local/java/ -fr
mv ~/Downloads/android-ndk-r9d/ ~/dev/ -fr
mv ~/Downloads/adt-bundle-linux-x86_64-20140321/ ~/dev/ -fr

sudo update-alternatives –install “/usr/bin/javaws” “javaws” “/usr/local/java/jdk1.8.0_05/bin/javaws” 1
sudo update-alternatives –set java /usr/local/java/jdk1.8.0_05/bin/java
sudo update-alternatives –set javac /usr/local/java/jdk1.8.0_05/bin/javac
sudo update-alternatives –set javaws /usr/local/java/jdk1.8.0_05/bin/javaws
sudo apt-get install ia32-libs
sudo apt-get install lib32z1  lib32ncurses5 lib32bz2-1.0

sudo apt-get install build-essential
sudo apt-get install lib32z1 lib32z1-dev
sudo apt-get install git byacc libglib2.0-dev parcellite samba subversion

sudo apt-get install git
sudo apt-get install byacc

sudo apt-get install parcellite
sudo apt-get install samba subversion
sudo  ln -s /home/victor/dev/adt-bundle-linux-x86_64-20140321/eclipse/eclipse

Interacting with Java from the Native Side

Call Java class methods

jmethodID mid = (env)->GetMethodID(cls, “callback”, “()V”);
if (mid == 0) {
return (env)->NewStringUTF(buff);
(env)->CallVoidMethod(thiz, mid);

 Make a Jclass global reference, lifetime == app life

cls = (*env)->NewGlobalRef(env, cls1);
        if (cls == 0) {
            ... /* error */      

Remember to free the reference when finish DeleteGlobalRef