Tuesday, June 26, 2012

How to Create or Check the CRC MD5 for a File


Whenever you donwload a file you will need to test the integrity of that file you downloaded

So, you are on the INTERNET and looking for this driver that you need for your new device. Whether you are running MS Windows or Linux you will need to insure that the file you downloaded is the correct file that you are looking for. Here comes the MD5 for the rescue!

So, what is md5 any way?




How you can make use of md5 Tool?




How you can do that in MS Windows?





How about Linux, Ubuntu?

You should be able to run the command, 
md5sum    file_name
you will get something like this



Very simple process, I hope it is useful to someone out there.  You let me know.

Realtek Gigabit Ethernet Not Working with Ubuntu 11.10


New Gigabyte Motherboard Using Ubuntu 11.10 can not use Realtek Gigabyte Ethernet Correctly


Well we need to know/make sure you have the Ethernet card we are talking about.
so, type the following

lspci -nnk | grep -iA2 net

You should get something like this:

elsaghir@elsaghir-Main-Ubuntu:~$ lspci -nnk | grep -iA2 net
06:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller [10ec:8168] (rev 06)
    Subsystem: Giga-byte Technology GA-EP45-DS5 Motherboard [1458:e000]
    Kernel driver in use: r8168

So, now we need to install kernel Headers to be able to build and compile the Ethernet driver
Type:

sudo apt-get install --reinstall linux-headers-generic build-essential dkms
wget http://r8168.googlecode.com/files/r8168-8.025.00.tar.bz2
tar xvf r8168-8.025.00.tar.bz2
cd r8168-8.025.00
sudo modprobe -rf r8169
sudo ./autorun.sh
echo 'blacklist r8169' | sudo tee -a /etc/modprobe.d/blacklist.conf
sudo modprobe -v r8168
sudo depmod -a
sudo update-initramfs -u


now you need to build the driver:
Change folder to where the driver source is   cd r8168-8.026.00/
Build the Driver/Library  sudo make
We need to copy the new Library to the lib folder 
sudo cp src/r8168.ko /lib/modules/$(uname -r)/kernel/drivers/net/
Run depmod program to link all modules   sudo depmod -a
Now add the module to the kernel   sudo modprobe -v r8168 
And Update initramfs     sudo update-initramfs -u

if you have your interface in blacklist!  follow these steps:

lspci -nnk | grep -iA2 net
gksu gedit /etc/modprobe.d/blacklist.conf
# blacklist r8169



Update Dec 18, 2011:
At this point I had few update to the kernel, and I noticed every time I have a new one, I lose my network and I have to go through the build again and copy the file to the lib folder,
Of-course that make sense because every time we get a new kernel it is saved in its own folder under
/lib/modules/
so, I created a simple script that will help every time I find my network adapter not functioning correctly after a system update:

cd ~/Downloads/Drivers/r8168-8.026.00/
sudo make
sudo cp src/r8168.ko /lib/modules/$(uname -r)/kernel/drivers/net/
sudo depmod -a
sudo modprobe -v r8168
sudo update-initramfs -u

save these instructions to a file, make sure it is executable. and use it when you need to...

Let me know how these notes work for you,...





Links:
http://ubuntuforums.org/showthread.php?t=1865436

Developing GUI Programs with C/C++ in Linux "Introduction"


An introduction to GUI programming using Glade and Code::Blocks

This is an Introduction to my new book I am writing that will introduce GUI development to programmers trying to explore the Linux world and simplify the transformation for MS Visual Studio programmers that need help and direction to a similar environment in Linux world. In this knol, I will publish my first two chapters from my book trying to get more feed back and input on my topics and contents of the book. Also, This will make this knol a Tutorial for this topic. So, it is a work in progress, if you visit and do not see what you were looking for, please, come back a little later or just send me an email and I will gladly discuss your topic or add it to this Knol.


Chapter Index:

Introduction
Chapter 1
Chapter 2
Chapter 3
Chapter4
Chapter5






Introduction:

  • What resources do you need to have to use this book?
  • Why did this book come to life?
  • What do we know about GNU, Open Source?
  • What about Linux Kernel, Distributions?
  • What are the other option to develop GUI programs in Linux?




Programming in Linux is becoming more and more popular as Linux OS gets more user friendly and more regular home users are comfortable using this new Operating System. The more popular Linux Operating System gets the more demanding on adding programs and tools for end user to use. The more demand on programs the more interest in developers to start learning Linux GUI programming. I started learning about Linux about 10 years ago, and at that time it was very interesting new interface, however, it was very hard to understand and find resources to learn more about it. I struggled to learn about it on my own and installed it on an old extra computer I had just to try to keep up with this new environment. At that time I used Mandriva Linux distribution formerly Mandrake Linux. Few years later and I was shocked by how user friendly Linux became and how easy it is to switch to this OS and say good by to other operating systems that we no longer have to use it. As an embedded system programmer and very well oriented with multi programming languages and environment, I wanted to port all my tools and programs to run on Linux the new amazing Operating System so I can really say “I use Linux as my full time OS”.

