Samstag, 4. August 2012

[Android] Create Eclipse Project for OpenCV in Native Code

Going to come later..

Eclipse IDE for Native OpenCV development on Android

As my new internship requires me to do Android-development, I'm trying to build myself a clean Eclipse-IDE and easy-to-follow Step-by-Step instructions on how to do that, so I can fall back to this clean environment whenenver I messed up my working one. Therefore I extract all components into one Root-Directory and create a script to set needed Environment-Variables whenever changing or deploying it to a new machine.

Please note I used Eclipse Indigo, although Juno is already available, because Juno has some serious problems when combined with Android NDK, they're currently working on that.

  1. Get yourself Java JDK  from http://www.oracle.com/technetwork/java/javase/downloads/index.html. I fetched Java SE 7. Of course you have to install JDK after the download succeeded.
  2. Create a root-folder (I called it androidEclipse) and download the following items to this location:
    1. Get Eclipse for Java Develpers EE from http://www.eclipse.org/downloads/. I downloaded Indigo for Windows 64bit. Extract it somewhere on your system, but make sure you have no spaces in the absolute path to avoid possible complications with NDK and OpenCV later on.
    2. Get Native Development Kit for Android http://developer.android.com/tools/sdk/ndk/index.html (android-ndk-r8b-windows.zip in my case)
    3. Get OpenCV4Android in latest version from http://opencv.org/downloads.html (2.4.2 here) 
  3. Extract all archives and place it together in a Folder, e.g. androidEclipse
  4. Install CDT (C and C++ Development)
    1. Go to Help => Install new Software
    2. Enter the p2 repository url which could be found at http://www.eclipse.org/cdt/downloads.php. In my case it was http://download.eclipse.org/tools/cdt/releases/indigo. Select CDT Main and Optional features and install it after agreeing the terms and conditions.
      Note: Probably it doesn't work because of conflicting dependencies. In this case (when installing Indigo, never experienced that in Juno) install CDT Main Features,TCF and Uncategorized, restart Eclipse and then install CDT Optional features.
      Install new Software: CDT

    3. Restart Ecplise
    4. Test if you can create a new C or C++ project and compile a Hello-World project.
  5. Install ADT (Android Development Tools) Plugin to eclipse.
    Refer to http://developer.android.com/tools/sdk/eclipse-adt.html and install similar to CDT via Repository URL https://dl-ssl.google.com/android/eclipse/. Please keep in mind, if this repository is extraordinary slow or not working, just drop the s in https - this is also recommended from developer.android.com.
    You need to install Developer Tools and NDK Plugins, but I'm not quite sure the second one is necessary.
  6. Now we have to adjust the Environment of our IDE. We have to create two environment-variables:
    NDKROOT ... Path to root of ndk-Folder (e.g. D:\AV\androidEclipse\android-ndk-r8b)
    OPENCVROOT ... Path to root of android-openCV-Folder (e.g. D:\AV\androidEclipse\OpenCV-2.4.2-android-sdk)

    You have to restart Eclipse (best your whole System, Windows is often a bit unpredictable in these manners) in order to get it to know the new environment variables. Windows console knows them immediately, but some other applications (such as eclipse) don't.
  7. Depending on which Android platform you're developing on, you have to install further API Support. To do so, go to SDK-Manager and select the desired packages. I additionally installed API 10 SDK Platform Android 2.3.3 and the Google APIs for API 10.
  8. Good, you're done and your IDE is (or should be) ready. Please refer the next post on how to create a Project that features JNI and OpenCV - and the combination of those two.

    Click here for the next post

Mittwoch, 18. Juli 2012

[TBL][M3S] M3S-Sniffer-Hardware


We often want to have a look on the ongoing data traffic on RS485-Bus when developing and debugging new applications or when we determine faults in already running systems.

It's quite important to NOT connect an USB-RS485-Converter directly to the bus, as it has high influence through possibly connected 120R-Termination-Resistors or Pullup/Pulldown.

Therfore i soldered together a small PCB that is a Sniffer-Connector for RS485 busses with high impedance inputs. This should minimize the influence of sniffing parts and give you the ability to watch the bus as it may work without the debugging equipment.

Needed Parts:
-PCB
- Soldering stuff
- TL084P
- FTDI USB-RS485-Converter Cable
- some wires for bus connection


Following circuit is used:

Circuit of M3S-Analyzer-Snifferhardware


And this is how it looks like:

Complete device





Detail view


Probably someone experienced trouble with influencing debugging equipment on RS485 busses as well, this may solve your problem ;)



Mittwoch, 23. Mai 2012

[Dreamplug] Change DNS-Hostname

One may want to identify the Dreamplug via DNS-Hostname in the network. Per default, it always is "dreamplug", which is quite useful if ten dreamplugs are in the same net.

In my previous releases (which are based upon NewIT-Debian Squeeze Release) the hostname is easily configureable via hostname command, but the DNS-Name always remains "dreamplug".

To alter the DNS-Name, you have to edit dhclient.conf:

 nano /etc/dhcp/dhclient.conf  

At the top of the document there's the line where you have to apply changes:

 send host-name "dreamplug";  

change here to whatever your DNS-Name should be and restart networking.

 /etc/init-d/networking restart  

Done - pretty easy when you know where to look for it ;)

Mittwoch, 16. Mai 2012

[Dreamplug] DebianSqueeze_TBConfig_V0.3 GFI-Edition released

