Thursday, December 18, 2014

Run Hello World Python on Raspberry pi/ Qemu

There are two different ways you can write programs for Python. You can create text files that contain the code, and then run these files with Python, or you can use an Integrated Development Environment (IDE) such as IDLE 3. Either way will result in the code being run in the same way and it's just a matter of personal preference.




If you want to write the programs as text files, you need to use a text editor such as Leafpad. A word processor such as LibreOffice's Writer is unsuitable because the various formatting it uses will confuse Python. As an example, open Leafpad and create a new file that just has the line:

print("Hello World!")

Once you've created your file, just save it with the extension .py; for example testpython.py. You can then run it by opening LXTerminal and navigating to where the file is saved. Then you run python <filename>. You can use the cd command to move to different directories. For example, if you save the file in a folder called programming in your home directory, you could run it by typing the following into LXTerminal:
 
cd programming
python3 testpython.py

 
If everything has worked correctly, you should see the following line appear on the screen:
Hello World!

otherwise just open python shell IDLE 3 and command  print("Hello World!") press Enter you will see the output as 
 Hello World!  
 

Wednesday, December 17, 2014

Set Proxy to Raspberry Pi or Emulator Qemu

In this post I'm going to explain how to connect internet thorough proxy connection because most universities and colleges have the proxy internet connection so these are the steps we need to do to connect internet through Proxy





1. In Raspberry pi there is two Terminals one is user terminal and another one is root terminal in order make connection setting we need to open root terminal
Start Menu --> Accessories --> Root Terminal

2. in the Terminal navigate into the directory apt.conf.d thorough type the command cd /etc/apt/apt.conf.d


















3. Then create and open 10proxy file (actually this file is not exist so we have to create the file) through command nano 10proxy (this is the command for this creating and opening the 10proxy file in Terminal)





















4. Then add the Acquire::HTTP::Proxy "http://username:password@proxy_server_address:port"; line ( you have to add the sentence in bold) and Save it .
( Example :The format is Acquire::HTTP::Proxy "http://username:password@10.0.0.1:8080"; the format is according to you local proxy)

5. Then Close the Terminal . For checking Type sudo apt-get update in terminal . Then you get the internet access in raspberry to download the packages.

to check ip type command ifconfig on terminal

Run Raspberry Pi using Qemu emulater on Windows

There are a few things that make the Raspberry Pi a great device on which to learn programming. Firstly it's cheap. At around a tenth of the price of a low-end PC, it's cheap enough to have in addition to your main computer.Here is the guide to emulate Raspberry pi using Qemu Emulator on our PC.





1. Download Suitable virsion of the the Qemu Emulator and Extract it into the folder
2. Download and place the Qemu kernel in the same directory.
3. Download the Image file for your Raspberry Pi Emulator and Extract it into the same Directory .

Now Your Folder Should be like this in the final view after all editing works
Now the time to start our Emulator so to make easy the work we need to create a .bat file to run Starting command.in your text editor create a new file and type the below command and save it as Raspberry.bat name is optional one and make sure your image file name.
qemu-system-armw.exe -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -hda wheezy_raspbian.img



then we need to make some modifications before we boot properly to make this change run the .Bat file as a administrator then only it will allow to modify the files

Type                nano /etc/ld.so.preload
Put a # in front of the first line so that it looks like this:
           #/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so
Now Press ctrl-x then y then enter to save and exit.

Now is the time to run the Emulator to do then open your .bat file and delete the code init=/bin/bash
 its mean
qemu-system-armw.exe -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda wheezy_raspbian.img

Above is the new code to run if you run this code




















when we run the command it will ask the username and password for the pi

Default Username=pi
Default Password=Raspberry

if we type correct username & Password above window will appear in that console type startx this is the command to start the Raspberry pi Emulator




















Yes! we Done our work now Qemu Emulator Running on Windows Machine