This book does not teach you how to become a C or C++ programmer, it will introduce C/C++ and make a great use of them but it assumes that you know a good deal of programming concepts and infrastructure. Instead, this book will introduce the GUI programming concept and provide a step-by-step programming examples, to help programmers who are new to Linux or to GUI programming in Linux, take a big jump into GUI programming world and find the resource that will ease developing of new graphical application in Linux OS environment.





What resources do you need to work with this book?

To make a full use of this book you will need to have some resources available. First of all you need a good working computer with no Operating System “OS” to be able to install Linux on it. Or, you could have a computer with a large hard drive and create two partitions one for your original OS and one to install Linux on it. Or you could have your own way of running Linux OS on a computer. For your reference before you start, you probably should keep in mind that working with a compiler and GUI design you will need a fast enough computer with enough resources such as Memory and drive storage. You should also consider a back device like an external USB drive so you can back up your work on it just in case something happens and your computer gets damaged in anyway, even thought that there is a very small chance this could happen but you do not wont to take a chance of loosing your hard work.
Now, let us talk about what minimum resources you should have on your development computer. That is a pentium 4 with a 3GHz processor and at least 1 GB of Memory and lot of storage space. I believe that this spec is not a budget breaker and very easy to come up with. So, after you have this computer you will need to install Linux on it and that brings up a question, what distribution would I need to install? I will immediately answer saying Ubuntu. This is my favorite distribution and that one I used while working on this book. Now, keep in mind that you should download latest release available for Ubuntu. In this book I used Release 9.10 (karmic) which is the latest Ubuntu release at this time, but when you start working you always should download the latest release as there are always a lot of fixes and enhancements every time a new release is available.
Through out this book, I will be using two important GNU programs, Code::Blocks and Glade. These are the two tools you will be using to develop your programs. So, go a head and install them. Next you should know that these two programs require you to have gcc and g++ installed on your computer, the GNU C and C++ compiler and linker. Also, we are going to use the Gtk+ library to build the GUI interface when working with C programming language, and Gtkmm when working with C++ programming language. So, we need to make sure you install all these components on your Ubuntu machine.

Why did this book come to life?

As a long time C/C++ Windows programmer, I am used to find a lot of resources and references when I need help with one of my new topics that I am working on. So, when I started to work on Linux and get used to the GNU gcc and g++ programming environment I found a lot of documentation that are very useful. I also found a lot tools that we can use to develop these type of programs. But, when I started to look at GUI programming, I started to get a lot of dead ends to resources. I placed to questions on the Internet blogs and groups and I got a lot of different answers to what is considered to be the prober way to create a GUI program under Linux. I began to read a lot of documentation and blogs and had to make a decision of what I really want to do. Do I want to use an IDE that would do everything for me? Well, this is not Windows. I really should be aware of every part of my code where I can customise it and change it any time I need to. So, what I really need to do is to understand what is needed to be able to develop a GUI program using C or C++ programming language. So far so good. I continue to read more and found out that to develop a GUI program I need to know what programming language I am going to use. If I am going to use C which requires gcc tool as a compiler and a linker, then I will use Gtk+ which is the library that provides us “programmers”with all the APIs to develop this type of GUI programming. If I am going to use C++ programming language it will require g++ tool as a compiler and a linker, then I will use Gtkmm which is the Gtk+ clone but it is customised for C++ program structures.

Well, as a MS Windows long time programmer, I am really used to the idea of having an IDE, Integrated Development Environment, that will contain and manage all my project structure and configuration. So, I looked around to see what IDEs are available and compared their pros and cons. I found a lot of these IDEs like programs and each one of them had different futures and some limitations. One of the important future I was looking for is the auto-complete of keywords and commands which would really save a lot of time when you are writing a lot of code. Customisation is a nice future that can help when you work a lot with the IDE. Other futures like auto save, text formatter, built-in compile and link tools that internally link to GCC is great options too.


What do we know about GNU, Open Source?

GNU is collection of programs and operating systems that are based on the Free Software idea. GNU was first started by RichardStallman and publicly announced on September 27th , 1983. Software began on January 5th ,1984 after Stallman quit his job so his company would not claim ownership of the free GNU. The plan was to create new free software operating system and bring it to our world just like it used to be in the 1960s and 1970 where programmers were free to study the software they were using, share the software with other people, modify the software to fit their needs, and free to distribute what they modified so others can make use of it.