This Debian 6.0 distribution runs on sheeva.with-linux.com's 3.3.4 Kernel and comes with preinstalled
  • Apache 2 (PHP5 and MySQL+phpmyAdmin included), Document root /dev/sdb1/www (which is on external SD-Card)
  • Mono 2.10 Framework complete
  • Support for standard USB2Serial / USB2RS485 converters such as FTDI-products
  • Automount External SD /dev/sdb1 and runs init_setup_ext.sh shellscript there. If not mountable, an internal M3S-uSlave on Port 62626 is launched. For further examination send M3S-Request 'a' to Slave #10
  • Note: This is a GFI Edition only, root password set accordingly
Further I created an USB-Stick image with Ubuntu 9.04 with included setup-Script to copy the install the above described distribution on internal SD-Card. Please note you may want to activate auto-installation whenever Dreamplug is started from this stick. To do so, boot from Stick and edit /root/init_setup.sh and uncomment the GFI-line (almost at the end of the file there). This starts the gfi_setup.sh script when booting and signals finished installation with the blue LEDs.

Edit: In provided Stick-Installation the shellscript /root/gfi_setup/gfi_dp_setup_debian6.sh has to be modified; At the bottom change version number of the Image from *v0-2.tar.gz to *v0-3.tar.gz, I mistakingly forgot to apply the changes. New Image is currently being uploaded but that takes half a night with my internet connection...

Files:

Bootable Stick for Installation on internal SD

 Operation System files for internal SD

Montag, 30. April 2012

[Dreamplug] DebianSqueeze_TBConfig_V0.2 released

This Debian 6.0 configuration runs on sheeva.with-linux.com's 3.3.4 Kernel and comes with preinstalled
- Apache 2 (PHP5 and MySQL + phpMyAdmin included)
- Mono 2.10 Framework
- Support for diverse USB2Serial / USB2RS485 converters such as FTDI-Chips

Kernel Files (uploaded on my server for persistence, originally via Bashscript from www.sheeva.with-linux.com)
  • uImage (Kernel Version 3.3.4 from www.sheeva.with-Linux.com)
  • Sysconfig stuff 
OS Files
  • Debian 6.0 TBConfiguration V 0.2 (30.04.2012)

Sonntag, 29. April 2012

[Dreamplug] Getting FTDI-Converters to work

[Note]:  Equipment is Dreamplug with NewIT-2.6.?-dirty Kernel, installed Debian 6.0 (NewIT-Edition) and Mono 2.10 / Apache 2 installed.

Currently I'm desperately working on getting an FTDI-USB-to-RS485-Converter operating on my Dreamplugs (using Debian 6.0).

I found out NewIT-Dreamplug-Kernel is not supporting USB-Serial Converters, so I have to find alternatives where these modules are included or compileable.

I stumbled upon  http://sheeva.with-linux.com/, where a myriad of kernels is located.

The Author was so kind as to supply a shellscript doing all the work for you.

Just download the Script from the Website using wget and make it executable


  root@debian:~# wget http://sheeva.with-linux.com/sheeva/README-DREAM-UPDATE.sh  
  root@debian:~# chmod 777 README-DREAM-UPDATE.sh  

Afterwards you just have to execute the Shellscript and giving the desired kernel Version as a parameter

  ./README-DREAM-UPDATE.sh 3.3.4  

The update process terminates with the following lines:

 Extracting modules  
 Writing kernel to /boot  
 ****************************************************************  
  update your bootcmd to load dream-3.3.4-uImage  
  or create a link from /boot/dream-3.3.4-uImage to /boot/uImage  
 ****************************************************************  

I ignored that hints and attached my bootable Ubuntu-Stick (9.04 dreamplug version), i usually use for updates, and copied the content from /boot to the stick's /home folder after mounting.

 mount /dev/sdc2 /mnt/dp_system  
 cd dp_system/home  
 cp -r /boot ./  
 cd /  
 sync  
 umount /dev/sdc2  

Afterwards I booted from this USB-Stick (don't forget to change uBoot Environment accordingly) and copied the new uImage and sheeva-sysfile to /dev/sda1 (fat16 file system of internal SD)

See also: http://semicolon-expected.blogspot.com/2012/04/dreamplug-backup-your-system-from.html

After successful reboot from freshly updated internal SD you could run uname -a command and should see your new kernel version number.

 root@debian:~# uname -a  
 Linux debian 3.3.4 #1 PREEMPT Fri Apr 27 16:11:35 MDT 2012 armv5tel GNU/Linux  


Because this kernel comes with serial-usb-converter modules  you simply can plug in your FTDI-Chip and you should get some output like that

 root@debian:~# usb 1-1.3: new full-speed USB device number 6 using orion-ehci  
 ftdi_sio 1-1.3:1.0: FTDI USB Serial Device converter detected  
 usb 1-1.3: Detected FT232RL  
 usb 1-1.3: Number of endpoints 2  
 usb 1-1.3: Endpoint 1 MaxPacketSize 64  
 usb 1-1.3: Endpoint 2 MaxPacketSize 64  
 usb 1-1.3: Setting MaxPacketSize 64  
 usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB0  

If not, run the following command (which "enables" the ftdi_sio module manually)

 root@debian:~# modprobe ftdi_sio  
 usbcore: registered new interface driver usbserial  
 USB Serial support registered for generic  
 usbcore: registered new interface driver usbserial_generic  
 usbserial: USB Serial Driver core  
 USB Serial support registered for FTDI USB Serial Device  
 usbcore: registered new interface driver ftdi_sio  
 ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver  

You may then finally test the command and send out something (1st command) and/or read the response (second command)

 root@debian:~# echo "hello world!" > /dev/ttyUSB0  
 root@debian:~# tail -f /dev/ttyUSB0