Wednesday, January 20, 2016

RPI2 - Dashing Dashboard Installation Tutorial


Dashboard provide a quick view of information on the system. This can be a desktop application or web based. One such example on Raspberry Pi 2 is Dashing which is based on the Sinatra Framework and Ruby.

The Sinatra Framework from http://sinatrarb.com provides web application development quickly on Ruby. Example of installation on Ruby;

$ sudo gem install sinatra


Pre Installation checklist


  1. Raspbian Jessie
  2. Ruby


Installation of Dashboard on Dashing.

Step 1: Install Dashing.

$ sudo apt-get update
$ sudo apt-get install ruby-dev
$ sudo apt-get install ruby2.1-dev
$ sudo gem install bundler


Install Dashing 1.3.4 and create a new project called my_dashboard_project.

$ sudo gem install dashing



Step 2: Create a new project space

$ dashing new my_dashboard_project
$ cd my_dashboard_project
$ ls -l
total 36
drwxr-xr-x  6 pi pi 4096 Jan 20 12:34 assets
-rw-r--r--  1 pi pi  339 Jan 20 12:34 config.ru
drwxr-xr-x  2 pi pi 4096 Jan 20 12:34 dashboards
-rw-r--r--  1 pi pi  122 Jan 20 12:34 Gemfile
drwxr-xr-x  2 pi pi 4096 Jan 20 12:34 jobs
drwxr-xr-x  2 pi pi 4096 Jan 20 12:34 lib
drwxr-xr-x  2 pi pi 4096 Jan 20 12:34 public
-rw-r--r--  1 pi pi   65 Jan 20 12:34 README.md
drwxr-xr-x 11 pi pi 4096 Jan 20 12:34 widgets


Change your directory to my_dashboard_project and bundle gems

$ bundle

Display installed gems

$ bundle show

Step 3: Start the dashing server


$ dashing start

Point web browser location at http://localhost:3030/sample


Whats next?

There are additional widgets that can be installed and new dashboards can be created. Here is an example of adding a widget from dashing.

Installing Server Status Squares widget with GIST_ID = 9588819

$ dashing stop
$ dashing install 9588819

From server status squares widget, copy the file server_status_squares.erb to the dashing dashboard directory in the project created above.

$ cp server_status_squares.erb dashboards

Point web browser location at http://localhost:3030/server_status_squares






WIP

Reference:
Dashboard on PI
Tutorial on Sinatra: Sinatra docsJust do it, Singing with Sinatra.
Dashing: Shopify,

Monday, January 18, 2016

Android Studio - Proguard Error Shows Unable to compute hash

In Android development, the standard development kit includes a tool to shrink, optimise and obfuscate the APK. This tool is known as Proguard.

Android Studio will provide the options to use Proguard if it is enabled. However, some classes or files do NOT like to be optimised and obfuscated. In particular Javascript files and reference to classes that do not exist in the path. Here is an example of how the error message may appear when building the signed APK on Linux & MS Windows.

Linux

Error:Execution failed for task ':app:packageMinirelease'.
> Unable to compute hash of /usr/development/BakersPercentage/app/build/intermediates/classes-proguard/minirelease/classes.jar

MS Windows

Error from proguard during build
Since the problem is a warning on GMS packages, I resolved on Android Studio 1.4 as follows;

Step 1: Verify project works

Open the project and make sure it can build without errors. 

Step 2: Edit build.gradle (Module: app)
Copy the existing release build type and paste as a new build release named minirelease (or any name you fancy).

buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        minirelease {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
    }


Step 3: Edit proguard-rules.pro

Add the following lines

 -keep class com.google.android.gms.** { *; }
 -dontwarn com.google.android.gms.**


Step 4: Build Signed APK

In Android Studio menu, choose Build-> Clean Project

Build-> Generate Signed APK...
Enter Key details and click Next.
In Build Type: choose minirelease.
Click Finish.


Done.

Friday, January 15, 2016

Android http audio streaming and MediaPlayer

