Archive

Posts Tagged ‘programming’

Learn How to Write a Driver for Linux 3.x With The Linux Driver Template

November 14th, 2012 No comments

A Linux Driver Template (LDT) has been published to help new Linux kernel developers writing hardware device drivers.

Constantine Shulyupin posted the Linux Driver Template (LDT) on the Linux mailing list in order to merge it into the mainline Linux kernel. The code can be used as as a starting point for new drivers, and shows how to use several Linux facilities such as  module, platform driver, file operations (read/write, mmap, ioctl, blocking and nonblocking mode, polling), kfifo, completion, interrupt, tasklet, work, kthread, timer, simple misc device,
multiple char devices, Device Model, configfs, UART, hardware loopback, software loopback and  ftracer.

This sample has been added to other device drivers samples in eLinux.org. And if you want to learn further there’s always the Linux driver bible: “Linux Device Drivers, Third Edition” which can be downloaded for free as PDF, although it’s for 2.6.10 kernel and many parts may not be up-to date.

Via: Phoronix

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Debian is Worth a Lot (Yet it’s Free) and C/C++ Language Still Rules

February 16th, 2012 No comments

James E. Bromberger (JEB) , a contributor to Perl CPAN and Debian, has estimated the cost of developing Debian Wheezy (7.0) from scratch based on the the number of lines of code (LOC) counted with SLOCCount tool, the Constructive Cost Model (COCOMO) and the average wage of a developer of 72,533 USD (using median estimates from Salary.com and PayScale.com for 2011).

He found 419,776,604 lines of code in 31 programming languages giving an estimated cost of producing Debian Wheezy in February 2012 of 19 billion US dollar (14.4 Billion Euros), making each package source code (out of the 17,141 packages) worth an average of 1,112,547.56 USD to produce.

He also estimated the cost of Linux 3.1.8 Kernel with almost 10 millions lines of source code would be worth 540 million USD at standard complexity, or 1.877 billions USD when rated as ‘complex’.

I don’t know which tool he used for the calculation (maybe his own), but there are two simple COCOMO calculators on the internet in order to estimate the number of man hours required for a particular project based on the LOC and the code complexity:

Bromberger also estimated the cost of several individual projects used in Debian and found that developing Apache 2.2.9 would cost 33.5 million USD and MySQL 64.2 million USD with today’s salary.

Of course, there are some caveats to such cost estimation. First, those costs assume software engineers based in the US. Taking into account outsourcing would significantly reduce those cost estimations. Second, he also tried another source code analysis tool (Ohcount) which found much less lines of code in Debian Wheezy. Finally, you also need to estimate the code complexity in the COCOMO model which may lead to great variation in the final costs.

In the last section of his post, Bromberger also analyzed the 31 programming languages that were used to develop the Debian software (See his chart below). It shows C and C++ still rule the (programming) world with respectively 40% and 20% of code written in those 2 programming languages. Java comes a distant third at 8%.

C/C++ Rules the World !!!

Top 11 Programming Languages of Debian Wheezy

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Android Training & Tutorials

December 16th, 2011 No comments

The Android team just announced the launch of Android Training a collection of classes aimed at helping developers to build better Android applications.

Each class explains the steps required to solve a problem, or implement a feature, with code snippets and sample code.

They’ll add more materials over time, but right now developers can already learn (more) about the following Android Graduatetopics:

  • Designing for Multiple Screens
  • Improving Layout Performance
  • Managing Audio Playback
  • Optimizing Battery Life
  • Remembering Users
  • Sharing Content
  • Capturing Photos
  • Maintaining Multiple APKs
  • Developing for Enterprise
  • Monetizing Your App
  • Designing Effective Navigation

There are currently 34 lessons on all those topics, and most include code samples such as the News Reader  (Designing for Multiple Screens).

You can get started immediately by visiting Android Training page.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Qt Quick QML Digital Signage Demo Part 2

December 12th, 2011 4 comments

