Subscribe:

Ads 468x60px

Pages

Monday, October 17, 2011

Installing GPSIM

Hi there., nowadays I'm playing around with micro controllers. Before to get involve with MCUs physically I wanted to try it virtually. As a Linux user I Googled for a linux software to simulate my MCU programs. I found out a software GPSIM (GNU PIC Simulator). But while I'm building the GPSIM I met with a problem and googled for the solution. Unfortunately there wasn't. So I get on to work and got a solution my self.  

Basically it's required to install following dependencies before.

gputils (GNU PIC Utils)
sdcc (Small Device C Compiler)

Then it's time to build and install the GPSIM

while I'm executing the ./configure I met with a problem. first there popt.h file missing. so I have to install package included that header file. and then the biggest problem was occurred.
                     To install gpsim, it's required to be installed gtkextra-2.0 package.
I couldn't find out the gtkextra-2.0. Instead of that I have installed gtkextra-3.0

But while I configuring, terminal prompts an Error.


checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find gtkextra-2.0 package

Although there's  no problem with gtkextra package I examined the source code of the configure file. I saw that there's a code in the configure file which is shown below

$PKGCONFIG --exists gtkextra-2.0
  if test $? != 0; then
    as_fn_error $? "Cannot find gtkextra-2.0 package" "$LINENO" 5
  fi

  X_LDFLAGS=`$PKGCONFIG --libs gtk+-2.0 gthread-2.0`
  X_CFLAGS=`$PKGCONFIG --cflags gtk+-2.0`
  Y_LDFLAGS=`$PKGCONFIG --libs gtkextra-2.0`
  Y_CFLAGS=`$PKGCONFIG --cflags gtkextra-2.0`
  GTK_VERSION_T=`$PKGCONFIG --modversion gtk+-2.0`


this code always search for the older version of the gtkextra package even computer has it's latest version. So I replaced 'gtkextra-2.0' with 'gtkextra-3.0'

Note: Keep a copy of the Configure file before you edit it.
Note: You cannot edit it without root privileges. So use


                     $ sudo gedit configure

Note: Always replace your currently running gtkextra package version. It's  gtkextra-3.0 in my case. To find out version of yours

               $ pkg-config --list-all | grep gtk

Note: install any other dependencies. In my case I had missing packages libpopt-dev (for popt.h)

Then I was able to get through the configuration process painlessly. Then executed

           $ sudo make

           $ sudo make install

I thought that it's almost done. But it wasn't, an error was prompted.

~/gpsim-0.26.1$ gpsim
gpsim: error while loading shared libraries: libgtkextra-x11-3.0.so.1: cannot open shared object file: No such file or directory


Searched for the missing package 'libgtkextra-x11-3.0' library and downloaded the built packages

libgtkextra-x11-3.0-0   and libgtkextra-x11-3.0-dev


installed sequently

$ sudo dpkg -i libgtkextra-x11-3.0-0_3.0-0ubuntu3_i386.deb

$ sudo dpkg -i libgtkextra-x11-3.0-dev_3.0-0ubuntu3_i386.deb

then it works without any trouble ...  :D

Saturday, June 11, 2011

Installing mysql on Ubuntu

I wanted to install mysql on my Ubuntu os. As a biginner to Ubuntu I found that it's some what difficult thing to do. However I came across my problem after struggling two days with command terminal. I'd like to share my experiences, faults I which have faced during my installation process.
First I found out that I must install mysql-client and mysql-server. So I used (I suggest you to use the root account during this)

sudo apt-get install mysql-client mysql-server

(Note: You must be online when you are doing this)
This will install mysql for you. You just only need to follow the instructins that asked to do. But in my case this wasn't done, I was ended up with an error

Err http://archive.ubuntu.schoolnet.lk/ubuntu/maverick-updates/main mysql-server all 5.1.49-1ubuntu8.1 403 Forbidden

And so on. 


I couldn't understood the exact reason for that but I think my weak network connection might cause for that. Well.., I was not in a mind to give up this. So I went through the link which showed in the error message and I downloaded those files from the archive