MediaPlayer class provides a player for local files and online streaming. Its a pretty flexible class and allows syn and asyn calls to suit almost every type of needs.

Formats supported by Android is at http://developer.android.com/guide/appendix/media-formats.html

There are cases where online streams can be played on an Android emulator but not on actual Android device. This happened for Samsung Galaxy S5 with Android 5 OS.

This is what I found;


  1. There are two type of AAC streams in my list of sites. Streams using AAC-LTP AAC with SBR+PS doesnt work but AAC-LC is played satisfactorily.
  2. Audio in MP3 plays fine on emulator and actual Android device.


There are other APK that managed to play the same audio streams on That S5. Probably there is another type of mediaplayer-like class to stream audio with support of the AAC-LTP.

Conclusion if MediaPlayer stream doesnt play over HTTP
  1. Try to play the stream on VLC player and see if it works. Verification process.
  2. Seek alternative stream format if one doesnt work. Remember, only MP3 and AAC-LC works.
  3. Incorporate a decoder to manage the unsupported format. 
  4. Consider to use AudioTrack instead of MediaPlayer. This will require manual assignment of the codec and audio format.

Raspberry Pi 2 and a VGA monitor

The Raspberry Pi 2 (RPI2) model B (more details) comes with many input/output connectors and of which its display output is using HDMI type A. This HDMI is also known as Full HDMI.

Model B is the big brother of Model A+ that is much more cheaper for specific implementation in an embedded project where the most minimal use of electrical power is needed.

The RPI2 can be hooked up to a decent monitor or projector using VGA connectors. All that is needed is a HDMI to VGA adapter. This adapter may comes with additional functions like audio output, additional power source or USB. Price differences are huge but here is an example that I got from online and it works just fine with the NEC AccuSync LCD52v monitor.

HDMI to VGA cable plugged to RPI2 and female VGA.


Done.


Raspbian Command Line Basics 101

A few commands to display configurations of Raspbian on a Raspberry Pi 2.

At the Raspbian terminal, users can access a whole load of information. These can be useful for troubleshooting graphics, program conflicts and networking issues.

GENERAL


1. Display version of the Raspbian.
$ lsb_release -a

DISPLAY CONFIGURATIONS


2. Display the GPU chip version
$ vcgencmd version

3. The monitor hdmi mode
$ vcgencmd get_config hdmi_mode

4. Display current configuration
$ tvservice -s
$ tvservice -d monitor.dat
Translate monitor.dat into a readable text
$ edidparser monitor.dat > monitor.txt
cat monitor.txt 

This will display the monitor capabilities. In order to change the monitor settings, edit /boot/config.txt and determine to use CEA or DMT with the following lines

CEA uses hdmi_group=1
DMT uses hdmi_group=2

5. Is the monitor using CEA or DMT
$ vcgencmd get_config hdmi_group

6. Display supported CEA mode for the monitor
$ tvservice -m CEA

NETWORKING


7. Display all IP devices configured
$ ip a
Or just eth0 device
$ ip addr show dev eth0

Raspbian: Example output of basic commands

Friday, January 8, 2016

Howto Configure Static IP Address for Raspberry Pi 2

This is specifically for Raspbian Linux on Raspberry Pi 2 (RPI) using a wired ethernet cable.

Step 1. Connect the ethernet cable.

By default this connection is called eth0. Ensure its connected, look for the blinking lights then steady light on the RPI.

Step 2. Configure the static network information.

In this example I am using the following static IP address information:
IP address: 10.1.1.100
Gateway: 10.1.1.2
DNS: 10.1.1.3
Broadcast: 10.1.255.255

At the Panel, right click the network icon and choose "WiFi Networks (dhcpcdui) Settings".

Choose following;
Configure: interface eth0
Automatically configure empty options: checked
IP Address: 10.1.1.100
Router: 10.1.1.10
DNS Server: 10.1.1.3

Click Apply. Close the window and reboot RPI.

Done.

Test using the web browser or access the terminal and try the ping command.

Reference: RPiconfig in elinux http://elinux.org/RPiconfig