Android Intro

Android is a Linux-based operating system for mobile devices such as smartphones and tablet computers. It is developed by the Open Handset Alliance, led by Google, and other companies. Google purchased the initial developer of the software, Android Inc., in 2005.The unveiling of the Android distribution in 2007 was announced with the founding of the [...]

Posted in Linux system programming | Comments Off

Write image to AVI

Write image to AVI using OpenCV. http://answers.oreilly.com/topic/1366-how-to-write-to-an-avi-file-with-opencv/ or you can use ffmpeg.

Posted in c++ | Comments Off

Linux packaging .deb

https://wiki.ubuntu.com/PackagingGuide/Complete https://wiki.ubuntu.com/PbuilderHowto

Posted in Linux system programming | Comments Off

Compile and Install Linux Kernel

This tutorial is about kernel compiling version 2.6.xx under Debian GNU Linux. 1. Get latest linux kernel code from kernel.org $ cd /tmp $ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2 x.y.z is the version number. 2. Extract tar (.tar.bz3) file Type the following command: # tar -xjvf linux-2.6.25.tar.bz2 -C /usr/src # cd /usr/src 3. Configure kernel make sure you [...]

Posted in Linux system programming | Comments Off

static

Rules: 1. ISO C++ forbids in-class initialization of non-const static member. You have to make it static. For static var defined in .h file, you have to define it in the .cpp file class:: var. 3. Any static member function defined in .h, in .cpp file, you do not put static keyword when you implement [...]

Posted in c++ | Comments Off

Callback function in C++ class

Simply put, make the callback function static. Here is a working example, #include using std::cout; using std::endl; class Test { public: Test() {} void my_func(void (*f)()) { cout

Posted in c++ | Comments Off

How to write Linux Driver

Features of a Driver The main features of a driver are: It performs input/output (I/O) management. It provides transparent device management, avoiding low-level programming (ports). It increases I/O speed, because usually it has been optimized. It includes software and hardware error management. It allows concurrent access to the hardware by several processes. There are four [...]

Posted in Linux system programming | Comments Off

c++ pure virtual function & virtual function

If A has a pure function, derived class B must implement it, or even leave an empty implementation. Otherwise B can not instantiate an object.  Pure virtual function servers as a contract, so c++ abstract class is like java interface.   #include <iostream> using namespace std; class A { public: virtual void f()=0; }; class [...]

Posted in c++ | Comments Off

Perl Daemon

1. Manual way sub daemonize { use POSIX; POSIX::setsid or die “setsid: $!”; my $pid = fork (); if ($pid < 0) { die "fork: $!"; } elsif ($pid) { exit 0; } chdir "/"; umask 0; foreach (0 .. (POSIX::sysconf (&POSIX::_SC_OPEN_MAX) || 1024)) { POSIX::close $_ } open (STDIN, "/dev/null”); open (STDERR, “>&STDOUT”); } [...]

Posted in perl | Comments Off

c++ exception

What if you do not do the throw()? It does not work. Explain … class DeviceException : public std::exception { public: DeviceException(); ~DeviceException() throw(); //TODO stub in exception methods //TODO add ability to embed file and line number info into exception }; http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.10 http://www.daniweb.com/software-development/cpp/threads/114299/undefined-reference-to-vtable-for-

Posted in c++ | Comments Off