(Note: http://archive.ubuntu.schoolnet.lk/ is dedicated ubuntu archive for Sri Lanka. If haven't configured your PC to the nearest ubuntu server at your location, you have to do it first)
After Downloading those missing stuffs I installed those packages using below command

 dpkg -i mysql server_5.1.49-1ubuntu8.1_all.deb
You'll have to answer some questions like password, etc
proceed with the process. After that process you have installed mysql successfully. To check whether it's working or not use:

netstat -tap | grep mysql
If it's working properly you'll see something like this

~$ netstat -tap | grep mysql
tcp        0      0 localhost.localdo:mysql *:*              LISTEN    -              

Finally to run the mysql on command terminal 

mysql -u root -h localhost -p
Then it'll ask for the password. give the password which you have given in the installation process. That's all, now you can see the command terminall turned in to a mysql console.

mysql -u root -h localhost -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 40
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>



To exit from the mysql console:

mysql> exit

Sunday, March 6, 2011

device is not ready (firmware missing)...!!

Hi there, Nowadays I'm playing around Ubuntu 10.10 because I had to do big works with command terminal which need for my 2nd semester subjects. I haven't installed Ubuntu to my laptop (Dell XPS M1210) before. But I knew I'll have to get it soon to my laptop. However I was in a doubt whether my laptop can bear two OS's because my HDD is too small comparatively to others. Whatever I decided to install Ubuntu 10.10 and no matter, it's running easily. But I saw that my wi-fi status indicator not coming to active status even I switched it into active mode. And I saw the network connections icon in top of the desktop is showing a red exclamation mark also. It's indicating "device is not ready (firmware missing)" under the wireless networks. Finally I found a solution for that after surfing some web sites. There are two solutions as I got it. If you can gain a Internet connection using other source like wired Ethernet, etc. It'll be a easy case for you. 

Here's the correct place you must follow: http://wireless.kernel.org/


Friday, February 25, 2011

How I jumped into MAD with J2ME....

Well..., After finishing the first semester of my university life I got a break to study about technological stuffs on my interest. so I'm studying about MAD these days... :D Hey..., I'm talking about Mobile Application Delveloping, however that's a kind of mad. As I got to know There's so many ways to develop mobile apps but I used J2ME with Sun Java(TM) Wireless Toolkit because java enabled moble devices are widely available in this time. First I just wanted know how to build small app for my little mobile phone (Sony Ericsson C702) as new fellow to this subject. Finally I got some knowlege by reviewing some web sites, pdf's, sample codes, etc. That's how I jumped into water. Then I wanted make a app which can be useful for someone. When I was thinking about it one of my friend gave me a hint for it. He has developed a little application containing info's (index numbers, registration numbers, etc) about students in our Batch which runs on computers. I saw a disadvantage of  that app, we cannot access those info's without a computer. That reduce the mobility of the application and the usage of it. So I thought that can be dropped out if I can implement that on mobile devices like our mobile phones. Then I did it within two days as my first app. And it was a practical solution for that problem. I'll attach my app to this and you also can try it... 

Code:


import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class Example extends MIDlet implements CommandListener, ItemStateListener {

    private static final Command CMD_EXIT = new Command("Exit", Command.EXIT, 5);
    private Display display;
    private boolean firsttime;
    private Form mainForm;
    private ChoiceGroup fullName, name, index, regNo, email;
    private Ticker ticker;
    
    /** I used this arrays to store data. In this case I have used five arrays but I think it can be done by using a 2D array also. So it's up to you   **/
  
String[] fullNameArray = {"example_1","example_2","...etc"};
    String[] nameArray = {"example_1","example_2","...etc"};
    String[] indexArray = {"example_1","example_2","...etc"};
    String[] regNoArray = {"example_1","example_2","...etc"};
    String[] emailArray = {"example_1","example_2","...etc"};

    public Example() {
        firsttime = true;
    }

    protected void startApp() {
        if (firsttime) {
            display = Display.getDisplay(this);

            mainForm = new Form("Example");
            mainForm.setTicker(getTicker());

            ChoiceGroup[] groups = {getFullNameChoiceGroup(), getNameChoiceGroup(), getRegChoiceGroup(), getIndexChoiceGroup(), getEmailChoiceGroup()};

            for (int iter = 0; iter < groups.length; iter++) {
                mainForm.append(groups[iter]);
            }

            mainForm.addCommand(CMD_EXIT);
            mainForm.setItemStateListener(this);
            mainForm.setCommandListener(this);
            firsttime = false;
        }

        display.setCurrent(mainForm);
    }

    public void commandAction(Command c, Displayable d) {
        if (d == mainForm) {
            if (c == CMD_EXIT) {
                destroyApp(false);
                notifyDestroyed();
            }
        }
    }

    protected void destroyApp(boolean unconditional) {
    }

    protected void pauseApp() {
    }

    public ChoiceGroup getFullNameChoiceGroup() {
        if (fullName == null) {
            fullName = new ChoiceGroup("Full name", ChoiceGroup.POPUP, fullNameArray, null);
        }
        return fullName;
    }

    public ChoiceGroup getNameChoiceGroup() {
        if (name == null) {
            name = new ChoiceGroup("First name", ChoiceGroup.POPUP, nameArray, null);
        }
        return name;
    }

    public ChoiceGroup getIndexChoiceGroup() {
        if (index == null) {
            index = new ChoiceGroup("Index", ChoiceGroup.POPUP, indexArray, null);
        }
        return index;
    }

    public ChoiceGroup getRegChoiceGroup() {
        if (regNo == null) {
            regNo = new ChoiceGroup("Reg No", ChoiceGroup.POPUP, regNoArray, null);
        }
        return regNo;
    }

    public ChoiceGroup getEmailChoiceGroup() {
        if (email == null) {

            email = new ChoiceGroup("E-mail", ChoiceGroup.POPUP, emailArray, null);

        }
        return email;
    }

    public void refresh(int in) {
        fullName.setSelectedIndex(in, true);
        name.setSelectedIndex(in, true);
        index.setSelectedIndex(in, true);
        regNo.setSelectedIndex(in, true);
        email.setSelectedIndex(in, true);
    }

    /** This itemStateChanged() method is a important point of this code. Because it has dropped the use of another UI command **/
    public void itemStateChanged(Item item) {
        int in = 0;
        if (item == fullName) {
            in = fullName.getSelectedIndex();
        } else if (item == name) {
            in = name.getSelectedIndex();
        } else if (item == index) {
            in = index.getSelectedIndex();
        } else if (item == regNo) {
            in = regNo.getSelectedIndex();
        } else if (item == email) {
            in = email.getSelectedIndex();
        }
        refresh(in);
    }

    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {


        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }

    }

    public Ticker getTicker() {
        if (ticker == null) {
            ticker = new Ticker("Developed by: Supun Viraj Rathnayaka  ----  E_mail: rathnaviraj@gmail.com  ----");
        }
        return ticker;
    }
}