A lot of people get confused with the idea behind GNU free software and do not exactly understand the meaning of it. The free software term here means free in freedom, freedom to know, freedom to have access to the source code and freedom to change/update that source code to fix or add futures to it. However, this freedom is attached to a responsibility. The responsibility is simply to pass that freedom you have to the users of your applications. So, if you distributing modified programs that are based on GNU programs, then you should give users of your program access to the source code and the freedom to copy, distribute and/or modify it. You should let them know of their rights and present the GNU GPL license to them.

The name GNU was chosen for three reasons. The first reason was it is recursive acronym for “GNU's Not Unix”. So, because GNU is Unix like in design but it is free software and has no Unix code. The second reason is GNU is the real word. It is the name of “Wildebeest”. Third it is an old song , “Song of the GNU” which was a funny song about a talking gnu.

The idea of developing GNU systems is based on the “GNU Project”. The GNU project idea is to deliver free programs to the user and give them the freedom to copy, distribute, and/or modify it. However, without a free operating system, users would still have to use a proprietary software to run their computer. So the main task for the GNU project was to develop a free operating system. The operating system was chosen to be Unix compatible because the design was already proven and portable. And more important compatibility will make it easy for users to switch to the new free OS.

The major components of the GNU are GNU Compiler Collection GCC, the GNU C Library glibc, and more but, these two projects we will use a lot in this book. GCC is the main compiler that we will use to compile the programs we have in this book. There are a lot of other programs developed under GNU GPL license such as email programs, Internet browsers, text formatters, communications tools and utilities, and many other applications.

The GCC or GNU Compile Collections is one of the most important tool in the GNU project. Without the GCC the whole idea of free software would not make any since. With this tool, everyone is able to develop, modify source code and build their executable with out the need to go out and buy an expensive proprietary compiler from a third party source. Even-more, for me to publish this book with all the code I have in it, I would have had to go and find a way to make my reader have access to some type of compiler and linker such as buy a licensed right to distribute a copy of XYZ program with my book that will allow my readers to try out my code and experiment with it. But, thanks to the GNU GCC, all I have to do is point you to the Linux distribution and you have everything you need to create, copy, change and compile all the code in this book. GCC is not just C/C++ compiler and linker, it used for few other programming languages such as C sharp, Java, Ada, Fortran, Pascal, VHDL, and more other languages are supported. Also, gcc can target different processor families such as Alpha, ARM, Atmel AVR, Blackfin, HC12, PowerPC, VAX, x86-64, MIPS, and much more.

What about Linux Kernel?

A year ago, I bought a “Eee pc net-book” to be able to take all my work to any place I go. But, as soon as I powered it up and saw MS Windows XP home edition on it, I said, “Noway that is not what should be running on my net-book” so I immediately repartitioned the hard drive and installed windows XP on a small partition and Ubuntu Linux on the other partition. To be honest, there are still some programs that I might need to run under windows and did not want to force my self with no options if I had to run a windows program or hardware that is not quite supported by Linux.

Well, Linux is a free Operating System that was developed by a Finnish computer science student his name is Linus Torvalds in 1991 and was made free to people to use by 1992. Linus was a student at University of Helsinki and was getting tired of the limitations of the Minix OS, so he decided to develop his own new OS that will be much more stable and free to people to use. He never thought that it will be as popular as it is now. Linux is an open source, it provides anyone with all the source code needed to modify, update, and rebuild the whole OS, so it complies with GNU GPL.

Linux kernel is the operating system that everything else run on top of. Linux kernel is release under the GNU GPL license version 2 plus some proprietary licenses. Most of the Linux kernel has full access to the hardware and has futures to handle interrupts correctly. Also, it improves the support for symmetric multiprocessing (SMP) and preemption which improves latency, and increases responsiveness which simply makes it suitable for real time operating system. When we hear the phrase “Linux distribution” that is not the Linux kernel. Linux distributions are a group of applications tools and utilities that run on top of the Linux Kernel. Such applications are word processors, email program, Internet browser, media players, graphics programs, and communications programs. There are currently over six hundred distributions available and about three hundred of them are in active development. Each distribution was created by a person or group of users. Slackware was created by Patrick Volkerding and then maintained by the Development team. On the other hand, OpenSUSE was created by Novell and started as a business only distribution then changed to focus on the home user desktops and workstations. Below is a list of most popular Linux distributions that I can think of:

