Saturday, February 8, 2014

[Product Review] Raspbery Pi Cookbook Video

This is a product review for the Raspbery Pi Cookbook Video.

As they say, "Seeing is Believing", there is something to be said about a seeing something being done rather than reading about it. Perfect companion for the cookbook, in my opinion.

I reviewed the cookbook when it was in early draft and liked it very much. At the time, I honestly thought that it would be great if I can just see demonstrate of some of the recipes. Apparently I am not alone. Personally I believe if you have some experience with Raspberry Pi you will still get value out of the video, but it is best to be used with the cookbook so one can read about the recipe and reinforce the idea with the video.

Just like the cookbook, the video works from simple to more complex recipes. Some recipes builds on top of each other, but not much.

Overall, I believe if you like the cookbook, you will enjoy the video.

[02/16/2014]

Here is a video for a mashup for "Recipe 04.09 Raspberry Pi Radio Transmitter". The idea is to tail /var/log/syslog, upon finding a suitable event, play the sound.


Here is the code:

#!/usr/env/bin python
#
# Eric Chou ericc@a10networks.com
# Fred Hsu fredlhsu@aristanetworks.com
# http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter
#
# Feb. 16, 2014
#
# The purpose of the file is to tail the syslog, upon finding a suitable event
# the device will push out the directflow to the Arista switch and transmit
# a FM radio sound to indicate triggered event.
#

import subprocess, time, re
from jsonrpclib import Server

p = subprocess.Popen('tail -f /var/log/syslog', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

# Sets Arista API call parameters
username = "admin"
password = "admin"
switch = "172.22.28.156"
dip = "10.1.1.1"
outport = "Port-Channel 100"
urlString = "https://{}:{}@{}/command-api".format(username, password, switch)
switchReq = Server( urlString )

# Tails syslog and look for the re expression
while True:
    line = (p.stdout.readline()).strip()
    if re.search('vThunder-2', line):
        print "Found Event: ", line
        print "Pushing Direct Flow out to Arista switch", switch
        # The following rpc request will match on the source IP, then punts traffic to output port
        #response = switchReq.runCmds( 1, ["enable", "configure", "openflow", "flow a10", "persistent", "match destination ip {}".format(dip), "action set output interface {}".format(outport)] )
        subprocess.call(['./pifm', 'starwars.wav', '103.0']) #make sure pyfm available

Happy scripting with Raspberry Pi!



2 comments:

  1. I look forward to seeing more updates from you, this helps me a lot. Because I have a Hotmail account, so I found hotmail com login for troubleshooting every problems. If you cannot find your problems any where, this website will help you.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete