Friday, June 19, 2009

Enable Wifi In Ubuntu for HP DV series Laptops specifically

Step 1

Open the Terminal. Applications--> Accessories--> Terminal OR press ALT+F2 and type 'gnome-termianl' & enter then you have to check the WiFi adapter so type , lspci -v , in the terminal and check wether your adapter is Atheros and if not i'm afraid that this might not work, so after knowing that it's Atheros you can proceed further

Step 2

Go to

System-->Administration-->Hardware Drivers and Deactivate the driver Ubuntu has used for the adapter (in most scenarios Ubuntu assigns a avalible driver for the adapter but it's won't be competible )after that reboot .

The kernel headers and the compiler are needed to build this driver so you have to get started by installing build-essential. In a terminal window (Applications/Accessories/Terminal) enter:

sudo apt-get install build-essential

The driver code will be downloaded with the subversion source code manager so I installed subversion:

Code:
sudo apt-get install subversion 

You need a place to put the driver source without mixing it up with other stuff so changed directory to your home directory:

Code:
cd ~ 

Created a directory:

Code:
mkdir madwifi 

And changed to the new dirctory:

Code:
cd madwifi 

Use subversion to download (checkout) a copy of the code: If this site is not working mail me ..I have the tar file....

After the driver code is downloaded by subversion, change to the directory, which should be madwifi-hal-0.10.5.6

Code:
cd madwifi-hal-0.10.5.6 

Run the make script to have the compiler build the driver:

Code:
make 

Install the driver

Code:
sudo make install 
You can also give above commands in one line:
sudo make && make install 

Add the Atheros kernel module to the list of modules to be automatically loaded at boot by adding "ath_pci" (without the quotes) to the end of the /etc/modules file. Gedit is probably easy to use so try:

Code:
sudo gedit /etc/modules 

Now you can reboot and it should work.

Enjoy !!!!



Implementing the C printf() function???

Given this code, I was to finish it by creating the printint(), printstring(), and printhex() functions.
Before you start this please go thorough this function va_arg() to make the code undersatandable


#include

extern int printchar(int);

void myprintf(const char *fmt, ...);
{
const char *p;
va_list argp;
int i;
char *s;
char fmtbuf[256];

va_start(argp, fmt);

for(p + fmt; *p != '\0'; p++)
{
if(*p != '%')
{
putchar(*p);
continue;
}

switch(*++p)
{
case 'c':
i = va_arg(argp, int);
putchar(i);
break;

case 'd':
i = va_arg(argp, int);
printint(i);
break;

case 's':
s = va_arg(argp, char *);
printstring(s);
break;

case 'x':
i = va_arg(argp, int);
printhex(i);
break;

case '%':
putchar('%');
break;
}
}

va_end(argp);
}

void printint(int i)
{
int digit;
digit = i % 10;
digit = digit + '0';
i = i / 10;
putchar(i);
}

void printstring(char s)
{
putchar(s);
}

void printhex(int i)
{
for (int a=2*sizeof(int) - 1; a>=0; a--) {
putchar("0123456789ABCDEF"[((i >> a*4) & 0xF)]);
}
}