Distribution
Creator
Producer
First Public Release
Base Distribution
Latest Release Date
Purpose
UbuntuCanonical Ltd.Canonical Ltd.10/20/04Debian10/29/09General
MandrivaMandrake soft S.A.Mandriva S.A.07/23/98Red Hat Linux04/29/09General
OpenSUSENovell Inc.OpenSUSE Project03/00/1994SUSE Linux11/12/09General
DebianIan MurdockDebian Project08/16/93None09/05/09General
FedoraFedora ProjectFedora Project11/05/03Red Hat Linux11/17/09General
SlackwarePatrick VolkerdingDev Team07/16/93SLS08/26/09General
Gentoo LinuxDaniel RobbinsGentoo Foundation, Inc.03/31/02NoneWeeklyGeneral
Dam Small LinuxJohn AndrewsDev Team2003Knoppix11/17/08Portable
YoperAndreas GiradetThe Yoper Team03/05/03None10/03/07General

Ubuntu:
Ubuntu is free GNU Linux distribution. It started by Mark Shuttleworth and then sponsored by Canonical Ltd. It is the most popular distribution available as it focuses on the ease of use, hardware support and availability of most Linux program packages. Ubuntu is driven from Debian distribution and it is different in the way it has a regular releases every 6 months with long time support (LTS) releases every one and a half years. Also, you can run it off the live-CD with having to install it but when you decide to install it, it is a breath. You can start using it right after the install because it installs most common desktop components. Finally, it has a very strong on-line community for references and support.

Debian:
Debian is also a free GNU Linux Distribution. Is very stable, mature and known to have an outstanding package management. It requires some knowledge to Linux though and is very slow on updates and changes. It is very well maintained and supported by the vast popularity and multilingual community. It is very easy to get help from the Debian related forums and mailing lists.

Slackware:
Slackware is the oldest Distribution to come to life. It was started by Patrick Volkerding on July 13th, 1993 and then maintained by the development team. This distribution is designed for users who like to have control and are not afraid of the command line. One of the disadvantages in this distribution is that the the package system does not have list of dependencies which forces the user to install all package dependencies manually.


Fedora:
Fedora is designed to work with home users, programmers, and corporate servers. In this way it will need some customisations to fit the need of each group of users. Fedora has a great desktop tools and management. It is well known of its new tools and bleeding edge technologies. These advantages bring with some disadvantage which is the instability. So, if you want to use the new futures in Fedora, you will need to realise the consequences.


OpenSUSE:
OpenSUSE one of the top distribution for quite a while as it first appeared around 1992 as S.U.S.E. As a business only distribution and now focuses on home users desktop and workstations. OpenSUSE is managed by Novell, and aims to be the most usable and user friendly desktop Linux distribution. Is is very well known by its great configuration tool, YAST. It has a very well designed control center for administration. Users like it because it is one of the simplest distribution to install and configure. It offers a great support and documentation.

Mandriva:
Mandriva is originally was released to public with the name Mandrake Linux. It became very popular among users who want to switch from MS Windows because of its ease and similarity in desktop layout. Mandriva always up-to-date in tools and software which makes it sometimes unstable.

Gentoo Linux:
Gentoo is really known to be all about customisations. This distribution lets you have the option to customise every and each components of the system. It also has a different type of installation process. It will ask you to choose your kernel, cron and event-logging program. The installation is not click-able and will take a long time and knowledge. If you do not like to read and research then you better choose different distribution with a graphical install.

Dam Small Linux:
dam Small Linux, DSL, is meant to be the smallest Linux distribution ever. You could carry a small basic copy of it with you and boot it from a floppy disk, not that we have these available on most computers any more. But if you have an old computer and wanted to use it for a certain purpose with a small and light Linux distribution, your first choice would be DSL. The ISO is just 50Mb, so you can fit it on a business CD. The real future of DSL that you can boot it directly within other operating system such as MS Windows. So you can take it with you and use it on other computers when you are not home. DSL is based on knoppix which is based on Debian. That makes it have a stable system and good with hardware recognition.

Yoper:
Yoper is know to be the most fastest operating system on earth. It is has something in it that makes it fast and responsive out of the box. Yoper also has a very fast installation, you can install this distribution in about 5 to 10 minutes. The problem with Yoper is that it does not have a lot of configurations. The other problem is Yoper team is very small and lacks manpower. The latest release was in July 2007.


What are the other options to develop GUI programs in Linux?

