Thursday, July 23, 2015

Docker first steps

Currently looking at implementing DevOps based solution at work and whenever you hear DevOps one of the most famous trending buzz work is Docker .



I decided to give it a try on a Windows 7  pc , basically you need to follow the tutorial to install Boot2Docker which will is simple enough in terms of just being an exe that will kick start a stripped down Linux instance on your Windows pc or Mac .

The first thing you need to do is try out this simple command:

docker run hello-world


The picture below explains syntax within the commands:
Now the first issue I got however that no Docker images were being downloaded , i just kept getting i/0 timeout errors . Figureout that something might be blocking the images being downloaded.

A simple googling provided a rapid answer that the problem had to do with Cisco Connect Anywhere , if you have it installed either you need to exit it ( and close from system tray ) or you  can follow the instructions from this stackoverflow query:

http://stackoverflow.com/questions/26686358/docker-cant-connect-to-boot2docker-because-of-tcp-timeout

Sure enough once Cisco Connect Anywhere was closed i was able to download the image.

Sunday, April 12, 2015

Control GPIO Pins on Raspberry Pi 2 using Webiopi

I recently started working on a robot controlled with my Raspberry Pi , it is at the moment kind of rover which is attached to my Raspberry Pi through a long umbellical cord of wires. There are 2 servos to which my Raspberry Pi sends out data through an L298N H-Bridge which makes the Robot "Rover" wheels  move either backward or forward .

I managed to also write a python code to send signals to the servers which looks a bit like this :

-------------
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)

GPIO.output(7,True)
time.sleep(1)
GPIO.output(7,False)
GPIO.output(11,True)
time.sleep(1)
GPIO.output(11,False)
GPIO.output(13,True)
time.sleep(1)
GPIO.output(13,False)
GPIO.output(15,True)
time.sleep(1)
GPIO.output(15,False)
GPIO.cleanup()


--------------

Now that is great but what would have been better would be to access to the GPIO pin remotely via a REST API for example and here is where Webiopi kicks in which basically provides you a WEB and a REST interface to connect to you GPIO pins of your PI :
https://code.google.com/p/webiopi/wiki/INSTALL  

As a first setup you need to follow the instructions from the Webiopi install page above .

Note: that current version ,  WebIOPi-0.7.1 ,didn't work straight off with my Raspberry Pi 2 I had to do the following changes to the following c files  once the Webiopi setup was completed:

1.python/native/cpuinfo.c,change "BCM2708" to "BCM2709";
2.python/native/gpio.c, change "#define BCM2708_PERI_BASE 0x20000000" to "#define BCM2708_PERI_BASE 0x3f000000";
3.run setup.sh again.

The above solution was found from RaspberryPi forums .

Now you should be up and running after having re-run the setup for WebIOPI. You launch the server using command:

sudo /etc/init.d/webiopi start

Then you go to navigate to the following location on your PI :

http://IP_ADDRESS_OF_YOUR_PI:8000/

Note that you can get the IP_ADDRESS_OF_YOUR_PI using ifconfig command .

To quickly test the setup navigate to :
http://IP_ADDRESS_OF_YOUR_PI:8000/app/gpio-header

For those pins on which servos are connected change them from IN to OUT  and click on the number corresponding to the pin to execute .


Weaved

Note that WebIOPI is supported by Weaved which provides you to install a package on your Raspberry PI that allows you to control your RaspberryPi WebIOPI from anywhere as long as  you and your PI are connected to the internet .

What nice is that this is a free service and I justed it works .

https://developer.weaved.com/portal/members/betapi.php