August 13, 2012

ECL on Raspberry Pi

ECL source code won't compile without proper options.  See this page:
http://posterous.betareduction.info/building-my-own-ecl-for-and-on-the-raspberry

The page has the proper options to use to configure, and also provides the binary.  I did compile myself on Rasberry Pi, and it took VERY long time -- I had to let it run over night to finish.

Summarized Steps
$ git clone git://ecls.git.sourceforge.net/gitroot/ecls/ecl
$ ./configure --prefix=/usr/local --enable-unicode=yes "CFLAGS=-mcpu=arm1176jzf-s -DAO_USE_PTHREAD_DEFS"
$ make
$ sudo make install


August 10, 2012

Ecl For Windows



ECL (download)

I use CLisp and SBCL, but switched to ECL recently for a few reasons which I will not discuss.  It's just a personal preference.

OSX, Ubuntu, Wheezy(Raspberry Pi) all have pre-compiled packages available through mac port and apt-get, but those are older versions and have issues with quicklisp.

So I compiled Ecl source code for Windows, Ubuntu, OSX, Raspberry Pi.  They all compiled without any difficulties, except that for Windows, it's a few more steps: get VC++(Express version is fine too), run 'nmake' and run installer to package it.  For others who just want to download the binaries

I'll post Windows, and Wheezy version on my blog so people can just download it and use it.  Here is the Windows version: Download Ecl 12.7.1 For Windows, pre-compiled installer

ECL
Windows EMACS

August 9, 2012

tcpdump on OSX

http://java.dzone.com/articles/tcpdump-learning-how-read-udp

Above page shows use of tcpdump:
$ tcpdump -i lo udp port 8125 -vv -X
$ echo -n "blah:36|c" | nc -w 1 -u -4 localhost 8125

On Mac, install it using mac port (sudo port install tcpdump) and run as below:
$ sudo tcpdump -vv -X -i lo0 udp port 8125
$ echo -n "blah:36|c" | nc -w 1 -u -4 localhost 8125

August 8, 2012

Raspberry Pi: Installing OS, WebCam, Wifi module



I've ordered Raspberry Pi in March, received in June, then something came up and couldn't do much for a while.  Finally I set it up properly and ready.

I'm thinking of a project using this device with wifi and webcam -- with Javelin (product link) to control servos and interface with various sensors -- the wifi module and the webcam are verified to be working with Raspberry Pi without any problems, and external USB hub with power is not required:
I didn't want any devices that requires external HUB with power -- and I had the web cam already lying around, and I purchased the Wifi USB module for only $8.99.  I also didn't want to spend too much time on setting up the device, so did some googling to find which OS image is the easiest one to use -- and tried Arch Linux, but that didn't work for a few reasons.  Wheezy version (7/15/2012 version) worked without much effort.

For the usb wifi module, read this thread -- and get the automatic install script from here, and the driver from here.  For the webcam, it worked out of the box.  My wireless router is set to use WEP with MAC filtering, but if you use WPA, please read other tutorial to configure it.

There are other advantages of using Wheezy over Arch Linux -- I did not attach monitor keyboard to the device, but ssh to it -- Wheezy lets you resize the SD card and configure other things with simple rasp-config command.  I didn't really measure the performance, but actually, I felt that Arch Linux performance is some what better than Wheezy.  For Arch Linux, the automatic wifi script or driver did not work, and resizing SD card is not possible on the raspberry pi while the OS is running. (adding partition is possible).

Conclusion
Use Wheezy and get verified H/W -- and save time.

To Do
  • Write more about S/W and H/W on Raspberry Pi.
  • Hook up Javelin with Raspberry Pi via GPIO/Serial/TTL.
Javelin Stamp
Why am I using Javelin instead of the popular Arduino?  It's only because I purchased the Javelin stamp development kit and other parts when it first came out (2001).  The product is discontinued, but still sold and its price is much cheaper than 2001 price.  The hardware is pretty good in today's standard -- compare with Arduino Uno: see here and here.  And you can program it in Java!  The Javelin IDE runs on Windows OS -- I tested up to Vista, and read that it works on Windows 7 as well.  The IDE comes with Jike Java compiler, so Sun's (oops), Oracle's Java SDK is not necessary.

(My) Environments
  • MacBook, Snow Leopard, with Parallax+WinXP (For Javelin IDE)
  • Use USB-to-Serial device to program Javelin.  Remember to install the device driver on Mac and add that device to the VM, and install WinXP driver.  The one I have uses Prolific PL-2303 chipset -- get drivers from here.
  • For Raspberry Pi, I had the web cam already, bought the wifi module, had this power adapter with micro USB from old phone.  Since no monitor or keyboard is attached, first install the OS image on the SD, use Ethernet to connect to the router, and turn it on.  Check the router setting and get the IP (it's first configured to use dynamic IP).  Then set it up to use wifi, rasp-config, etc.  I configured it to use static IP.
Misc Tips, Resources
  • Helpful wifi related Linux commands: 
    • iwconfig, lsusb, lsmod, ifconfig, iwlist wlan0 scan
  • Install ISO image onto SD card from Mac for Raspberry Pi:
    • example:
      sudo dd bs=1m if=~/Downloads/OS_image.img of=/dev/rdisk1 (replace 'rdisk1' with your device.)
  • Back up SD image
      1. unmount) $ diskutil unmount /dev/disk1s1
      2. backup) $ dd if=/dev/rdisk1 of=/Users/kkim/Desktop/raspberry_backup.img bs=1m
      3. eject) diskutil eject /dev/rdisk1 
    • Restore SD image
      1. unmount) $ diskutil unmount /dev/disk1s1
      2. Restore) $ dd if=./raspberry_backup.img of=/dev/rdisk1 bs=1m
      3. eject) diskutil eject /dev/rdisk1
    • Javelin: manual/IDE/files, some codes, sensors.

    S/W
    For WebCam, get followings (google yourself to find out what they are and how to use them):

    • sudo apt-get install motion
    • sudo apt-get install fswebcam
    • sudo apt-get install vlc

    August 7, 2012

    How to disassemble in OSX

    Compiled simple "Hello, World" codes in ECL Lisp and GCC into binary, and wanted to compare the two in assembly.

    Just do:

    $ otool -tV "filename"
    


    August 4, 2012

    Helpful Mac port commands

    Just a note for myself...
    • port list installed
    • port search erlang
    • sudo port upgrade outdated
    • sudo port -fp uninstall installed
    • sudo port -f uninstall inactive
    • sudo port -f clean --all all
    • Configuration file: /opt/local/etc/macports/macports.conf


    Install OpenCV+Python on OSX Snow Leopard


    Environment
    OSX Snow Leopard
    X-code v4.0.2

    How-To
    The reason I failed to install it with other methods is that everyone's environment is a bit different, and some tutorials are outdated.  So check your environment against mine and if it's not what you have, then please find other tutorials.

    1. install mac port, if it's already installed clean it up (e.g. sudo port -f clean --all all)
    2. mv /usr/local /usr/local.bak (remember to change it back later)
    3. sudo port install opencv +python27 configure.compiler=clang

    (Help from: https://trac.macports.org/wiki/ProblemHotlist#compiler)

    Note

    • It's easier to experiment with Python.
    • What I'd like to try with OpenCV is to feed photos and videos to recognize faces and add meta tags to the photo, and make it more searchable.  Picasa already has that feature for photos, but not for videos.
    • Using MacBook's built-in webcam, the face detection works great.

    Other How-To's
    http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port
    http://opencv.willowgarage.com/wiki/UsingOpenCVUnderOSX
    http://opencv.willowgarage.com/wiki/InstallGuide
    http://tilomitra.com/opencv-on-mac-osx/
    http://vislab.cs.vt.edu/~vislab/wiki/index.php?title=Vision#OpenCV_2.0_universal_framework_for_Mac_.28ppc.2Fi386.29
    http://www.tsd.net.au/blog/opencv-python-bindings-macports
    http://code.google.com/p/opencv-cocoa/wiki/Building
    http://stackoverflow.com/questions/3681496/opencv-macport-python-bindings
    http://www.janeriksolem.net/2010/12/opencv-with-python-on-mac-os-x.html

    OpenCV and Python
    http://opencv.willowgarage.com/documentation/python/cookbook.html
    http://opencv.willowgarage.com/documentation/python/index.html
    http://recursive-design.com/blog/2010/12/14/face-detection-with-osx-and-python/

    August 3, 2012

    Interesting Project at Kickstarter: Oculus Rift

    Oculus


    log4j properties file to XML converter

    I had to convert log4j.properties file to log4j.xml -- and found this tool (saves time):
    http://code.google.com/p/log4j-properties-converter/

    For logback, use this tool:
    http://logback.qos.ch/translator/

    Helpful Windows commands

    I'm more familiar with Linux/Unix environment -- and I find the following Windows commands very helpful:

    "grep"

    $ netstat -a | grep 8080


    C:\> netstat -a | find -i "8080"


    Killing Process

    C:\> wmic PROCESS where "commandline like 'C:\MyConsoleApp\%run.exe%'" delete

    (See here for more about "wmic")

    List Running Services

    C:\> service where state="Running"