Following up on Qt Quick QML Digital Signage Demo Part 1, I’ve updated the digital signage demo to support the following:

  • Play 5 videos in a loop
  • Display 5 pictures in a loop where the picture is changed every 5 seconds
  • Use a (twitter) RSS feed for the scrolling text
Digital Signage Programmed with QtQuick/QML

QML Digital Signage Demo Screenshot

I initially planned to use QML to list the media files, but it is apparently not possible without using C/C++ and I may do it later on. So instead, I hard-coded the video and picture playlists in the QML files with the ListModel element. Videos are located in the video directory and pictures in the pic folder.

An index is needed to scroll thru the playlist, but QML does not support global variables, so I created a JavaScript file (globals.js) to store the video and picture index:

// Global variables in JavaScript file
var iVideoIndex = 0
var iPicIndex = 0

Then imported the script at the top of main.qml:

import "globals.js" as GlobalScript

Now the code to play 5 videos in a loop looks like:

Rectangle {
            id: video;
            width: 600;
            height: 432

            ListModel {
                    id: videoFiles
                     ListElement {
                             file: "video/video1.wmv"
                     }
                     ...
            }

            Video {
                id: videofile
                playing: true
                source: videoFiles.get(GlobalScript.iVideoIndex).file
                width: 600
                height: 432
                opacity: 0.9
                focus: true
                onStopped: { // To loop the video
                    source = videoFiles.get(GlobalScript.iVideoIndex).file
                    console.debug("Video: " + videoFiles.get(GlobalScript.iVideoIndex).file)
                    videofile.play()
                    GlobalScript.iVideoIndex =  (GlobalScript.iVideoIndex + 1) % 5;
                }

            }

I only used Windows Media (wmv), WebM and Mpeg video, as it seems the AVI and MP4 video I used made the emulator crash.

The picture zone uses a 5 files list (pic/pic1.jpg to pic/pic5.jpg) with a 5 second timer:

Rectangle {
            id: picture; width: 200; height: 432
            anchors.left: video.right
            ListModel {
                    id: picFiles
                     ListElement {
                             file: "pic/pic1.jpg"
                     }
                     ...
            }

            Image {
                source: picFiles.get(GlobalScript.iPicIndex).file
                Timer {
                    interval: 5000; // 5 Seconds
                    running: true;
                    repeat: true
                    onTriggered: {
                        parent.visible = false
                        parent.source = picFiles.get(GlobalScript.iPicIndex).file
                        parent.visible = true
                        console.debug("Picture: " + picFiles.get(GlobalScript.iPicIndex).file)
                        GlobalScript.iPicIndex =  (GlobalScript.iPicIndex + 1) % 5;
                    }
                }
            }

In the code above, I had to switch parent.visible between false and true or the picture would not be updated.

In the scrolling text zone, I used cnxsoft twitter feed, retrieved it, parsed it and displayed it with QML XmlListModel and ListView:

Rectangle {
            id: text
            width: 800; height: 48
            color: "blue"
            XmlListModel {
                 id: feedModel
                 source: "http://twitter.com/statuses/user_timeline/114751985.rss"
                 query: "/rss/channel/item"
                 XmlRole { name: "title"; query: "title/string()" }
            }
            ListView {
                 id: rss
                 width: 800; height: 48
                 model: feedModel
                 delegate: ScrollingText {
                     id:scrolltext
                     width: 800
                     height: 48
                     text: title // "Qt Quick Digital Signage Demo"
                 }
            }

Here’s what the Qt QML Digital Signage demo looks like when running in Qt Simulator (Nokia N900):

You can also download the source code (main.qml, ScrollingText.qml and global.js). You’ll need to create the video and pic directories in your project and add 5 videos and 5 pictures to test it.
The full QtQuick project is also available on Gitorious.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Qt Quick QML Digital Signage Demo Part 1

December 10th, 2011 No comments

I’ve recently started to play around with Qt and since I’d like to do a digital signage player running on Raspberry Pi, I’ve decided to try to make a simple digital signage demo application to evaluate the development platform.

Raspberry Pi Digital Signage

Screenshot of Digital Signage Demo Written with Qt Creator/QML

In Part 1, my goal was to make a 3 zones layout with a video zone, a picture zone and a scrolling text zone. I would just play one hard-coded media in each zone and the video and scrolling text would have to continuously loop.

I used Qt Creator to create  a “Pigital Signage” application (or should it be Πgital Signage ?).

To create the 3 zones I used the Gridview Element with 3 rectangles:

  • Video zone: 600×432
  • Picture zone: 200×432
  • Text zone: 800×48

Displaying the image is very easy with the Image Element:

Image {
    source: "pic/phone.jpg"
}

The video playback was also supposed to be easy with the Video Element but it can not work on Desktop, so I had to revert to used the Nokia N900 emulator to be able to play a short video (hence the 800×480 resolution of the demo).  It works fine but there is a transparency issue with the emulator (in my PC), so if I want to clearly see the video I have to open a black picture and move the emulator on top. Here’s the video playback code:

Video {
       id: videofile
       playing: true
       source: "video/Bear.wmv"
       width: 600
       height: 432
       opacity: 0.9
       focus: true
       onStopped: { /* To loop the video */
              videofile.play()
       }
}

The scrolling text should also have been easy since we can use  Webview  Element and html marquee, but I could not solve a problem with left and top margins that always left white border to the text zone.  Finally, I wrote the scrolling text code based on sample code provided by Kunal. I added a new file called ScrollingText.qml to the project:

import QtQuick 1.0

Item {
    id:marqueeText
    height: scrollingText.height
    clip: true
    property int tempX: marqueeText.width
    property alias text: scrollingText.text
    Text {
        x: tempX
        id:scrollingText
        color: "Yellow" /* Hard code text color for now */
        font.pixelSize: marqueeText.height - 6;
    }
    Timer {
        id:timer
        interval: 200; running: true; repeat: true
        onTriggered:{
            tempX = tempX - 5
            scrollingText.x = tempX;
            console.debug("Tempx = " + tempX + "Text Width = " + scrollingText.width, " Height = " + marqueeText.height)

            if( tempX < -scrollingText.width) {
                tempX = marqueeText.width;
                console.debug("Restart Scrolling Text")
            }
        }
    }
}

The code is modified to start scrolling the text from the right until it fully disappears on the left and continuously repeat it.

Here’s the full main.qml with the code for the 3 zones:

import QtQuick 1.0
import QtMultimediaKit 1.1
import QtWebKit 1.0

Rectangle {
    id: screen
    width: 800
    height: 480
    Grid {
        columns: 2
        spacing: 0

        Rectangle {
            id: video;
            color: "black";
            width: 600;
            height: 432
            Video {
                id: videofile
                playing: true
                source: "video/Bear.wmv"
                width: 600
                height: 432
                opacity: 0.9
                focus: true
                onStopped: { /* To loop the video */
                    videofile.play()
                }
            }
        }
        Rectangle {
            id: picture; width: 200; height: 432
            anchors.left: video.right
            Image {
                source: "pic/phone.jpg"
            }
        }
        Rectangle {
            id: text
            width: 800; height: 48
            color: "blue"
            ScrollingText {
                id:scrolltext
                width: 800
                height: 48
                text: "Qt Quick Digital Signage Demo"
            }
/* Method 2: Webview (issue with white border)
            WebView {
                    width: 800; height: 48
                    preferredWidth: 800; preferredHeight: 46
                    anchors.top: video.bottom
                    // Marquee code generated with http://www.quackit.com/html/html_generators/html_marquee_generator.cfm
                    html: "<style type=\"text/css\">
                    .html-marquee {height:48px;width:800px;background-color:3333FF;font-family:Verdana;font-size:24pt;color:FFFF33;font-weight:bold;}
                    </style>
                    <marquee class=\"html-marquee\" direction=\"left\" behavior=\"scroll\" scrollamount=\"6\" >Qt Quick Digital Signage Demo</marquee>"
             } */
        }
    }
}

In order for QtMultimediaKit to work properly, you also need to modify PigitalSignage.Pro since it is part of QtMobility:

CONFIG += mobility
MOBILITY += multimedia

Developing with Qt Creator and QML language seems relatively straightforward as this short demo could be written in one afternoon.

I’m not sure Qt 5 Video Element will be supported for the Raspberry Pi so QML Binding Element may have to be used to call an external video player that support R-Pi GPU.

In Part 2, I plan to list video and pictures file in a directory and play them continuously. For the scrolling text, the plan is to use a (twitter) RSS feed, scroll it and reload it each time the scroll is finished. I may also try to play online video (e.g. YouTube) and parse a config file to configure things like picture display duration, text color and scrolling speed etc…

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Nokia Developer Day 2: Qt QML Workshop – Chiang Mai

December 8th, 2011 No comments

I’ve just attended Nokia Developer Day  on 6-7 December 2011 in Chiang Mai.

I’ve already written a summary about the first day dealing with Series 40 Java and Web Apps Workshop.

The second day was focused on Qt/QML (Qt Meta-Language) software development for Nokia’s Symbian phones. Nokia will phase out Symbian operating system in 2016, but they’ll still support it until that time. Nokia will also port  Qt to lower end phones (e.g. Series 40) on a new operating system based on Linux called Meltemi.

Overall Business Direction & Strategy

The first 45-minutes for was presentation given by Grant Aaron McBeath, Managing Director, Nokia Thailand and Emerging Asia, about Nokia business direction: focus on Windows Phone for smartphones, Java/Web Apps for feature phones and future disruption. He also showed the progress of Nokia Ovi Store with 10 million downloads a day and 177 publishers with more than 1 million downloads. The new Nokia Lumia 710 and 800 (WP7) and Nokia Asha 300 & 303 were also showcased.

Some other interesting fact during the presentation:

  • Once operator billing is enabled, you can get 20 times more purchase than with payment requiring a credit card.
  • The best business model for app developers (at least in Thailand) is to provide freemium: try before you buy.

Finally, he talked about expected NFC growth in the next few years and different ways an application can be monetized:

  • directly: paid download, subscriptions, in-app purchases…
  • Indirectly: advertizing, sponsors…

Introduction to Qt Quick (QML) in Qt 4.7

The rest of the day 10:00 till 16:00 was devoted to Qt QML for Symbian workshop animated by Manikantan Krishnamurthy, Technical Manager, Nokia, Southeast Asia & Pacific.

The first thing to do is to download Nokia Qt SDK Windows offline (Qt_SDK_Win_offline_v1_1_3_en.exe)   and follow the installation procedure given at http://www.forum.nokia.com/Develop/Qt/Getting_started/

You can also download the Qt QML Workshop Presentation Slides.

There was first a quick introduction about Qt, Symbian and the Ovi Store. An overview of Qt Creator, Qt SDK and QML was then provided. Mani also quickly explained it was possible to use Remote Device Access to test your application on real phones remotely.

Then the worskhop started and only involved QML programming (similar to javascript in some respects). We basically followed what’s inside the slides above and learnt the following:

  • Create a new Qt project for Symbian and run the hello world application in the Emulator.
  • Create an application to display an image that can be moved to a new location by pressing the mouse button.
  • States, Transition and Timer: Updating the application above by adding code that fades-in / fades-out the image.
  • How to create an animation, list view, grid view etc… with QML
  • Introduction to Qt Quick Components for Symbian.
  • Create an application that converts degree Celsius to Kelvin with a text field, button (with image) and text showing the result. (cnxsoft: This was one of the most interesting part, as the source code was not available and we add to code ourselves and look for relevant API in Qt help, not just type the code in the PDF…).
  • Create a MAP application using QtMobility.location 1.2 API where we were able to display the map, create a map circle, pan the map and zoom in/out with a slider.
  • Create a multimedia application (Jukebox) that play/pauses and stop a MP3 file.

To conclude the workshop, mani explained how we could submit Qt applications to the Ovi Store.

This was followed by the Q&A session without any questions asked…

The day was concluded with a lucky draw for a Nokia C601 (and I was kindly explained it would not be my turn this time…), distribution of a certificate participation and a group picture.

All in all the workshop was quite interesting, but this was quite a rush (especially I was unable to copy /past the code in the PDF slides and had to type everything). But that’s fine as it gives good starting point to start developing your app. I may start playing around more with Qt once I receive my Nokia C601 and/or the Raspberry Pi becomes available.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Nokia Developer Day 1 Summary – Chiang Mai

December 6th, 2011 1 comment

I’ve just attended the first day of Nokia Developer Day (6-7 December 2011).

The focus was on software development for Nokia’s feature phones with Java or Web Apps (HTML/CSS/Javascript) and most of the time was spent on workshops to get started for developing for Nokia feature phones such as the S40 series.

Introduction to Ecosystem Business Updates

During the first 15 minutes, an “Introduction to Ecosystem Business Updates” was given by Jirapat Janjerdask, Head of the Ecosystem Developer Experience at Nokia Thailand. He gave an overview of the ecosystem for features phones including the brand, developer & publisher, mobile brand, mobile operator and consumer.

One interesting statistics was that there are 10 millions app downloads every single day. He also talked about the new Nokia Asha 300 and 303 features phones available for 3000 to 4000 Thai Baht (100 to 130 USD)  that are capable of running applications that usually run in smartphones such as Angry Bird and a Web Browser.

Development Possibilities on Nokia Platforms

After that another short 20 minutes talk was given about the “Development Possibilities on Nokia Platforms” by Nicholas Foo, Lead of Technical Services & Consultancy SEAP. He talked about the different development platforms used by Nokia:

  • Series 40 Java
  • Symbian
  • Meego
  • Qt
  • Windows Phone

Meego and Symbian operating systems will be phased out and the focus on mid to high end phones will be on Windows Phone and low end phones will use Series 40 Java, Web Apps and Qt.

Prerequisites, tools installation

The next part was the workshop showing how to use the new features of S40 Series Java and develop Web Apps.  First, you had to configure your development machine and install the relevant tools:

  1. Java tools for S40 Series Java development. Refer to Java Tools Installation Instructions.pdf for links and instructions to install Java JDK, Nokia SDK 1.0 for Java and Netbeans.
  2. Nokia Web Tools 1.5 for Web Apps development at http://www.developer.nokia.com/info/sw.nokia.com/id/e22963ec-3d9e-43f2-a220-3ef4c4092cc7/Nokia_Web_Tools.html

Most of the resources and documentation for Nokia software development can be found at http://library.developer.nokia.com.

Introduction of Series 40 Java – Touch & Type

The presentation slides and source code samples for the 2 day workshop are currently available at http://www.developer.nokia.com/Events/invitation/nddcmkk/download.

Basically, you’d use Java for games and where you need to access the phone hardware (e.g. camera) and Web Apps for applications that focuses on content as would be the case for a news application.

In that part, we’ve learnt how to use the gesture and frame animation APIs.

 The two documents for this part:

The instructions are very clear, simply follow “S40 Java slides” and it will take you to other PDF files explaining how to use the demo apps for Gesture and FrameAnim.

After the workshop, further details were given on how to sign your application to avoid too many user security confirmations among other things.

That session took an awful amount of time (about 4h30)…

Series 40 Web Apps for the next billion

In that part, we’ve learnt how Nokia Cloud-based Browser works and how to create a Google Moderator app using HTML/CSS/ javascript code and the Mobile Web Library (MWL).

The two documents for this part:

Here again, follow “S40 Web Apps slides” as the instructions are pretty clear.
Finally, we were explained how to publish Web Apps to Nokia store.

Social Media Marketing Training

The last session was a presentation focusing on marketing your product / services on social media such as Facebook, Twitter and Linkedin. It was in Thai and I pretty much lost all of my focus at that time, so I did not get much of the details…

At the end of the day, there was a lucky draw for a Nokia C601 and amazingly it seems I’m the one who got lucky…

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter