Sunday 29 December 2013

Working inside the Envelope

In my real life, I'm a faculty member in Computer Science with a focus on first-year learning. While some might argue otherwise, I'm very interested in my student's success. Success in first-year has something to do with learning content, but a large component has to do with understanding that they are in charge of their learning, and that they need a strategy for how they are going to go about it. I find that if they get the second part right (thinking about and planning how they are going to learn), then the first part becomes relatively easy.

So here's an argument for finishing early. I have no empirical models - just a ton of observations. The red line represents stress as a deadline approaches, with the submission not complete. Notice that at the last moment it's due the stress is off-the-chart high. Now look at common sense (blue line), again assuming the submission is not complete. Notice that at the last moment the submission is due there is no common sense left. So the message is that the closer to the deadline, the more likely you are to want to make a bad (stress-induced) choice, and the less oversight (common sense) you have to resist the bad idea. This can't be a good mix, can it?

Take a moment to think about a deadline. It does not represent the time that something must be handed in. Nope, instead it represents the last possible time that something can be handed in. The message? Complete the deliverable in advance, before the stress gets stupid and so do you. You do better work for less stress and more peace. Isn't that where you want to work?

For you teachers out there, what are some of the silly things that your students have done when they work outside of the envelope?

Friday 27 December 2013

Raspberry WAP

Progress over the past day or so has been good, and I now have what most people think of as a home router.

If you're following along and building this with me, you should consider an ssh/puTTY session to work in so that you can copy/paste if you wish. First, login to the RPi and find out the IP address (in bold) of the ethernet interface, eth0:


eth0 Link encap:Ethernet HWaddr b8:27:eb:6a:c7:61
     inet addr:192.168.2.244 Bcast:192.168.2.255 
     Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500  Metric:1 
     RX packets:6152 errors:0 dropped:0 overruns:0 frame:0 
     TX packets:511 errors:0 dropped:0 overruns:0 carrier:0 
     collisions:0 txqueuelen:1000 
     RX bytes:614474 (600.0 KiB) TX bytes:46934 (45.8 KiB)

If you're using a Mac or Linux, start a shell and simply type


ssh pi@192.168.2.244


to complete your login. If you're using Windows, look into the puTTY tool.  

When I ordered the parts for the VantasticVideo Project I paid particular attention to the wifi adapter to ensure that it was capable of acting in client mode to connect to multiple wireless clients. The Newark store lists all Adafruit wifi adapters as being capable of this.

The following procedure is based on http://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/ beginning at "Check Ethernet & Wifi". Each heading here matches the headings there, to make it easier to stay in sync. I've listed my files here to represent what worked for me. I've also assumed some familiarity with linux/unix, and that you have a general understanding of using a text editor such as nano or vi.


Install the Software

sudo apt-get update
sudo apt-get install hostapd isc-dhcp-server


This installs the access point server package and the dhcp IP address server. The download will ask you to confirm the download. You do. Note that the install may complain that something doesn't seem right and ask you to confirm that you want to proceed. You do.


Setup DHCP Server

The dhcp configuration file (/etc/dhcp/dhcpd.conf) gives some explanations as well as example configurations. Lines in the file that are comments (not used by the software) begin with "#". The documentation I followed lists quite a few things. Here are the pertinent pieces we need:

  1. uncomment the line #authoritative
  2. add the following text to the end of the file:
subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.20 192.168.1.50;
        option broadcast-address 192.168.1.255;
        option routers 192.168.1.1;
        default-lease-time 600;
        max-lease-time 7200;
        option domain-name "mobile";
        option domain-name-servers 192.168.1.1;
}
In addition, we need to edit /etc/default/isc-dhcp-server and update the line


INTERFACES="" 

to read

INTERFACES="wlan0"

As a short explanation, we need to identify that this dhcp server is to be considered the authority for the networks it serves (only wlan0 in this case), specify a network to serve, including the address range to lease IP addresses from, the connection IP to the outside world, the lease duration and dns parameters. We'll look at dns as a last item in this post


Setup wlan0 for Static IP

The network interface information is kept in /etc/network/interfaces. We need to edit it to look like this:
auto lo

iface lo inet loopback

auto eth0
iface eth0 inet dhcp

allow hotplug wlan0

auto wlan0
iface wlan0 inet static
address 192.168.1.1
netmask 255.255.255.0

There is one additional line to add, later.


Configure Access Point

The access point information is kept in /etc/hostapd/hostapd.conf. We need to edit it to look like this:
interface=wlan0
driver=rtl871xdrv
ssid=VanNetwork
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
#wpa=2
#wpa_passphrase=Raspberry
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP
#rsn_pairwise=CCMP

Note that I've opted for an open network and commented out the wpa2 security. I suppose I could worry that someone could watch movies from this machine while travelling next to me at 120kph. But I won't.

We also need to update /etc/default/hostapd so that the line 
#DAEMON_CONF="" 

reads 

DAEMON_CONF="/etc/hostapd/hostapd.conf"


Configure Network Address Translation

The steps I took are exactly as given in the guide I followed (http://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software), so in the spirit of DRY (Don't Repeat Yourself), go look there. Note that the last edit necessary for /etc/network/interfaces is done here.


Update hostapd

Again, I followed the steps exactly as specified in the guide.


Finishing Up!

You guessed it - I followed the guide.


Connect and Test

This was the last step I followed. I have no desire to compile packages myself. Having done time compiling kernels to add new hard drives, I'm quite happy to stand on the shoulders of giants and (gratefully) use their handiwork.

At this point we have a functioning home gateway/router box. Take a device, connect it to VanNetwork and take a moment to revel in your accomplishment!

Thursday 26 December 2013

Vantastic Video Project: Overview

Last fall we bought a new minivan. The kids were excited because looking through the brochures, they saw -- video screens! When I looked all I saw was the $3,000 price to upgrade to that package. And then I saw shiny DVD disks, dulled by salt and sand. Both the price and the ongoing damage were/are a problem for me.

Most adults travelling with kids will tell you that: (i) videos are a good idea and (ii) their kids are pigs create mess in any space they occupy. The VantasticVideo Project seeks to provide a compact mobile video solution that provides entertainment without adding to the chaos of stuff in the vehicle.

The Vision

I have a home server in my basement, and among the things stored on it are moves ripped from the DVDs I own into h.264 format as .mp4 format video files. Using these already existing files, I'd like to copy a selection of them onto a USB drive, insert them into some small computing device in the vehicle powered by the native 12V "power outlets". The device then can stream the video on demand using wifi to mobile devices (phones, tablets, computers), so that anyone in the vehicle can watch their choice of movie in their own time.

My Solution

The solution is composed of several technologies coming together, and a bit of scripting. So here's the gist of things, delivered by technology.

A raspberry pi (RPi) will serve as the computing device, powered through a mini-USB cable to a USB/power outlet adapter. Through a USB wifi interface, the RPi will provide home router capabilities (dhcp, NAT, client wap, routing) as well as minimal dns. Using a web server on the RPi, it will serve up web pages in HTML5 that are custom-built at boot time, when the USB drive is mounted to the web server's document root. Clients connect to the network, load the master index page listing all the moves, choose the movie's web page they want to watch and the movie is delivered though html <video> tags to enable viewing though the device's native format.

For my purposes I'm choosing h.264 because my kids all have Apple devices and that format is supported natively by their Safari web browser.


Telling The World

I don't have this built yet. As I go, I'll publish a note about my current chunk of progress. Hopefully I'll get it done, and it'll clear enough that you can build one too, and maybe extend to make it better.

So far there are two generic posts about getting the Raspberry Pi and loading the basic operating system. I'll update this post as I publish my progress.

Update: Raspberry WAP builds on the project to produce a wireless home router.

Monday 23 December 2013

Raspbian Pi

The Raspberry Pi hardware is together. Let's see what happens.


Initial Boot

On boot the machine scrolls the usual reams of text and ends with a dialog box to choose the operating system to install. I'm a "recommended" kind of guy the first-time round, and so chose Raspbian. It didn't hurt that my preferred distribution is Debian/Ubunutu :)




Not very exciting in itself, but progress is being made.

And things installed successfully, so a reboot and we're ready for setup.

Setup



  1. Expand Filesystem
    • The install of Raspbian includes this step, ensuring that the full memory of the SD card is available.
  2. Change User Password
    • Do this. Not only does it secure your system, but also makes it available for remote login via ssh.
  3. Enable Boot to Desktop
    • Because I don't see needing a desktop for what I'm doing I didn't do this. Memory is scant enough on these without using it when not required.
  4. Internationalisation Options
    • Support for UK English is on my default
    • I did change this to add support for Canadian English (en_CA.UTF-8) as well.
  5. Enable Camera
    • If I'd bought the camera module this would make sense, but I didn't.
  6. Add to Rastrack
    • This looks like it adds geo-location tracking for the device (rastrack.co.uk). Not part of my current ideas
  7. Overclock
    • Maybe another time. For now, working is good enough.
  8. Advanced options

    • I set the hostname to vantasticvideo
    • I enabled ssh

A reboot and the RPi is ready for customization. Next time!

Sunday 22 December 2013

A Piece of Raspberry Pi

With Christmas break coming, I figured I'd have some spare hours to take on a Raspberry Pi (RPi) project and see what the buzz has been about. Thanks to +John Peterson for the encouragement to start.


Getting One

Turned out to be pretty straight-forward. I was able to order the parts through http://canada.newark.com/ and within 24 hours they were in town from South Carolina (according to UPS tracking) and by the next evening delivered to my door. Speedy is great!




The order included:




  • Raspberry Pi, version B (Two USB ports)
  • 8Gb SD card with NOOBS installed
  • case
  • USB 80211n wifi "nub"


  • Because it powers using a standard micro USB connector and I already have enough of them, I  left it out of the order. 


    Getting Ready

    Putting the kit together was a two minute adventure. According to the internet the NOOBS card will customize the card to one of several RPi operating systems that you choose. I made a backup of the card using http://elinux.org/RPi_Easy_SD_Card_Setup as a reference.

    Next Up

    Next time I'll go through powering the RPi up and choosing/configuring Raspbian using NOOBS.