You can basically write C/C++ programs in Linux using an edit program like gedit in Ubuntu and the GNU gcc, Gtk+, and Gtkmm. However, this is not very convenient when you working on a big project that contains a lot of GUI interfaces and multiple source code files. The idea of using an IDE manager is to mange you file structures and contain everything in one container. Also, all your project settings are stored and managed within a configuration window that is simple to understand and change. Even though, some IDE programs would be so complicated that make finding items and settings very hard and confusing. I find Code::Blocks very simple and complete IDE that you can use now for simple projects and later for advanced projects. Code::Blocks has a simple project manager and still very efficient. The compile and link options are easy to find and configure. Code completion is very helpful. Other programs could be very similar but I found Code::Block easier to adapt after working all these years with MS Visual Studio. Other IDE programs are Anjuta, Qt Creator, Kdevelop, Eclipse, Netbeans.



Web Link:
For more information on GNU visit Wikipedia web site http://en.wikipedia.org/wiki/GNU
GNU General Public License GPL http://www.gnu.org/licenses/gpl.html
Mandriva Linux on Wikipedia http://en.wikipedia.org/wiki/Mandriva_Linux
Wikipedia Linux page http://en.wikipedia.org/wiki/Linux
Linux Distributions Wikipedia http://en.wikipedia.org/wiki/Linux_distribution
Glade User Interface Designer Reference Manual http://library.gnome.org/devel/gladeui/3.6/

Switch Netbook to Classic Desktop Mode in Karmic Koala


New Ubuntu Netbook 9.10 is as nice as it can be.  they added more apps and enhanced the interface.  I do like the new Netbook desktop,  it got much better interface than the older one they had with 8.4.  The problem is I like to switch between Netbook mode and Classic mode.  the regular Application menu where you have to click on Application then go down throw the program categories and click on the app you want to start.  Well, it took me a while to figure out a way to do that.
First of all, there is no desktop switcher utility provided in 9.10, so you can not just click on switch between these two modes that easy.
Now, the change is easy, but you would not want to do this twice, there are few steps and things you will do and memorize in order to do the switch.  just follow this step by step process and you will be able to get the old classic desktop back on your 9.10 Netbook Karmic Koala.
  1. Remove the existing Netbook Menu, right click on startup icon, at the top left part of the Main Panel and select remove
    Netbook icon on main Panel
  2. Remove the Netbook Menu it self, go to System, preferences, Startup Applications and Find “Netbook Launcher” and un-check it. then find “Maximus Window Management” and un-check it.  This is the program that maximizes the window for any program you open, which gets annoying at some point.
  3. Do not worry, if you say, now that the desktop will be empty, how am I going to start of find any application, your other option to start any application is to use Alt+F1 and this will show you the main menu at any time.
  4. go to the main panel and right click.  this is the hardest part as you need to make sure you click on the correct are, all the way to the left of this panel, the menu should be as shown below.
  5. Select Add to Panel
  6. look for “Menu Bar, A custom menu bar” and Add it, wallah, you got it back
I will be working on adding more Snap shots later to this so it makes it easier to follow

How to Auto scroll TextBox, ListBox, ListView


programming In C# with Visual Studio 2008

Sometimes you need to add this little trick in your code to ease using it. this trick is to force the TextBox, ListBox, ListView, or DataGridView to scroll down to the last item was entered.

Here are some info on how to do an Auto-scroll for your program controls

TextBox autoscroll

textBox1.SelectionStart = textBox1.Text.Length;
textBox1.ScrollToCaret();

ListBox autoscroll

listBox1.SelectedIndex = listBox1.Items.Count - 1;
listBox1.SelectedIndex = -1;

ListView autoscroll

listView1.EnsureVisible(listView1.Items.Count - 1);TreeView autoscroll
treeView1.Nodes[treeView1.Nodes.Count - 1].EnsureVisible();

DataGridView autoscroll

dataGridView1.FirstDisplayedCell =
dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];


Note:
This blog was first published in Google Knowledge but since they shut down the project, I had to move my blogs here.

We Have to Start Somewhere!

I am working on this new ideas.  I been doing a lot of research and development and I expect a lot more to come.  So, I believe documenting is the best way to preserve this work and the best way to allow other to benefit from it.  Also, I hope other will get involved and open the door for discussions and opinions.
Here is a quick System Over View as a start point.
The first project I am working on is a USB-to-SPI Bridge, UTSB.  This bridge will manage or connect a system on the USB bus to systems on the SPI bus.

MCU Chosen for this system: PIC24HJ256GP610A
Used Microchip USB Stack and SPI Hardware interface
Started with the CDC Emulator Project provided from Microchip examples for the PICDEM FS USB.


Next: 

  1. Flow Chart of USB-to-SPI Bridge UTSB "USB To SPI Bridge"
  2. Schematic and pin-outs
  3. example code for the System
  4. Protocol used to control the UTSB
  5. Other items related to development progress