<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://elinux.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://elinux.org/api.php?action=feedcontributions&amp;user=Ruff&amp;feedformat=atom</id>
		<title>eLinux.org - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://elinux.org/api.php?action=feedcontributions&amp;user=Ruff&amp;feedformat=atom"/>
		<link rel="alternate" type="text/html" href="http://elinux.org/Special:Contributions/Ruff"/>
		<updated>2013-06-19T18:47:39Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.22alpha</generator>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2013-01-03T16:46:40Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Highlights */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
09 Executive Summary&lt;br /&gt;
09 Installation Instructions&lt;br /&gt;
09 User Instructions &lt;br /&gt;
10 Highlights (Nice video.  Label the 2nd one as an HD version of the first.)&lt;br /&gt;
10 Theory of Operation (Nice diagram.  It' really helps explain how things work)&lt;br /&gt;
09 Work Breakdown&lt;br /&gt;
10 Future Work&lt;br /&gt;
09 Conclusions&lt;br /&gt;
10 Demo&lt;br /&gt;
10 On Time&lt;br /&gt;
Comments: Well done.  Very well documented.  &lt;br /&gt;
&lt;br /&gt;
Score:  95/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encode the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The node.js server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
[[File:BeagleVNS_Door_Bell.jpg|thumb|right|A door bell button is a good idea]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::Node.js is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
::: You can also start the node.js server to edit the configuration file. Simply run the command below in the BeagleBoardVNS destroyer and then point your browser to the beaglebone's port 8081 with a URL or host name, i.e: beagleVNS.local:8081&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''node BeagleBoardVNS.js'''&lt;br /&gt;
&lt;br /&gt;
::: Note that you can change your host name by editing this file: /etc/hostname. For example:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''nano /etc/hostname'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|k7yUmo1zc0Q}}&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNSDiagram.jpg|640px|thumb|right|BeagleBone]]&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions to the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/File:BeagleVNS_Door_Bell.jpg</id>
		<title>File:BeagleVNS Door Bell.jpg</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/File:BeagleVNS_Door_Bell.jpg"/>
				<updated>2012-11-14T03:54:42Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: An appropriate door bell for BeagleVNS&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An appropriate door bell for BeagleVNS&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:53:41Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
[[File:BeagleVNS_Door_Bell.jpg|thumb|right|A door bell button is a good idea]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
::: You can also start the node.js server to edit the configuration file. Simply run the command below in the BeagleBoardVNS destroyer and then point your browser to the beaglebone's port 8081 with a URL or host name, i.e: beagleVNS.local:8081&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''node BeagleBoardVNS.js'''&lt;br /&gt;
&lt;br /&gt;
::: Note that you can change your host name by editing this file: /etc/hostname. For example:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''nano /etc/hostname'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNSDiagram.jpg|640px|thumb|right|BeagleBone]]&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:47:45Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Highlights */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
::: You can also start the node.js server to edit the configuration file. Simply run the command below in the BeagleBoardVNS destroyer and then point your browser to the beaglebone's port 8081 with a URL or host name, i.e: beagleVNS.local:8081&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''node BeagleBoardVNS.js'''&lt;br /&gt;
&lt;br /&gt;
::: Note that you can change your host name by editing this file: /etc/hostname. For example:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''nano /etc/hostname'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNSDiagram.jpg|640px|thumb|right|BeagleBone]]&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:44:58Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* User Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
::: You can also start the node.js server to edit the configuration file. Simply run the command below in the BeagleBoardVNS destroyer and then point your browser to the beaglebone's port 8081 with a URL or host name, i.e: beagleVNS.local:8081&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''node BeagleBoardVNS.js'''&lt;br /&gt;
&lt;br /&gt;
::: Note that you can change your host name by editing this file: /etc/hostname. For example:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''nano /etc/hostname'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=C4nStjQJdCc BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNSDiagram.jpg|640px|thumb|right|BeagleBone]]&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:43:44Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* User Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
::: You can also start the node.js server to edit the configuration file. Simply run the command below in the BeagleBoardVNS destroyer and then point your browser to the beaglebone's port 8081 with a URL or host name, i.e: beagleVNS.local:8081&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''node BeagleBoardVNS.js'''&lt;br /&gt;
&lt;br /&gt;
::: Note that you can change your host name by using editing this file: /etc/hostname. For example:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''nano /etc/hostname'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=C4nStjQJdCc BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNSDiagram.jpg|640px|thumb|right|BeagleBone]]&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:23:53Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Theory of Operation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=C4nStjQJdCc BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNSDiagram.jpg|640px|thumb|right|BeagleBone]]&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:23:45Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Theory of Operation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=C4nStjQJdCc BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNSDiagram.jpg|640px|thumb|right|BeagleBone]]&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:23:03Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Theory of Operation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=C4nStjQJdCc BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNSDiagram.jpg|640px|thumb|right|BeagleBone]]&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/File:BeagleVNSDiagram.jpg</id>
		<title>File:BeagleVNSDiagram.jpg</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/File:BeagleVNSDiagram.jpg"/>
				<updated>2012-11-14T03:21:05Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: A block diagram on how each component works together.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A block diagram on how each component works together.&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:19:49Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Theory of Operation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=C4nStjQJdCc BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
[[File:BeagleVNSDiagram.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:16:46Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Highlights */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=C4nStjQJdCc BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:16:35Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Highlights */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
[http://www.youtube.com/watch?v=C4nStjQJdCc BeagleVNS YouTube Video Demo]&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T03:10:11Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Highlights */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
[http://www.youtube.com/embed/k7yUmo1zc0Q BeagleVNS YouTube Video Demo]&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T00:45:09Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email, and that we have been working under Python 2.7 and did not need to modify our code for version 3.0 syntax.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T00:32:23Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Future Work */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio or achieve files locally&lt;br /&gt;
# Capture video along with audio or capture image upon button press&lt;br /&gt;
# Voice-To-Text using Google Voice API&lt;br /&gt;
# Low Power Mode for longer battery life using interupts&lt;br /&gt;
# Release alsa device for other aplications when not in use&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T00:25:20Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio files&lt;br /&gt;
# Capture video along with audio&lt;br /&gt;
# Voice-To-Text&lt;br /&gt;
# Low Power Mode for longer battery life&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T00:24:08Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*'''Node.js'''&lt;br /&gt;
&lt;br /&gt;
::Node.js is a tool for quickly make web or browser based interfaces for networking with the beagle or any comparable platform.&lt;br /&gt;
&lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file&lt;br /&gt;
&lt;br /&gt;
:: Installation instructions can be found here: [[ECE497 Notes on node.js | ECE497 Notes on node.js]]&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio files&lt;br /&gt;
# Capture video along with audio&lt;br /&gt;
# Voice-To-Text&lt;br /&gt;
# Low Power Mode for longer battery life&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-14T00:07:33Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Executive Summary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we are able to successfully capture audio while a user presses and holds a button. Once the button is released, there is a python script that will encod the recording into a mp3 file and send it via an email attachment to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use, who to send the email message too, as well as what text to populate the subject and body field with. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
== Install Instructions ==&lt;br /&gt;
&lt;br /&gt;
::In order to run this application the ALSA library must be installed. &lt;br /&gt;
::NodeJS is an optional installation if you would like a web interface for changing the email preferences file. &lt;br /&gt;
&lt;br /&gt;
::No other installation is required.  The application developed is available on a git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your '''home directory''' to get up and running first before modifying anything for your own application.  Otherwise the program will not work.  Follow the github section below to download the repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd'''&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Restart the Network'''&lt;br /&gt;
:::If you cannot grab an ip address from a dns server when the A5 image initially boots up. Run the following command in order to restart the network service&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''/etc/init.d/networking restart'''&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Beagle VNS Application'''&lt;br /&gt;
&lt;br /&gt;
::: In order to run the Beagle VNS Application you will need go to the C-Programs Directory&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''cd ~/BeagleBoardVNS/C-Program/'''&lt;br /&gt;
&lt;br /&gt;
::: Once you are in this directory, you will need to compile the application.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''make clean; make'''&lt;br /&gt;
&lt;br /&gt;
::: Now you can run the application.  There is currently only a debug version of the application.  This verision will print out debug information which is helpful to see what is going on.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''./beagleVNSApp_DEBUG'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that will need to be started and checks for the button press. When it picks up that the button has been pressed it collects audio until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google voice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending complete&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is complete it is in the C-Program Directory&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::If you run the C-Program the audio collection will work.  However, the web interface is a separate service you will need to start.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
The following C application is used to collect audio from the Playstation Eye and then write it to a file when a gpio button is being pressed.  Once the pgio button is released, the program runs a bash file that will encode the raw audio into mp3 and email it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
#include     &amp;lt;fcntl.h&amp;gt;                          // Defines open, read, write methods&lt;br /&gt;
#include     &amp;lt;unistd.h&amp;gt;                         // Defines close and sleep methods&lt;br /&gt;
//#include     &amp;lt;string.h&amp;gt;                         // Defines memcpy&lt;br /&gt;
#include     &amp;lt;alsa/asoundlib.h&amp;gt;			// ALSA includes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
//#include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;audio_input_output.h&amp;quot;             // Audio driver input and output functions&lt;br /&gt;
&lt;br /&gt;
//* ALSA and Mixer devices **&lt;br /&gt;
#define     SOUND_DEVICE     &amp;quot;plughw:0,0&amp;quot;	// This uses line in&lt;br /&gt;
//#define     SOUND_DEVICE     &amp;quot;plughw:1,0&amp;quot;	// This uses the PS EYE mikes&lt;br /&gt;
&lt;br /&gt;
//* Output file name **&lt;br /&gt;
#define     OUTFILE          &amp;quot;/tmp/audio.raw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//* The sample rate of the audio codec **&lt;br /&gt;
#define     SAMPLE_RATE      8000&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the left channel **&lt;br /&gt;
#define     LEFT_GAIN        100&lt;br /&gt;
&lt;br /&gt;
//* The gain (0-100) of the right channel **&lt;br /&gt;
#define     RIGHT_GAIN       100&lt;br /&gt;
&lt;br /&gt;
//*  Parameters for audio thread execution **&lt;br /&gt;
#define     BLOCKSIZE        48000&lt;br /&gt;
&lt;br /&gt;
// Success and failure definitions for the thread&lt;br /&gt;
#define     AUDIO_THREAD_SUCCESS     ( ( void * ) 0 )&lt;br /&gt;
#define     AUDIO_THREAD_FAILURE     ( ( void * ) - 1 )&lt;br /&gt;
&lt;br /&gt;
// The levels of initialization for initMask&lt;br /&gt;
#define     INPUT_ALSA_INITIALIZED      0x1&lt;br /&gt;
#define     INPUT_BUFFER_ALLOCATED      0x2&lt;br /&gt;
#define     OUTPUT_FILE_OPENED          0x4&lt;br /&gt;
&lt;br /&gt;
// Thread environment definition (i.e. what it needs to operate)&lt;br /&gt;
typedef  struct  audio_thread_env&lt;br /&gt;
{&lt;br /&gt;
    int quit;                // Thread will run as long as quit = 0&lt;br /&gt;
    int button;&lt;br /&gt;
} audio_thread_env;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
 audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
     audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Variables and definitions&lt;br /&gt;
// *************************&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	int recording = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	audio_env.button = button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	// led light&lt;br /&gt;
	int led = 17;&lt;br /&gt;
	int bled = 1;&lt;br /&gt;
	led = (bled*32)+led;&lt;br /&gt;
	exportgpio(led);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	setdirection(led,0);&lt;br /&gt;
&lt;br /&gt;
	//turn off led&lt;br /&gt;
	gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// Thread parameters and return value&lt;br /&gt;
        void             * status = AUDIO_THREAD_SUCCESS;      // &amp;lt; see above&lt;br /&gt;
        unsigned  int   initMask =  0x0;		// Used to only cleanup items that were init'd&lt;br /&gt;
&lt;br /&gt;
        // Input and output driver variables&lt;br /&gt;
        snd_pcm_uframes_t exact_bufsize;&lt;br /&gt;
        snd_pcm_t	*pcm_capture_handle;&lt;br /&gt;
&lt;br /&gt;
        FILE          * outfile = NULL;	// Output file pointer (i.e. handle)&lt;br /&gt;
        int   blksize = BLOCKSIZE;		// Raw input or output frame size&lt;br /&gt;
        char *inputBuffer = NULL;		// Input buffer for driver to read into&lt;br /&gt;
&lt;br /&gt;
// Setup audio input device&lt;br /&gt;
// ************************&lt;br /&gt;
&lt;br /&gt;
        // Open an ALSA device channel for audio input&lt;br /&gt;
        exact_bufsize = blksize/BYTESPERFRAME;&lt;br /&gt;
&lt;br /&gt;
        if( audio_io_setup( &amp;amp;pcm_capture_handle, SOUND_DEVICE, SAMPLE_RATE, &lt;br /&gt;
	        SND_PCM_STREAM_CAPTURE, &amp;amp;exact_bufsize ) == AUDIO_FAILURE )&lt;br /&gt;
        {&lt;br /&gt;
                ERR( &amp;quot;Audio_input_setup failed in audio_thread_fxn\n\n&amp;quot; );&lt;br /&gt;
                status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                goto cleanup;&lt;br /&gt;
        }&lt;br /&gt;
        DBG( &amp;quot;exact_bufsize = %d\n&amp;quot;, (int) exact_bufsize);&lt;br /&gt;
&lt;br /&gt;
        // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_ALSA_INITIALIZED;&lt;br /&gt;
&lt;br /&gt;
        blksize = exact_bufsize*BYTESPERFRAME;&lt;br /&gt;
        // Create input buffer to read into from OSS input device&lt;br /&gt;
        if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
        {&lt;br /&gt;
           ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
           status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
           goto  cleanup ;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
       DBG( &amp;quot;Allocated input audio buffer of size %d to address %p\n&amp;quot;, blksize,inputBuffer );&lt;br /&gt;
&lt;br /&gt;
        // Record that the input buffer was allocated in initialization bitmask&lt;br /&gt;
        initMask |= INPUT_BUFFER_ALLOCATED;&lt;br /&gt;
&lt;br /&gt;
// Thread Execute Phase -- perform I/O and processing&lt;br /&gt;
// **************************************************&lt;br /&gt;
	&lt;br /&gt;
        while(1){&lt;br /&gt;
		//Gets the button value&lt;br /&gt;
		//printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
		bValue = gpioRead(button);&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		// Read capture buffer from ALSA input device&lt;br /&gt;
                if( snd_pcm_readi(pcm_capture_handle, inputBuffer, blksize/BYTESPERFRAME) &amp;lt; 0 )&lt;br /&gt;
  	        {&lt;br /&gt;
               	    snd_pcm_prepare(pcm_capture_handle);&lt;br /&gt;
                 }&lt;br /&gt;
&lt;br /&gt;
		//Starts to record audio&lt;br /&gt;
		if(bValue &amp;amp;&amp;amp; !recording){&lt;br /&gt;
                	printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
      		       recording = 1;		&lt;br /&gt;
                         &lt;br /&gt;
                       // Open a file for record&lt;br /&gt;
                       outfile = fopen(OUTFILE, &amp;quot;w&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                       if( outfile == NULL )&lt;br /&gt;
                       {&lt;br /&gt;
                          ERR( &amp;quot;Failed to open file %s\n&amp;quot;, OUTFILE );&lt;br /&gt;
                          status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                          goto  cleanup ;&lt;br /&gt;
                       }&lt;br /&gt;
&lt;br /&gt;
                       DBG( &amp;quot;Opened file %s with FILE pointer = %p\n&amp;quot;, OUTFILE, outfile );&lt;br /&gt;
&lt;br /&gt;
                       // Record that input OSS device was opened in initialization bitmask&lt;br /&gt;
                       initMask |= OUTPUT_FILE_OPENED;&lt;br /&gt;
&lt;br /&gt;
                       // Processing loop&lt;br /&gt;
                       DBG( &amp;quot;Entering audio_thread_fxn processing loop\n&amp;quot; );&lt;br /&gt;
		       gpioWrite(led,0);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
    		//saves to file while recording.&lt;br /&gt;
                if(bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
	                if( fwrite( inputBuffer, sizeof( char ), blksize, outfile ) &amp;lt; blksize )&lt;br /&gt;
                        {&lt;br /&gt;
                             ERR( &amp;quot;Error writing the data to FILE pointer %p\n&amp;quot;, outfile );&lt;br /&gt;
                             status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
                             goto cleanup;&lt;br /&gt;
                        }&lt;br /&gt;
                }	&lt;br /&gt;
	&lt;br /&gt;
		// Sends the audio on button release&lt;br /&gt;
		if(!bValue &amp;amp;&amp;amp; recording){&lt;br /&gt;
			printf(&amp;quot;Button Released&amp;quot;);&lt;br /&gt;
			gpioWrite(led,1);&lt;br /&gt;
&lt;br /&gt;
                        DBG( &amp;quot;Closing output file at FILE ptr %p\n&amp;quot;, outfile );&lt;br /&gt;
                        fclose( outfile );&lt;br /&gt;
			&lt;br /&gt;
			DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        		free( inputBuffer );&lt;br /&gt;
       			DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
&lt;br /&gt;
			// Create input buffer to read into from OSS input device&lt;br /&gt;
			if( ( inputBuffer = malloc( blksize ) ) == NULL )&lt;br /&gt;
			{&lt;br /&gt;
			   ERR( &amp;quot;Failed to allocate memory for input block (%d)\n&amp;quot;, blksize );&lt;br /&gt;
			   status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
			   goto  cleanup ;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
	 		system(&amp;quot;~/BeagleBoardVNS/BeagleVNSScript&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			//reset recording flag&lt;br /&gt;
			recording = 0;&lt;br /&gt;
		}&lt;br /&gt;
	 }&lt;br /&gt;
&lt;br /&gt;
// Thread Delete Phase -- free up resources allocated by this file&lt;br /&gt;
// ***************************************************************&lt;br /&gt;
&lt;br /&gt;
cleanup:&lt;br /&gt;
&lt;br /&gt;
    DBG( &amp;quot;Starting audio thread cleanup to return resources to system\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    // Close the audio drivers&lt;br /&gt;
    // ***********************&lt;br /&gt;
    //  - Uses the initMask to only free resources that were allocated.&lt;br /&gt;
    //  - Nothing to be done for mixer device, as it was closed after init.&lt;br /&gt;
&lt;br /&gt;
    // Close input OSS device&lt;br /&gt;
    if( initMask &amp;amp; INPUT_ALSA_INITIALIZED )&lt;br /&gt;
        if( audio_io_cleanup( pcm_capture_handle ) != AUDIO_SUCCESS )&lt;br /&gt;
        {&lt;br /&gt;
            ERR( &amp;quot;audio_input_cleanup() failed for file descriptor %d\n&amp;quot;, (int) pcm_capture_handle );&lt;br /&gt;
            status = AUDIO_THREAD_FAILURE;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    // Free allocated buffers&lt;br /&gt;
    // **********************&lt;br /&gt;
&lt;br /&gt;
    // Free input buffer&lt;br /&gt;
    if( initMask &amp;amp; INPUT_BUFFER_ALLOCATED )&lt;br /&gt;
    {&lt;br /&gt;
        DBG( &amp;quot;Freeing audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
        free( inputBuffer );&lt;br /&gt;
        DBG( &amp;quot;Freed audio input buffer at location %p\n&amp;quot;, inputBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Return from audio_thread_fxn function&lt;br /&gt;
    // *************************************&lt;br /&gt;
&lt;br /&gt;
    // Return the status at exit of the thread's execution&lt;br /&gt;
    DBG( &amp;quot;Audio thread cleanup complete. Exiting audio_thread_fxn\n&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
This is the Python script that is used to email a message with an attachment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface to manage audio files&lt;br /&gt;
# Capture video along with audio&lt;br /&gt;
# Voice-To-Text&lt;br /&gt;
# Low Power Mode for longer battery life&lt;br /&gt;
# Authentication&lt;br /&gt;
# Wireless Communication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Overall, we currently have a working version of the Beagle VNS.  There are two separate parts to the project.  The Beagle C-Program records the audio and sends an email with an mp3 attachment.  There is also a web interface which will allow a user to change the default sender and recipient email address.  Some cool additions the the project would be to be able to take an video and audio message, as well as incorporate a wireless driver.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-13T16:40:18Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* User Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading Template ==&lt;br /&gt;
I'm using the following template to grade.  Each slot is 10 points.&lt;br /&gt;
0 = Missing, 5=OK, 10=Wow!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
10 Executive Summary (Looks good.  Be sure to keep it up to date)&lt;br /&gt;
00 Installation Instructions (I suggest putting the Hardware section before the software)&lt;br /&gt;
05 User Instructions (How do I make sendmail work on my Bone?)&lt;br /&gt;
00 Highlights (Not done yet)&lt;br /&gt;
00 Theory of Operation (ditto)&lt;br /&gt;
10 Work Breakdown&lt;br /&gt;
00 Future Work&lt;br /&gt;
00 Conclusions&lt;br /&gt;
00 Demo&lt;br /&gt;
00 Late&lt;br /&gt;
Comments: I'm looking forward to seeing the completed project.&lt;br /&gt;
&lt;br /&gt;
Score:  25/100&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have have been able to successfully capture audio while a user presses and holds a button.  Once the button is released, there is a python script that will encoding the recording into a mp3 file and send it via an email message to a predetermined email address.  We have also developed a web interface that will allow a user to change the preferences for what email account to use and where to send the email message. &lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we have a functioning project that consist of a C program, python script, bash script, and nodejs webserver.  The C program controls how the audio is recorded.  The python script controls sending emails with attachments.  The bash script is in charge of moving the audio file, converting it to mp3, and firing the python script.  The nodejs server controlls the preference file for the python script.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone git://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer alsa-dev alsa-utils'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 | aplay'''&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''arecord -D plughw:0,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3'''&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: A python mail client that prompts the user for information to send an email with optional attachments.&lt;br /&gt;
&lt;br /&gt;
  python smtp-mail-client-attachments.py&lt;br /&gt;
&lt;br /&gt;
  Send To (Separated by a comma): &lt;br /&gt;
  Files (Separated by a comma): &lt;br /&gt;
  Send From: beagle497@gmail.com #Must use this email for now&lt;br /&gt;
  Subject: &lt;br /&gt;
  Message:&lt;br /&gt;
&lt;br /&gt;
*'''Install Instructions'''&lt;br /&gt;
&lt;br /&gt;
::Currently as long as the arecord libraries are installed and nodejs is install, no other installation is required. The app file will use files that are contained in the git repository. The python script does not need any additional packages, and the javascript libraries are also located in the repository.&lt;br /&gt;
&lt;br /&gt;
::For simplicity and clarity when reading and understanding the code, as well as some limitations with using mix of C, Python, and bash scripts, there exists some hard-coded references dependencies. As such, we suggest cloning the repo to your home directory to get up and running first before modifying anything for your own application.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
This device is intended to record audio messages from students when professors are out of their office. The device will sit outside a professors office and will have a microphone and user button attached. A student who wishes to leave a message will press and hold the button then begin speaking, when the student has finished speaking they will release the button. The software will then save the audio file and then send the file as a mp3 to the user specified email. &lt;br /&gt;
&lt;br /&gt;
As a user the professor will be able to modify the default preferences such as email to send to and the message that they receive.&lt;br /&gt;
&lt;br /&gt;
The system consists of a C program that runs at start-up and checks for the button press. When it picks up that the button has been pressed is creates an audio process that begins recording until the button is released. The system then calls on a python mail client script passing in the location of the newly created audio file. The python script then reads from the user preferences and sends an email accordingly.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google vouice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::Making c file for initializing GPIOs, interrupts and start up scripts for VNS server&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * main.c&lt;br /&gt;
 *&lt;br /&gt;
 * ============================================================================&lt;br /&gt;
 * Copyright (c) Texas Instruments Inc 2005&lt;br /&gt;
 *&lt;br /&gt;
 * Use of this software is controlled by the terms and conditions found in the&lt;br /&gt;
 * license agreement under which this software has been supplied or provided.&lt;br /&gt;
 * ============================================================================&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Standard Linux headers&lt;br /&gt;
#include     &amp;lt;stdio.h&amp;gt;              // Always include this header&lt;br /&gt;
#include     &amp;lt;stdlib.h&amp;gt;             // Always include this header&lt;br /&gt;
#include     &amp;lt;signal.h&amp;gt;             // Defines signal-handling functions (i.e. trap Ctrl-C)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Application headers&lt;br /&gt;
#include     &amp;quot;debug.h&amp;quot;&lt;br /&gt;
// #include     &amp;quot;audio_thread.h&amp;quot;&lt;br /&gt;
#include     &amp;quot;gpio.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
// Global audio thread environment&lt;br /&gt;
// audio_thread_env audio_env = {0};&lt;br /&gt;
&lt;br /&gt;
/* Store previous signal handler and call it */&lt;br /&gt;
void (*pSigPrev)(int sig);&lt;br /&gt;
&lt;br /&gt;
// Callback called when SIGINT is sent to the process (Ctrl-C)&lt;br /&gt;
void signal_handler(int sig)&lt;br /&gt;
{&lt;br /&gt;
    DBG( &amp;quot;Ctrl-C pressed, cleaning up and exiting..\n&amp;quot; );&lt;br /&gt;
   //  audio_env.quit = 1;&lt;br /&gt;
&lt;br /&gt;
    if( pSigPrev != NULL )&lt;br /&gt;
        (*pSigPrev)( sig );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
//*  main&lt;br /&gt;
//*****************************************************************************&lt;br /&gt;
int main( int argc, char *argv[] )&lt;br /&gt;
{&lt;br /&gt;
    int   status = EXIT_SUCCESS;&lt;br /&gt;
&lt;br /&gt;
    void *audioThreadReturn;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    // Set the signal callback for Ctrl-C&lt;br /&gt;
    pSigPrev = signal( SIGINT, signal_handler );&lt;br /&gt;
    DBG( &amp;quot;Registered SIGINT signal handler.\n&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// button values&lt;br /&gt;
	int button = 16;&lt;br /&gt;
	int bButton = 1;&lt;br /&gt;
	int bValue = 0;&lt;br /&gt;
	button =  (bButton*32)+button;&lt;br /&gt;
	exportgpio(button);&lt;br /&gt;
&lt;br /&gt;
	//SET DIRECTION&lt;br /&gt;
	setdirection(button,1);	&lt;br /&gt;
	&lt;br /&gt;
//	printf(&amp;quot;ENTER&amp;quot;);&lt;br /&gt;
    while(1){&lt;br /&gt;
//	printf(&amp;quot;Button:%d&amp;quot;,bValue);&lt;br /&gt;
	bValue = gpioRead(button);&lt;br /&gt;
	if(bValue){&lt;br /&gt;
		printf(&amp;quot;Button Pushed&amp;quot;);&lt;br /&gt;
		//Grab the audio from the microphone while the button is pressed&lt;br /&gt;
		//audioThreadReturn = audio_thread_fxn( (void *) &amp;amp;audio_env, button);&lt;br /&gt;
		//runs a script that will take the raw file saved and encode it to mp3 useing lame and send via email.&lt;br /&gt;
 		system(&amp;quot;./../BeagleVNSScript&amp;quot;);&lt;br /&gt;
	}	&lt;br /&gt;
//	sleep(100);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import smtplib, os, sys&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
from PREFERENCES import *&lt;br /&gt;
&lt;br /&gt;
#def send_mail(send_files=&amp;quot;&amp;quot;):&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
    print sys.argv[1]&lt;br /&gt;
    send_to = SEND_TO&lt;br /&gt;
    files = sys.argv[1]&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = SEND_FROM&lt;br /&gt;
    subject = SUBJECT&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = MESSAGE&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=PASSWORD&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#if __name__ == '__main__':&lt;br /&gt;
#    send_mail()&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
# Web Interface to manage audio files&lt;br /&gt;
# Capture video along with audio&lt;br /&gt;
# Voice-To-Text&lt;br /&gt;
# Low Power Mode for longer battery life&lt;br /&gt;
# Authentication&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake &amp;lt;br&amp;gt; Want to discuss alsa limitations that prevented more advanced recording methods.&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ruff</id>
		<title>User:Ruff</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ruff"/>
				<updated>2012-11-08T16:49:51Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RuffHead}}&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNS.png|thumb|[[ECE497 Beagle VNS | Beagle VNS]]]]&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|thumb|Displaying gyroscopic sensor data with node.js]]&lt;br /&gt;
&lt;br /&gt;
*Ruffin White&lt;br /&gt;
*Electrical Engineering Major&lt;br /&gt;
*Robotics Minor&lt;br /&gt;
*Class of 2013.&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
&lt;br /&gt;
[[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497|Ur]]&lt;br /&gt;
&lt;br /&gt;
== Mini Pprojects ==&lt;br /&gt;
&lt;br /&gt;
Mini Project 1&lt;br /&gt;
&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
Mini Project 2&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
Mini Project 4&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro_Display]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/ruffsl/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
== How To ==&lt;br /&gt;
* none yet&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ruff</id>
		<title>User:Ruff</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ruff"/>
				<updated>2012-11-08T16:48:11Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RuffHead}}&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNS.png|thumb|[[ECE497 Beagle VNS | Beagle VNS]]]]&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|thumb|Displaying gyroscopic sensor data with node.js]]&lt;br /&gt;
&lt;br /&gt;
*Ruffin White&lt;br /&gt;
*Electrical Engineering Major&lt;br /&gt;
*Robotics Minor&lt;br /&gt;
*Class of 2013.&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
&lt;br /&gt;
[[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497 | Uw]]&lt;br /&gt;
&lt;br /&gt;
== Mini Pprojects ==&lt;br /&gt;
&lt;br /&gt;
Mini Project 1&lt;br /&gt;
&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
Mini Project 2&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
Mini Project 4&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro_Display]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/ruffsl/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
== How To ==&lt;br /&gt;
* none yet&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ruff</id>
		<title>User:Ruff</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ruff"/>
				<updated>2012-11-03T17:56:50Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RuffHead}}&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNS.png|thumb|[[ECE497 Beagle VNS | Beagle VNS]]]]&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|thumb|Displaying gyroscopic sensor data with node.js]]&lt;br /&gt;
&lt;br /&gt;
*Ruffin White&lt;br /&gt;
*Electrical Engineering Major&lt;br /&gt;
*Robotics Minor&lt;br /&gt;
*Class of 2013.&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
&lt;br /&gt;
[[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
== Mini Pprojects ==&lt;br /&gt;
&lt;br /&gt;
Mini Project 1&lt;br /&gt;
&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
Mini Project 2&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
Mini Project 4&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro_Display]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/ruffsl/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
== How To ==&lt;br /&gt;
* none yet&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ruff</id>
		<title>User:Ruff</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ruff"/>
				<updated>2012-11-03T17:56:15Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RuffHead}}&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|thumb|Displaying gyroscopic sensor data with node.js]]&lt;br /&gt;
&lt;br /&gt;
*Ruffin White&lt;br /&gt;
*Electrical Engineering Major&lt;br /&gt;
*Robotics Minor&lt;br /&gt;
*Class of 2013.&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
&lt;br /&gt;
[[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
== Mini Pprojects ==&lt;br /&gt;
&lt;br /&gt;
Mini Project 1&lt;br /&gt;
&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
Mini Project 2&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
Mini Project 4&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro_Display]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/ruffsl/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
== How To ==&lt;br /&gt;
* none yet&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-03T17:55:20Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''Angstrom A5 Image'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the camera drivers for the playstation eye you will need to install the A5 image on the beagle bone.  To do this you will need to download the A5 image.  Then you will need to install this image on the sd card of the BeagleBone using the instructions bases on [http://elinux.org/EBC_Exercise_03_Installing_a_Beagle_OS| ECE 497 Exercise 03 Installing a Beagle OS].&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.png|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:1,0 | aplay&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:2,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: A python mail client that prompts the user for information to send an email with optional attachments.&lt;br /&gt;
&lt;br /&gt;
  python smtp-mail-client-attachments.py&lt;br /&gt;
&lt;br /&gt;
  Send To (Separated by a comma): &lt;br /&gt;
  Files (Separated by a comma): &lt;br /&gt;
  Send From: beagle497@gmail.com #Must use this email for now&lt;br /&gt;
  Subject: &lt;br /&gt;
  Message:&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
'''1.''' Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''2.''' Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
'''3.''' Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
'''4.''' Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
:::Passing capture video on to Ruffin&lt;br /&gt;
'''5.''' Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
'''6.''' Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google vouice accounts&lt;br /&gt;
'''7.''' Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending&lt;br /&gt;
'''8.''' Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
'''9.''' Capture an image using GStreamer - Kevin &amp;amp; Tom&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''10.''' Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
'''11.''' Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::Making c file for initializing GPIOs, interrupts and start up scripts for VNS server&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import smtplib, os&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
&lt;br /&gt;
def send_mail():&lt;br /&gt;
    #This version promts the user to specify recipient, files,&lt;br /&gt;
    #subject, and message. The version for incorperating in the&lt;br /&gt;
    #notifier will need to read from a preferences file that &lt;br /&gt;
    #should be modifiable by the user.&lt;br /&gt;
&lt;br /&gt;
    send_to = raw_input(&amp;quot;Send To (Separated by a comma): &amp;quot;)&lt;br /&gt;
    files = raw_input(&amp;quot;Files (Separated by a comma): &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    #Make sure that we are working with a list&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = raw_input(&amp;quot;Send From: &amp;quot;)&lt;br /&gt;
    subject = raw_input(&amp;quot;Subject: &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    #Create a message object that we will be sending&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = raw_input(&amp;quot;Message: &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    #Attach files to message&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    #Open up a connection to the gmail servers on port 587&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=&amp;quot;beagleece497&amp;quot;&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    send_mail()&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/File:Belkin_N150_Micro_Wireless_USB_Adapter.png</id>
		<title>File:Belkin N150 Micro Wireless USB Adapter.png</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/File:Belkin_N150_Micro_Wireless_USB_Adapter.png"/>
				<updated>2012-11-03T17:54:32Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/File:PlayStation-Eye.png</id>
		<title>File:PlayStation-Eye.png</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/File:PlayStation-Eye.png"/>
				<updated>2012-11-03T17:52:43Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T15:22:49Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|320px|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.jpg|320px|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
::This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
::Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
::In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
::This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
::Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
::Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
::To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
::Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
::In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
::As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:1,0 | aplay&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:2,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: Instructions for this section are being developed.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
# Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
# Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google vouice accounts&lt;br /&gt;
# Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending, google is blocking attachments however&lt;br /&gt;
# Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
# Capture an image using GStreamer - Kevin &amp;amp; Tom&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::Making c file for initializing GPIOs, interrupts and start up scripts for VNS server&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import smtplib, os&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
&lt;br /&gt;
def send_mail():&lt;br /&gt;
&lt;br /&gt;
    send_to = raw_input(&amp;quot;Send To (Separated by a comma): &amp;quot;)&lt;br /&gt;
    files = raw_input(&amp;quot;Files (Separated by a comma): &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = raw_input(&amp;quot;Send From: &amp;quot;)&lt;br /&gt;
    subject = raw_input(&amp;quot;Subject: &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = raw_input(&amp;quot;Message: &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=&amp;quot;########&amp;quot;&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    send_mail()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T15:21:38Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Installation Instructions 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|320px|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.jpg|320px|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
:This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
:Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
:In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
: Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
:Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
: To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
: Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
: In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
: As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:1,0 | aplay&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:2,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: Instructions for this section are being developed.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
# Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
# Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google vouice accounts&lt;br /&gt;
# Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending, google is blocking attachments however&lt;br /&gt;
# Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
# Capture an image using GStreamer - Kevin &amp;amp; Tom&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::Making c file for initializing GPIOs, interrupts and start up scripts for VNS server&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import smtplib, os&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
&lt;br /&gt;
def send_mail():&lt;br /&gt;
&lt;br /&gt;
    send_to = raw_input(&amp;quot;Send To (Separated by a comma): &amp;quot;)&lt;br /&gt;
    files = raw_input(&amp;quot;Files (Separated by a comma): &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = raw_input(&amp;quot;Send From: &amp;quot;)&lt;br /&gt;
    subject = raw_input(&amp;quot;Subject: &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = raw_input(&amp;quot;Message: &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=&amp;quot;########&amp;quot;&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    send_mail()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T14:55:11Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Future Work */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 1 ==&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|320px|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.jpg|320px|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
:This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
:Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
:In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
: Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
:Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
: To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
: Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
: In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
: As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:1,0 | aplay&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:2,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: Instructions for this section are being developed.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
# Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
# Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google vouice accounts&lt;br /&gt;
# Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending, google is blocking attachments however&lt;br /&gt;
# Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
# Capture an image using GStreamer - Kevin &amp;amp; Tom&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::Making c file for initializing GPIOs, interrupts and start up scripts for VNS server&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import smtplib, os&lt;br /&gt;
#from getpass import getpass&lt;br /&gt;
from email.MIMEMultipart import MIMEMultipart&lt;br /&gt;
from email.MIMEBase import MIMEBase&lt;br /&gt;
from email.MIMEText import MIMEText&lt;br /&gt;
from email.Utils import COMMASPACE, formatdate&lt;br /&gt;
from email import Encoders&lt;br /&gt;
&lt;br /&gt;
def send_mail():&lt;br /&gt;
&lt;br /&gt;
    send_to = raw_input(&amp;quot;Send To (Separated by a comma): &amp;quot;)&lt;br /&gt;
    files = raw_input(&amp;quot;Files (Separated by a comma): &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    send_to=send_to.split(',')&lt;br /&gt;
    files=filter(None, files.split(','))&lt;br /&gt;
&lt;br /&gt;
    assert type(send_to)==list&lt;br /&gt;
    assert type(files)==list&lt;br /&gt;
&lt;br /&gt;
    send_from = raw_input(&amp;quot;Send From: &amp;quot;)&lt;br /&gt;
    subject = raw_input(&amp;quot;Subject: &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    msg = MIMEMultipart()&lt;br /&gt;
    msg['From'] = send_from&lt;br /&gt;
    msg['To'] = COMMASPACE.join(send_to)&lt;br /&gt;
    msg['Date'] = formatdate(localtime=True)&lt;br /&gt;
    msg['Subject'] = subject&lt;br /&gt;
&lt;br /&gt;
    text = raw_input(&amp;quot;Message: &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    msg.attach( MIMEText(text) )&lt;br /&gt;
&lt;br /&gt;
    for f in files:&lt;br /&gt;
        part = MIMEBase('application', &amp;quot;octet-stream&amp;quot;)&lt;br /&gt;
        part.set_payload( open(f,&amp;quot;rb&amp;quot;).read() )&lt;br /&gt;
        Encoders.encode_base64(part)&lt;br /&gt;
        part.add_header('Content-Disposition', 'attachment; filename=&amp;quot;%s&amp;quot;' % os.path.basename(f))&lt;br /&gt;
        msg.attach(part)&lt;br /&gt;
&lt;br /&gt;
    server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    server.starttls()&lt;br /&gt;
    server.ehlo()&lt;br /&gt;
    #password = getpass()&lt;br /&gt;
    password=&amp;quot;########&amp;quot;&lt;br /&gt;
    server.login(send_from, password)&lt;br /&gt;
    server.sendmail(send_from,&amp;quot;,&amp;quot;.join(send_to),msg.as_string())&lt;br /&gt;
    server.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    send_mail()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T05:29:54Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Parts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 1 ==&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|320px|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.jpg|320px|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
:This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
:Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
:In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
: Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
:Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
: To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
: Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
: In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
: As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:1,0 | aplay&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:2,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: Instructions for this section are being developed.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
# Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
# Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google vouice accounts&lt;br /&gt;
# Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending, google is blocking attachments however&lt;br /&gt;
# Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
# Capture an image using GStreamer - Kevin &amp;amp; Tom&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::Making c file for initializing GPIOs, interrupts and start up scripts for VNS server&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
[http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html PlayStation Eye]&lt;br /&gt;
&lt;br /&gt;
[http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]&lt;br /&gt;
&lt;br /&gt;
[http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger]&lt;br /&gt;
&lt;br /&gt;
[http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T05:26:41Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 1 ==&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|320px|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.jpg|320px|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
:This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
:Further BeagleBone documentation can be found on the official [http://beagleboard.org Beagle Board] website.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
:In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
: Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
:Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
: To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
: Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
: In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
: As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:1,0 | aplay&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:2,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: Instructions for this section are being developed.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
# Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
# Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google vouice accounts&lt;br /&gt;
# Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending, google is blocking attachments however&lt;br /&gt;
# Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
# Capture an image using GStreamer - Kevin &amp;amp; Tom&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::Making c file for initializing GPIOs, interrupts and start up scripts for VNS server&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T05:25:58Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Work Breakdown */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 1 ==&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|320px|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.jpg|320px|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
:This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
:Further BeagleBone documentation can be found on the official [ http://beagleboard.org Beagle Board ] website.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
:In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
: Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
:Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
: To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
: Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
: In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
: As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:1,0 | aplay&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:2,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: Instructions for this section are being developed.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
:::Page made and updated&lt;br /&gt;
# Get USB wireless to work - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is not working at this time for A6 image&lt;br /&gt;
# Get PlayStation Eye to work - Tom&lt;br /&gt;
:::Audio working, need to use A5 image&lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
:::Done&lt;br /&gt;
# Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
:::Google acound made, along with Gmail and Google vouice accounts&lt;br /&gt;
# Create an email script to send email with attachments - Tom&lt;br /&gt;
:::Email sending, google is blocking attachments however&lt;br /&gt;
# Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
:::Able to record on bone, use lame to convert file, and SCP to send to PC and listen to the recording&lt;br /&gt;
# Capture an image using GStreamer - Kevin &amp;amp; Tom&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin&lt;br /&gt;
:::This is still being developed&lt;br /&gt;
# Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin&lt;br /&gt;
:::Making c file for initializing GPIOs, interrupts and start up scripts for VNS server&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T05:14:02Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Installation Instructions 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 1 ==&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|320px|thumb|right|PlayStation Eye]]&lt;br /&gt;
[[File:Belkin_N150_Micro_Wireless_USB_Adapter.jpg|320px|thumb|right|Belkin N150 Micro Wireless USB Adapter]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
:This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
:Further BeagleBone documentation can be found on the official [ http://beagleboard.org Beagle Board ] website.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
:In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
: Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
:Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
: To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
: Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
: In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
: As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:1,0 | aplay&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:2,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: Instructions for this section are being developed.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
# Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
# Get USB wireless to work - Kevin &amp;amp; Ruffin     ''This is not working at this time.''&lt;br /&gt;
# Get PlayStation Eye to work - Tom &lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
# Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
# Create an email script to send email with attachments - Tom&lt;br /&gt;
# Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
# Capture an image using GStreamer - Kevin &amp;amp; Tom    ''This is still being developed''&lt;br /&gt;
# Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin     ''This is still being developed''&lt;br /&gt;
# Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin      ''This is still being developed''&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T05:09:41Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 1 ==&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 2 ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
[[File:BeagleBone_256x249.jpg|320px|thumb|right|BeagleBone]]&lt;br /&gt;
[[File:PlayStation-Eye.png|320px|thumb|right|PlayStation Eye]]&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
:This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
:Further BeagleBone documentation can be found on the official [ http://beagleboard.org Beagle Board ] website.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
:In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
: Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
:Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
: To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
: Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
: In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
: As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:1,0 | aplay&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:2,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: Instructions for this section are being developed.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
# Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
# Get USB wireless to work - Kevin &amp;amp; Ruffin     ''This is not working at this time.''&lt;br /&gt;
# Get PlayStation Eye to work - Tom &lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
# Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
# Create an email script to send email with attachments - Tom&lt;br /&gt;
# Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
# Capture an image using GStreamer - Kevin &amp;amp; Tom    ''This is still being developed''&lt;br /&gt;
# Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin     ''This is still being developed''&lt;br /&gt;
# Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin      ''This is still being developed''&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T04:58:19Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 1 ==&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
*'''github'''&lt;br /&gt;
&lt;br /&gt;
::In order to use the project code for the Beagle VNS, you will need github installed in order to download the code.  If you do not have github there are instruction on how to install it on the [[EBC Exercise 16 git |ECE Exercise 16]] web page.&lt;br /&gt;
&lt;br /&gt;
::To download the code for the Beagle VNS run the following code:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''git clone https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
*'''Python'''&lt;br /&gt;
&lt;br /&gt;
::Python is natively installed on the Beagle operating system.  However it is important to note that the program will be using a python script to send email.&lt;br /&gt;
&lt;br /&gt;
*'''ALSA'''&lt;br /&gt;
&lt;br /&gt;
::The project uses ALSA drivers in order to record audio from a microphone device.&lt;br /&gt;
&lt;br /&gt;
::In order to download the ALSA drivers you will need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install alsa-utils-aplay alsa-utils-amixer'''&lt;br /&gt;
&lt;br /&gt;
*'''Lame'''&lt;br /&gt;
&lt;br /&gt;
::Lame is a audio encoder that will take raw audio and convert it into an mp3 format.&lt;br /&gt;
&lt;br /&gt;
::To install the lame onto the beagle board you will need to run the following command.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''opkg install lame'''&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
::GStreamer is an application that allows the user to capture video from a camera for multiple types of solutions.  For this project, it is being used to capture an image of the person leaving a message.&lt;br /&gt;
&lt;br /&gt;
::Instructions to install GStreamer is still in the process of being developed.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 2 ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
:This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure to use the A5 image of Ångström as the A6 image is still buggy with respect to audio/video capturing, as well as using the USB WiFi drivers.&lt;br /&gt;
&lt;br /&gt;
:Further BeagleBone documentation can be found on the official [ http://beagleboard.org Beagle Board ] website.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [https://www.adafruit.com/products/513 here]  &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
:In this project tutorial, we will be using the [http://en.wikipedia.org/wiki/PlayStation_Eye  PlayStation Eye] as the audio and video source to recod messages and capture face images. The PlayStation Eye is very compatible with the A5 image of Ångström and used in many other Beagle embedded Linux projects.&lt;br /&gt;
&lt;br /&gt;
:This device can be found available [http://us.playstation.com/ps3/accessories/playstation-eye-camera-ps3.html here]  &lt;br /&gt;
&lt;br /&gt;
*Wifi dongle&lt;br /&gt;
&lt;br /&gt;
: Here we would like to use a WiFi dongle to easily connect to surrounding wireless networks for ease of installation and placement in the remote stretches of hallways and doorframes. We will need we will need network connectivity to transmit e-mails and recording attachments over to an available e-mail server account. In particularly we are using the [http://www.belkin.com/us/p/P-F7D1102 Belkin N150 Micro Wireless USB Adapter]. &lt;br /&gt;
&lt;br /&gt;
:Although this device is not natively supported with the stock A5 image of Ångström, a brief tutorial has already been made on how to compile and install the device drivers for this particular wireless USB adapter: [http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Belkin Micro Wi-Fi USB dongle on the BeagleBoard]&lt;br /&gt;
&lt;br /&gt;
*Battery Pack and USB Hub&lt;br /&gt;
&lt;br /&gt;
: To again better a ease installation and quick deployment for our system we are using a battery pack to provide power for the BeagleBone, the WiFi dongle and the USB camera. Due to the hottest limitations of the Beagle bones single USB port, in addition to the limited amount of current that the single USB port can provide, we will also use a USB hub with power adapter to solve both issues.&lt;br /&gt;
&lt;br /&gt;
: Specific products we are using included [http://www.duracell.com/en-US/product/instant-usb-charger.jspx  Duracell Instant USB Charger] and [http://www.radioshack.com/product/index.jsp?productId=2476717 Gigaware® USB 4-Port Hub]&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
: In order for the end user to trigger the recording sequence, we will implement a traditional mechanical momentary pushbutton that will connect to the BeagleBone’s GPIO using the enabled internal pull-up resistors.&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
: As a simple display, our project will utilize a simple LED as an indicator for the user that the audio is currently being recorded and that a face capture will be taken.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
*'''Basic Command Line Examples'''&lt;br /&gt;
&lt;br /&gt;
:: In order to give you a feel to how the program is capturing and sending emails.  Here is a short run down of how the program works&lt;br /&gt;
&lt;br /&gt;
:*'''Audio Capture'''&lt;br /&gt;
&lt;br /&gt;
::: In order to capture audio, the project uses arecord.  This application allows you to grab audio from a microphone that is attached to your device and save to the current directory in a raw format.  &lt;br /&gt;
&lt;br /&gt;
:::Here is an example command that allows you to record audio and then pipe the audio into aplay to instantaneously hear feedback:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:1,0 | aplay&lt;br /&gt;
&lt;br /&gt;
:::In order to encode the audio into mp3 format, you will need to pipe the audio into lame instead of aplay.&lt;br /&gt;
&lt;br /&gt;
:::Here is an example of this:&lt;br /&gt;
&lt;br /&gt;
 beagle$ arecord -D plughw:2,0 -r 16000 -f S16_LE -c 2 -t raw -d 3 | lame  -s 16 -r - blackbird.mp3&lt;br /&gt;
&lt;br /&gt;
::: For more information about ALSA and how to use many of its interesting features visit [http://www.lvr.com/access_usb_devices_from_linux.htm | Jan Axelson's Lakeview Research web page]&lt;br /&gt;
&lt;br /&gt;
:*'''Email Script'''&lt;br /&gt;
&lt;br /&gt;
::: Instructions for this section are being developed.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
# Set up project page - Tom &amp;amp; Kevin&lt;br /&gt;
# Get USB wireless to work - Kevin &amp;amp; Ruffin     ''This is not working at this time.''&lt;br /&gt;
# Get PlayStation Eye to work - Tom &lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack - Ruffin&lt;br /&gt;
# Register an email for the BeagleBoard - Ruffin&lt;br /&gt;
# Create an email script to send email with attachments - Tom&lt;br /&gt;
# Encode the raw audio from ALSA into mp3 format - Kevin&lt;br /&gt;
# Capture an image using GStreamer - Kevin &amp;amp; Tom    ''This is still being developed''&lt;br /&gt;
# Create a C program to capture the audio and listen for GPIO inputs - Kevin &amp;amp; Ruffin     ''This is still being developed''&lt;br /&gt;
# Putting all the pieces together - Tom, Kevin, &amp;amp; Ruffin      ''This is still being developed''&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Web Interface using HTML and NodeJS&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T03:55:58Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Installation Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
At this time, we have a method for capturing audio for a specified amount of time and encoding that recording into a mp3 file.  We also have python script that allows the user to send email messages to another email by running a script.  We also have a working external power source for the beagle.&lt;br /&gt;
&lt;br /&gt;
The wireless usb adapter does not work at this time.  We are still trying to get recompile the kernel to install and enable the driver for this wireless adapter.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall we are looking at creating a c program that will record the audio while the button is being pressed.  Once the button has been released the program will encode the raw audio into mp3 format, and then attach it via an email and send it to the owner of the Beagle VNS system.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 1 ==&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
*github&lt;br /&gt;
&lt;br /&gt;
*Python&lt;br /&gt;
&lt;br /&gt;
*GCC&lt;br /&gt;
&lt;br /&gt;
*ALSA&lt;br /&gt;
&lt;br /&gt;
*Lame&lt;br /&gt;
&lt;br /&gt;
*GStreamer&lt;br /&gt;
&lt;br /&gt;
*Email&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions 2 ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
*BeagleBone&lt;br /&gt;
&lt;br /&gt;
This project is design primarily for the BeagleBone, but could be implemented on any other Beagle Board given the proper driver installation for the USB hardware and available GPIOs. The BeagleBone is applicable for this project due to is small size, low power consumption, and networking capabilities. Make sure &lt;br /&gt;
&lt;br /&gt;
*Camera&lt;br /&gt;
&lt;br /&gt;
*Wifi Dongle&lt;br /&gt;
&lt;br /&gt;
*Battery Pack&lt;br /&gt;
&lt;br /&gt;
*Doorbell&lt;br /&gt;
&lt;br /&gt;
*LED&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
Once everything is installed, how do you use the program?  Give details here, so if you have a long user manual, link to it here.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
# Set up project page - Tom&amp;amp;Kevin&lt;br /&gt;
# Get USB wireless to work&lt;br /&gt;
# Get PlayStation Eye to work&lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack&lt;br /&gt;
# Register an email for the BeagleBoard&lt;br /&gt;
# Program stuff....&lt;br /&gt;
# Build stuff......&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Flame decals&lt;br /&gt;
# Spoiler&lt;br /&gt;
# Bigger Engine&lt;br /&gt;
# Sentient&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T03:24:30Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff | Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
Nothing&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
All of it&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
We will probably learn things&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
Once everything is installed, how do you use the program?  Give details here, so if you have a long user manual, link to it here.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
# Set up project page - Tom&amp;amp;Kevin&lt;br /&gt;
# Get USB wireless to work&lt;br /&gt;
# Get PlayStation Eye to work&lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack&lt;br /&gt;
# Register an email for the BeagleBoard&lt;br /&gt;
# Program stuff....&lt;br /&gt;
# Build stuff......&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Flame decals&lt;br /&gt;
# Spoiler&lt;br /&gt;
# Bigger Engine&lt;br /&gt;
# Sentient&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Template:BeagleVNSHead</id>
		<title>Template:BeagleVNSHead</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Template:BeagleVNSHead"/>
				<updated>2012-11-02T03:23:25Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: Created page with &amp;quot;thumb‎ '''Embedded Linux Class''' [http://Rose-Hulman.edu ''RHIT'']  by  Tom Atnip,  Kevin Geisler, [[User...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:RoseLogo96.png|150px|thumb‎]] '''Embedded Linux Class''' [http://Rose-Hulman.edu ''RHIT'']&lt;br /&gt;
&lt;br /&gt;
by [[User:atniptw | Tom Atnip]], [[User:Geislekj | Kevin Geisler]], [[User:ruff | Ruffin White]]&lt;br /&gt;
&amp;lt;!-- This is a comment --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This is a comment --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Template:BeagleVNSFoot</id>
		<title>Template:BeagleVNSFoot</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Template:BeagleVNSFoot"/>
				<updated>2012-11-02T03:22:07Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- This is a comment --&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[File:RoseLogo96.png|150px|thumb‎]] '''Embedded Linux Class''' [http://Rose-Hulman.edu ''RHIT'']&lt;br /&gt;
&lt;br /&gt;
by [[User:atniptw | Tom Atnip]], [[User:Geislekj | Kevin Geisler]], [[User:ruff | Ruffin White]]&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Template:BeagleVNSFoot</id>
		<title>Template:BeagleVNSFoot</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Template:BeagleVNSFoot"/>
				<updated>2012-11-02T03:19:51Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: Created page with &amp;quot;&amp;lt;!-- This is a comment --&amp;gt; ----   thumb‎ '''Embedded Linux Class'''  Tom Atnip  Kevin Geisler [[User:ruff ...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- This is a comment --&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:RoseLogo96.png|150px|thumb‎]] '''Embedded Linux Class''' [[User:atniptw | Tom Atnip]] [[User:Geislekj | Kevin Geisler]] [[User:ruff | Ruffin White]]  [http://Rose-Hulman.edu ''RHIT'']&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Beagle_VNS</id>
		<title>ECE497 Beagle VNS</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Beagle_VNS"/>
				<updated>2012-11-02T03:16:52Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{BeagleVNSHead}}&lt;br /&gt;
[[File:BeagleVNS.png|thumb|]]&lt;br /&gt;
&lt;br /&gt;
Team members:[[User:atniptw | Tom Atnip]],[[User:Geislekj | Kevin Geisler]],[[user:Ruff|Ruffin White]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:WhereIsYoder.png|thumb|Where is Dr. Yoder?]]&lt;br /&gt;
[[File:WhereIsYoder2.png|thumb|I'll leave him a message]]&lt;br /&gt;
&lt;br /&gt;
We wanted a way for students to be able to leave audio (and possibly video) messages for professors when they are out of their office. Using a BeagleBoard Bone, we plan to connect a wireless USB device and a PlayStation Eye to achieve this. Students will be able to walk up to the device and press a button to record their message which will then be available for the professor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
Nothing&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
All of it&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
We will probably learn things&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
Once everything is installed, how do you use the program?  Give details here, so if you have a long user manual, link to it here.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
List the major tasks in your project and who did what.&lt;br /&gt;
&lt;br /&gt;
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Acquire Hardware - Ruffin&lt;br /&gt;
# Set up project page - Tom&amp;amp;Kevin&lt;br /&gt;
# Get USB wireless to work&lt;br /&gt;
# Get PlayStation Eye to work&lt;br /&gt;
# Get BeagleBoard Bone to run off a battery pack&lt;br /&gt;
# Register an email for the BeagleBoard&lt;br /&gt;
# Program stuff....&lt;br /&gt;
# Build stuff......&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
# Flame decals&lt;br /&gt;
# Spoiler&lt;br /&gt;
# Bigger Engine&lt;br /&gt;
# Sentient&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
[http://beagleboard.org/bone Beagle Bone]&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&amp;lt;br&amp;gt; Need More Cake&lt;br /&gt;
&lt;br /&gt;
{{BeagleVNSFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ruff</id>
		<title>User:Ruff</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ruff"/>
				<updated>2012-11-02T03:13:52Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RuffHead}}&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|thumb|Displaying gyroscopic sensor data with node.js]]&lt;br /&gt;
&lt;br /&gt;
*Ruffin White&lt;br /&gt;
*Electrical Engineering Major&lt;br /&gt;
*Robotics Minor&lt;br /&gt;
*Class of 2013.&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
&lt;br /&gt;
[[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
== Mini Pprojects ==&lt;br /&gt;
&lt;br /&gt;
Mini Project 1&lt;br /&gt;
&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
Mini Project 2&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
Mini Project 4&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro_Display]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/ruffsl/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
== How To ==&lt;br /&gt;
* none yet&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/SparkFun:_ITG-3200,Triple-Axis_Gyro_Display</id>
		<title>SparkFun: ITG-3200,Triple-Axis Gyro Display</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/SparkFun:_ITG-3200,Triple-Axis_Gyro_Display"/>
				<updated>2012-10-24T16:27:37Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Node.js Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
{{RuffHead}}&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This project show how the ITG-3200, a three-axis gyro sensor, can read and displayed using the beagle bone, a web browser and node.js. This project expands upon what was documented in [[SparkFun:_ITG-3200,Triple-Axis_Gyro]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone2.jpg|thumb|ITG-3200 breakout board pin-out]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo1.png|thumb|Here's the first display screen you will see after entering the bones web address, go ahead and click on the Button Dox Demo link]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|thumb|left|Once the script is up and running you will begin to see the sensor data rendered across the time axis plots with regards to each rotational direction of the gyroscope as well as its internal temperature]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The goal here is to add a web-based graphical display to the gyroscopic sensor. Using examples of node.js servers that display realtime data from the beagle, I have altered the example code to display specifically the three axes of rotation for the gyroscope as well as in addition the internal temperature of the sensor itself.&lt;br /&gt;
&lt;br /&gt;
; buttonBox.js, buttonBox.html&lt;br /&gt;
: This is a bone-based example that reads a gpio port, analog in and an i2c device and displays the output in a web browser.These will be there two main files that will contain many of my alterations.&lt;br /&gt;
&lt;br /&gt;
== Running the code ==&lt;br /&gt;
First off, you'll need to download the code through the get hub repository onto a local directory within your Beagle bone. You will then need to navigate to:&lt;br /&gt;
 beagle$ '''cd ~/MiniProject04/node.js/realtime'''&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install nodejs'''  (Don't install '''node''', it's not what you think.)&lt;br /&gt;
&lt;br /&gt;
On the Bone:&lt;br /&gt;
 beagle$ '''node buttonBox.js'''&lt;br /&gt;
&lt;br /&gt;
Simply press ‘CTRL’ + ‘C’ to quit the program.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Bone===&lt;br /&gt;
&lt;br /&gt;
Then point a browser to '''beaglebone.local:8081'''.  The default port is 8081.  You can change it if you like.&lt;br /&gt;
&lt;br /&gt;
== How it works ==&lt;br /&gt;
&lt;br /&gt;
The prior examples included the script within the HTML file that polled the server continuously for data updates. However I have altered the code within the HTML file as well as the .js file to allow the server to be so fully responsible for pushing the data to the client.&lt;br /&gt;
&lt;br /&gt;
Another alteration I have made is to alter the I2C function that is called to acquisition the sensor data. Using the source code within mini project two, I have made a stripped-down version that simply returns all the relevant registers within the sensor. This is interpreted as a string within the server's .js file and is streamed to the client browser where the script parses the relevant information to each specific axis and temperature variable. This is then plotted on the grass and rendered on-screen over time.&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGPIO.png|thumb|This setup is accurate for the Sample Code up to the point about the brackeout board pinout. Just adjust the pin to the ITG-3200 accordingly to by description below. See [[EBC Exercise 12 I2C]] for more detail]]&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Node.js Code ===&lt;br /&gt;
&lt;br /&gt;
The code shown below is part sample code to demonstrate reading the registers via I2C and displaying the data with node.js. The alteration that has been made is to specify a timeout period for the server, as well as an additional function that will execute the terminal commands required to poll the gyroscopic sensor in return its register values. The code will also zero out the gyro to account for the internal bias the gyro might have just being stationary and level.&lt;br /&gt;
&lt;br /&gt;
One alteration you'll need to make is to change the path the exec function with in the pushMessage function calls the custom c program to read the I2C buss. Just change the path to point to the excusable you compile with gcc using available MiniProject02.c file within the same directory as the HTML and node.js files, all the necessary header files are included as well.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// From Getting Started With node.js and socket.io &lt;br /&gt;
// http://codehenge.net/blog/2011/12/getting-started-with-node-js-and-socket-io-v0-7-part-2/&lt;br /&gt;
&amp;quot;use strict&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
var http = require('http'),&lt;br /&gt;
    url = require('url'),&lt;br /&gt;
    fs = require('fs'),&lt;br /&gt;
    exec = require('child_process').exec,&lt;br /&gt;
    server,&lt;br /&gt;
    connectCount = 0;	// Number of connections to server&lt;br /&gt;
&lt;br /&gt;
server = http.createServer(function (req, res) {&lt;br /&gt;
// server code&lt;br /&gt;
    var path = url.parse(req.url).pathname;&lt;br /&gt;
    console.log(&amp;quot;path: &amp;quot; + path);&lt;br /&gt;
    switch (path) {&lt;br /&gt;
    case '/':&lt;br /&gt;
        res.writeHead(200, {'Content-Type': 'text/html'});&lt;br /&gt;
        res.write('&amp;lt;h1&amp;gt;Hello!&amp;lt;/h1&amp;gt;Try&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;/buttonBox.html&amp;quot;&amp;gt;Button Box Demo&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;');&lt;br /&gt;
&lt;br /&gt;
        res.end();&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    default:		// This is so all the files will be sent.&lt;br /&gt;
        fs.readFile(__dirname + path, function (err, data) {&lt;br /&gt;
            if (err) {return send404(res); }&lt;br /&gt;
//            console.log(&amp;quot;path2: &amp;quot; + path);&lt;br /&gt;
            res.write(data, 'utf8');&lt;br /&gt;
            res.end();&lt;br /&gt;
        });&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
var send404 = function (res) {&lt;br /&gt;
    res.writeHead(404);&lt;br /&gt;
    res.write('404');&lt;br /&gt;
    res.end();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
server.listen(8081);&lt;br /&gt;
&lt;br /&gt;
// socket.io, I choose you&lt;br /&gt;
var io = require('socket.io').listen(server);&lt;br /&gt;
io.set('log level', 2);&lt;br /&gt;
&lt;br /&gt;
// on a 'connection' event&lt;br /&gt;
io.sockets.on('connection', function (socket) {&lt;br /&gt;
    var frameCount = 0;	// Counts the frames from arecord&lt;br /&gt;
    var lastFrame = 0;	// Last frame sent to browser&lt;br /&gt;
    console.log(&amp;quot;Connection &amp;quot; + socket.id + &amp;quot; accepted.&amp;quot;);&lt;br /&gt;
//    console.log(&amp;quot;socket: &amp;quot; + socket);&lt;br /&gt;
&lt;br /&gt;
    // now that we have our connected 'socket' object, we can &lt;br /&gt;
    // define its event handlers&lt;br /&gt;
&lt;br /&gt;
    // Make sure some needed files are there&lt;br /&gt;
    // The path to the analog devices changed from A5 to A6.  Check both.&lt;br /&gt;
    var ainPath = &amp;quot;/sys/devices/platform/omap/tsc/&amp;quot;;&lt;br /&gt;
//    if(!fs.existsSync(ainPath)) {&lt;br /&gt;
//        ainPath = &amp;quot;/sys/devices/platform/tsc/&amp;quot;;&lt;br /&gt;
//        if(!fs.existsSync(ainPath)) {&lt;br /&gt;
//            throw &amp;quot;Can't find &amp;quot; + ainPath;&lt;br /&gt;
//        }&lt;br /&gt;
//    }&lt;br /&gt;
    // Make sure gpio 7 is available.&lt;br /&gt;
    exec(&amp;quot;echo 7 &amp;gt; /sys/class/gpio/export&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    // Send value every time a 'message' is received.&lt;br /&gt;
    socket.on('ain', function (ainNum) {&lt;br /&gt;
//        var ainPath = &amp;quot;/sys/devices/platform/omap/tsc/ain&amp;quot; + ainNum;&lt;br /&gt;
        fs.readFile(ainPath + &amp;quot;ain&amp;quot; + ainNum, 'base64', function(err, data) {&lt;br /&gt;
            if(err) throw err;&lt;br /&gt;
            socket.emit('ain', data);&lt;br /&gt;
//            console.log('emitted ain: ' + data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('gpio', function (gpioNum) {&lt;br /&gt;
        var gpioPath = &amp;quot;/sys/class/gpio/gpio&amp;quot; + gpioNum + &amp;quot;/value&amp;quot;;&lt;br /&gt;
        fs.readFile(gpioPath, 'base64', function(err, data) {&lt;br /&gt;
            if (err) throw err;&lt;br /&gt;
            socket.emit('gpio', data);&lt;br /&gt;
//            console.log('emitted gpio: ' + data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('i2c', function (i2cNum) {&lt;br /&gt;
//        console.log('Got i2c request:' + i2cNum);&lt;br /&gt;
        exec('i2cget -y 3 ' + i2cNum + ' 0 w',&lt;br /&gt;
            function (error, stdout, stderr) {&lt;br /&gt;
//		The TMP102 returns a 12 bit value with the digits swapped&lt;br /&gt;
                stdout = '0x' + stdout.substring(4,6) + stdout.substring(2,4);&lt;br /&gt;
//                console.log('i2cget: &amp;quot;' + stdout + '&amp;quot;');&lt;br /&gt;
                if(error) { console.log('error: ' + error); }&lt;br /&gt;
                if(stderr) {console.log('stderr: ' + stderr); }&lt;br /&gt;
                socket.emit('i2c', stdout);&lt;br /&gt;
            });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('led', function (ledNum) {&lt;br /&gt;
        var ledPath = &amp;quot;/sys/class/leds/beaglebone::usr&amp;quot; + ledNum + &amp;quot;/brightness&amp;quot;;&lt;br /&gt;
//        console.log('LED: ' + ledPath);&lt;br /&gt;
        fs.readFile(ledPath, 'utf8', function (err, data) {&lt;br /&gt;
            if(err) throw err;&lt;br /&gt;
            data = data.substring(0,1) === &amp;quot;1&amp;quot; ? &amp;quot;0&amp;quot; : &amp;quot;1&amp;quot;;&lt;br /&gt;
//            console.log(&amp;quot;LED%d: %s&amp;quot;, ledNum, data);&lt;br /&gt;
            fs.writeFile(ledPath, data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
   var updateInterval = 100;&lt;br /&gt;
   function pushMessage() {&lt;br /&gt;
//        console.log('Got i2c request:' + 6);&lt;br /&gt;
        exec('/home/root/ECE497/MiniProject04/node.js/realtime/./a.out 0 0 ' + 3,&lt;br /&gt;
            function (error, stdout, stderr) {&lt;br /&gt;
		console.log('stdout:' + stdout);&lt;br /&gt;
		//console.log('stdout:' + parseFloat(stdout.substring(51,58))/100.0);&lt;br /&gt;
                if(error) { console.log('error: ' + error); }&lt;br /&gt;
                if(stderr) {console.log('stderr: ' + stderr); }&lt;br /&gt;
                socket.emit('i2c', stdout);&lt;br /&gt;
            });&lt;br /&gt;
        setTimeout(pushMessage, updateInterval);&lt;br /&gt;
    }&lt;br /&gt;
    pushMessage();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    socket.on('disconnect', function () {&lt;br /&gt;
        console.log(&amp;quot;Connection &amp;quot; + socket.id + &amp;quot; terminated.&amp;quot;);&lt;br /&gt;
        connectCount--;&lt;br /&gt;
        if(connectCount === 0) {&lt;br /&gt;
        }&lt;br /&gt;
        console.log(&amp;quot;connectCount = &amp;quot; + connectCount);&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    connectCount++;&lt;br /&gt;
    console.log(&amp;quot;connectCount = &amp;quot; + connectCount);&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== HTML Code ===&lt;br /&gt;
&lt;br /&gt;
This file is altered from example code and contains all the necessary formatting for the user interface and data representation. A also contains the script necessary to parse the string containing the sensor data sent by the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!doctype html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;Gyro Demo&amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;script src=&amp;quot;/json.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;!-- for ie --&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;/socket.io/socket.io.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;link href=&amp;quot;layout.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.flot.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.flot.navigate.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;h1&amp;gt;Gyro Demo &amp;lt;a href=&amp;quot;http://Rose-Hulman.edu&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;RoseLogo96.png&amp;quot; width=200 style=&amp;quot;float:right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
    &amp;lt;button id=&amp;quot;connect&amp;quot; onClick='connect()'/&amp;gt;Connect&amp;lt;/button&amp;gt;&lt;br /&gt;
    &amp;lt;button id=&amp;quot;disconnect&amp;quot; onClick='disconnect()'&amp;gt;Disconnect&amp;lt;/button&amp;gt;&lt;br /&gt;
    &amp;lt;span style=&amp;quot;position:relative; left:150px&amp;quot;&amp;gt;&lt;br /&gt;
    Analog: &amp;lt;input id=&amp;quot;ainNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:2em&amp;quot;&amp;gt;&lt;br /&gt;
    gpio: &amp;lt;input id=&amp;quot;gpioNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:2em&amp;quot;&amp;gt;&lt;br /&gt;
    i2c: &amp;lt;input id=&amp;quot;i2cNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;!--    &amp;lt;button id=&amp;quot;send&amp;quot; onClick='send()'/&amp;gt;Send Message&amp;lt;/button&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td&amp;gt;&amp;lt;div id=&amp;quot;plotTop&amp;quot; style=&amp;quot;width:550px;height:300px;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;samples&amp;lt;/center&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
    Update: &amp;lt;input id=&amp;quot;updateTopInterval&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt; ms&lt;br /&gt;
    &amp;lt;button id=&amp;quot;zoomout&amp;quot; onClick='plotTop.zoomOut()'&amp;gt;Zoom Out&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td&amp;gt;&amp;lt;div id=&amp;quot;plotBot&amp;quot; style=&amp;quot;width:550px;height:300px;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;samples&amp;lt;/center&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
    Update: &amp;lt;input id=&amp;quot;updateBotInterval&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt; ms&lt;br /&gt;
    &amp;lt;button id=&amp;quot;zoomout&amp;quot; onClick='plotBot.zoomOut()'&amp;gt;Zoom Out&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led0&amp;quot; onClick='led(0)'/&amp;gt;LED 0&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led1&amp;quot; onClick='led(1)'/&amp;gt;LED 1&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led2&amp;quot; onClick='led(2)'/&amp;gt;LED 2&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led3&amp;quot; onClick='led(3)'/&amp;gt;LED 3&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Button Box demo from the &amp;lt;a href=&amp;quot;http://elinux.org/index.php?title=Category:ECE497&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;32-bit Embedded Linux Class&amp;lt;/a&amp;gt;.&amp;lt;/b&amp;gt;&lt;br /&gt;
In this demo, the beagle bone pushes it sensor data to the web browser. Try moving the gyro or touching it to change its temprature. Try double-clicking to zoom and click and dragging to pan.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;a href=&amp;quot;http://beagleboard.org&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;beagle-hd-logo.gif&amp;quot; width=200 align=&amp;quot;right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;p id=&amp;quot;status&amp;quot;&amp;gt;Waiting for input&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;a href=&amp;quot;http://www.ti.com/sitara&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;hdr_ti_logo.gif&amp;quot; width=200 align=&amp;quot;right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;p id=&amp;quot;message&amp;quot;&amp;gt;message&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt; &lt;br /&gt;
By &amp;lt;i&amp;gt;Ruffin White&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    var socket;&lt;br /&gt;
    var firstconnect = true,&lt;br /&gt;
        fs = 8000,&lt;br /&gt;
        Ts = 1/fs*1000,&lt;br /&gt;
        samples = 100,&lt;br /&gt;
        plotTop,&lt;br /&gt;
        plotBot,&lt;br /&gt;
        ainData = [],  iain = 0, &lt;br /&gt;
        gpioData = [], igpio = 0,&lt;br /&gt;
        i2cXData = [],  ii2cX = 0,&lt;br /&gt;
        i2cYData = [],  ii2cY = 0,&lt;br /&gt;
        i2cZData = [],  ii2cZ = 0,&lt;br /&gt;
        i2cTData = [],  ii2cT = 0,&lt;br /&gt;
        gpioNum = 7,&lt;br /&gt;
        ainNum  = 6,&lt;br /&gt;
        i2cNum  = &amp;quot;0x48&amp;quot;;&lt;br /&gt;
    ainData[samples] = 0;&lt;br /&gt;
    gpioData[samples] = 0;&lt;br /&gt;
    i2cXData[samples] = 0;&lt;br /&gt;
    i2cYData[samples] = 0;&lt;br /&gt;
    i2cZData[samples] = 0;&lt;br /&gt;
    i2cTData[samples] = 0;&lt;br /&gt;
&lt;br /&gt;
    function connect() {&lt;br /&gt;
      if(firstconnect) {&lt;br /&gt;
        socket = io.connect(null);&lt;br /&gt;
&lt;br /&gt;
        socket.on('message', function(data)&lt;br /&gt;
            { status_update(&amp;quot;Received: message&amp;quot;);});&lt;br /&gt;
        socket.on('connect', function()&lt;br /&gt;
            { status_update(&amp;quot;Connected to Server&amp;quot;); });&lt;br /&gt;
        socket.on('disconnect', function()&lt;br /&gt;
            { status_update(&amp;quot;Disconnected from Server&amp;quot;); });&lt;br /&gt;
        socket.on('reconnect', function()&lt;br /&gt;
            { status_update(&amp;quot;Reconnected to Server&amp;quot;); });&lt;br /&gt;
        socket.on('reconnecting', function( nextRetry )&lt;br /&gt;
            { status_update(&amp;quot;Reconnecting in &amp;quot; + nextRetry/1000 + &amp;quot; s&amp;quot;); });&lt;br /&gt;
        socket.on('reconnect_failed', function()&lt;br /&gt;
            { message(&amp;quot;Reconnect Failed&amp;quot;); });&lt;br /&gt;
&lt;br /&gt;
        socket.on('ain',  ain);&lt;br /&gt;
        socket.on('gpio', gpio);&lt;br /&gt;
        socket.on('i2c',  i2c);&lt;br /&gt;
&lt;br /&gt;
        firstconnect = false;&lt;br /&gt;
      }&lt;br /&gt;
      else {&lt;br /&gt;
        socket.socket.reconnect();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function disconnect() {&lt;br /&gt;
      socket.disconnect();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function led(ledNum) {&lt;br /&gt;
        socket.emit('led', ledNum);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // When new data arrived, convert it and plot it.&lt;br /&gt;
    function ain(data) {&lt;br /&gt;
        data = atob(data)/4096 * 1.8;&lt;br /&gt;
        data = isNaN(data) ? 0 : data;&lt;br /&gt;
//        status_update(&amp;quot;ain: &amp;quot; + data);&lt;br /&gt;
        ainData[iain] = [iain, data];&lt;br /&gt;
        iain++;&lt;br /&gt;
        if(iain &amp;gt;= samples) {&lt;br /&gt;
            iain = 0;&lt;br /&gt;
            ainData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotTop.setData([ ainData, gpioData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function gpio(data) {&lt;br /&gt;
        data = atob(data);&lt;br /&gt;
//        status_update(&amp;quot;gpio: &amp;quot; + data);&lt;br /&gt;
        gpioData[igpio] = [igpio, data];&lt;br /&gt;
        igpio++;&lt;br /&gt;
        if(igpio &amp;gt;= samples) {&lt;br /&gt;
            igpio = 0;&lt;br /&gt;
            gpioData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotTop.setData([ ainData, gpioData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
//gyroX: -00026 gyroY: -00012 gyroZ: 000073 gyroTemp: 002602&lt;br /&gt;
&lt;br /&gt;
    function i2c(data) {&lt;br /&gt;
        Xdata = parseInt(data.substring(6,12));&lt;br /&gt;
        Ydata = parseInt(data.substring(20,26));&lt;br /&gt;
        Zdata = parseInt(data.substring(34,40));&lt;br /&gt;
        Tdata = parseInt(data.substring(51,56));&lt;br /&gt;
        i2cXData[ii2cX] = [ii2cX, Xdata];&lt;br /&gt;
        i2cYData[ii2cY] = [ii2cY, Ydata];&lt;br /&gt;
        i2cZData[ii2cZ] = [ii2cZ, Zdata];&lt;br /&gt;
        i2cTData[ii2cT] = [ii2cT, Tdata];&lt;br /&gt;
        ii2cX++;&lt;br /&gt;
        if(ii2cX &amp;gt;= samples) {&lt;br /&gt;
            ii2cX = 0;&lt;br /&gt;
            i2cXData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cY] = [ii2cY, Xdata];&lt;br /&gt;
        ii2cY++;&lt;br /&gt;
        if(ii2cY &amp;gt;= samples) {&lt;br /&gt;
            ii2cY = 0;&lt;br /&gt;
            i2cYData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cZ] = [ii2cZ, Xdata];&lt;br /&gt;
        ii2cZ++;&lt;br /&gt;
        if(ii2cZ &amp;gt;= samples) {&lt;br /&gt;
            ii2cZ = 0;&lt;br /&gt;
            i2cZData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cT] = [ii2cT, Xdata];&lt;br /&gt;
        ii2cT++;&lt;br /&gt;
        if(ii2cT &amp;gt;= samples) {&lt;br /&gt;
            ii2cT = 0;&lt;br /&gt;
            i2cTData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotBot.setData([ i2cXData, i2cYData, i2cZData]);&lt;br /&gt;
        plotBot.draw();&lt;br /&gt;
        plotTop.setData([ i2cTData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function status_update(txt){&lt;br /&gt;
      document.getElementById('status').innerHTML = txt;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function send(){&lt;br /&gt;
      socket.emit(&amp;quot;ain&amp;quot;, &amp;quot;Hello Server!&amp;quot;);    &lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    connect();&lt;br /&gt;
&lt;br /&gt;
$(function () {&lt;br /&gt;
&lt;br /&gt;
    function initPlotData() {&lt;br /&gt;
        // zip the generated y values with the x values&lt;br /&gt;
        var result = [];&lt;br /&gt;
        for (var i = 0; i &amp;lt;= samples; i++)&lt;br /&gt;
            result[i] = [i, 0];&lt;br /&gt;
        return result;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // setup control widget&lt;br /&gt;
    $(&amp;quot;#ainNum&amp;quot;).val(ainNum).change(function () {&lt;br /&gt;
        ainNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    $(&amp;quot;#gpioNum&amp;quot;).val(gpioNum).change(function () {&lt;br /&gt;
        gpioNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    $(&amp;quot;#i2cNum&amp;quot;).val(i2cNum).change(function () {&lt;br /&gt;
        i2cNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    var updateTopInterval = 100;&lt;br /&gt;
    $(&amp;quot;#updateTopInterval&amp;quot;).val(updateTopInterval).change(function () {&lt;br /&gt;
        var v = $(this).val();&lt;br /&gt;
        if (v &amp;amp;&amp;amp; !isNaN(+v)) {&lt;br /&gt;
            updateTopInterval = +v;&lt;br /&gt;
            if (updateTopInterval &amp;lt; 25)&lt;br /&gt;
                updateTopInterval = 25;&lt;br /&gt;
            if (updateTopInterval &amp;gt; 2000)&lt;br /&gt;
                updateTopInterval = 2000;&lt;br /&gt;
            $(this).val(&amp;quot;&amp;quot; + updateTopInterval);&lt;br /&gt;
        }&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    var updateBotInterval = 100;&lt;br /&gt;
    $(&amp;quot;#updateBotInterval&amp;quot;).val(updateBotInterval).change(function () {&lt;br /&gt;
        var v = $(this).val();&lt;br /&gt;
        if (v &amp;amp;&amp;amp; !isNaN(+v)) {&lt;br /&gt;
            updateBotInterval = +v;&lt;br /&gt;
            if (updateBotInterval &amp;lt; 25)&lt;br /&gt;
                updateBotInterval = 25;&lt;br /&gt;
            if (updateBotInterval &amp;gt; 2000)&lt;br /&gt;
                updateBotInterval = 2000;&lt;br /&gt;
            $(this).val(&amp;quot;&amp;quot; + updateBotInterval);&lt;br /&gt;
        }&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    // setup plot&lt;br /&gt;
    var optionsTop = {&lt;br /&gt;
        series: { &lt;br /&gt;
            shadowSize: 0, // drawing is faster without shadows&lt;br /&gt;
            points: { show: false},&lt;br /&gt;
            lines:  { show: true, lineWidth: 5},&lt;br /&gt;
        }, &lt;br /&gt;
        yaxis:	{ min: 10, max: 35, &lt;br /&gt;
                  zoomRange: [10, 256], panRange: [-128, 128] },&lt;br /&gt;
        xaxis:	{ show: true, &lt;br /&gt;
                  zoomRange: [10, 100], panRange: [0, 100] },&lt;br /&gt;
        legend:	{ position: &amp;quot;sw&amp;quot; },&lt;br /&gt;
        zoom:	{ interactive: true, amount: 1.1 },&lt;br /&gt;
        pan:	{ interactive: true }&lt;br /&gt;
    };&lt;br /&gt;
    plotTop = $.plot($(&amp;quot;#plotTop&amp;quot;), &lt;br /&gt;
        [ &lt;br /&gt;
          { data:  initPlotData(), &lt;br /&gt;
            label: &amp;quot;GyroTemp&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
            optionsTop);&lt;br /&gt;
&lt;br /&gt;
    var optionsBot = {&lt;br /&gt;
        series: { &lt;br /&gt;
            shadowSize: 0, // drawing is faster without shadows&lt;br /&gt;
            points: { show: false},&lt;br /&gt;
            lines:  { show: true, lineWidth: 5},&lt;br /&gt;
            //color: 2&lt;br /&gt;
        }, &lt;br /&gt;
        yaxis:	{ min: -100, max: 100, &lt;br /&gt;
                  zoomRange: [10, 256], panRange: [60, 100] },&lt;br /&gt;
        xaxis:	{ show: true, &lt;br /&gt;
                  zoomRange: [10, 100], panRange: [0, 100] },&lt;br /&gt;
        legend:	{ position: &amp;quot;sw&amp;quot; },&lt;br /&gt;
        zoom:	{ interactive: true, amount: 1.1 },&lt;br /&gt;
        pan:	{ interactive: true }&lt;br /&gt;
    };&lt;br /&gt;
    plotBot = $.plot($(&amp;quot;#plotBot&amp;quot;), &lt;br /&gt;
        [ &lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroX&amp;quot;},&lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroY&amp;quot;},&lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroZ&amp;quot;}&lt;br /&gt;
        ],&lt;br /&gt;
            optionsBot);&lt;br /&gt;
&lt;br /&gt;
    // Request data every updateInterval ms&lt;br /&gt;
    function updateTop() {&lt;br /&gt;
        socket.emit(&amp;quot;ain&amp;quot;,  ainNum);&lt;br /&gt;
        socket.emit(&amp;quot;gpio&amp;quot;, gpioNum);&lt;br /&gt;
        setTimeout(updateTop, updateTopInterval);&lt;br /&gt;
    }&lt;br /&gt;
    //updateTop();&lt;br /&gt;
&lt;br /&gt;
    function updateBot() {&lt;br /&gt;
        socket.emit(&amp;quot;i2c&amp;quot;,  i2cNum);&lt;br /&gt;
        setTimeout(updateBot, updateBotInterval);&lt;br /&gt;
    }&lt;br /&gt;
    //updateBot();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documents ==&lt;br /&gt;
&lt;br /&gt;
[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/ITG-3200-v10.pdf Schematic]&lt;br /&gt;
&lt;br /&gt;
[http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Gyros/3-Axis/ITG-3200-v11.zip Eagle Files]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/tutorials/265 Quickstart Guide]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf ITG-3200 Datasheet]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/IDG-3200-ATmega328-4-30-10.zip Code (ATmega328)]&lt;br /&gt;
&lt;br /&gt;
[http://mbed.org/cookbook/ITG-3200-Gyroscope Example]&lt;br /&gt;
&lt;br /&gt;
[https://www.sparkfun.com/products/9801 Sparkfun]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ruffsl/ECE497 Github Repo]&lt;br /&gt;
&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ruff</id>
		<title>User:Ruff</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ruff"/>
				<updated>2012-10-24T04:46:54Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RuffHead}}&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|thumb|Displaying gyroscopic sensor data with node.js]]&lt;br /&gt;
&lt;br /&gt;
*Ruffin White&lt;br /&gt;
*Electrical Engineering Major&lt;br /&gt;
*Robotics Minor&lt;br /&gt;
*Class of 2013.&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
Project topics I'm interested in:&lt;br /&gt;
* RCs - Using remote control for hobbies&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
== Mini Pprojects ==&lt;br /&gt;
&lt;br /&gt;
Mini Project 1&lt;br /&gt;
&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
Mini Project 2&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
Mini Project 4&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro_Display]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/ruffsl/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
== How To ==&lt;br /&gt;
* none yet&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ruff</id>
		<title>User:Ruff</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ruff"/>
				<updated>2012-10-24T04:46:39Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Mini Pprojects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RuffHead}}&lt;br /&gt;
*Ruffin White&lt;br /&gt;
*Electrical Engineering Major&lt;br /&gt;
*Robotics Minor&lt;br /&gt;
*Class of 2013.&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
Project topics I'm interested in:&lt;br /&gt;
* RCs - Using remote control for hobbies&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
== Mini Pprojects ==&lt;br /&gt;
&lt;br /&gt;
Mini Project 1&lt;br /&gt;
&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
Mini Project 2&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
Mini Project 4&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro_Display]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/ruffsl/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
== How To ==&lt;br /&gt;
* none yet&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ruff</id>
		<title>User:Ruff</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ruff"/>
				<updated>2012-10-24T04:46:13Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Mini Pprojects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RuffHead}}&lt;br /&gt;
*Ruffin White&lt;br /&gt;
*Electrical Engineering Major&lt;br /&gt;
*Robotics Minor&lt;br /&gt;
*Class of 2013.&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
Project topics I'm interested in:&lt;br /&gt;
* RCs - Using remote control for hobbies&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
== Mini Pprojects ==&lt;br /&gt;
&lt;br /&gt;
Mini Project 1&lt;br /&gt;
&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
Mini Project 2&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
Mini Project 4&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|thumb|Displaying gyroscopic sensor data with node.js]]&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro_Display]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/ruffsl/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
== How To ==&lt;br /&gt;
* none yet&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ruff</id>
		<title>User:Ruff</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ruff"/>
				<updated>2012-10-24T04:45:30Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Mini Pprojects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RuffHead}}&lt;br /&gt;
*Ruffin White&lt;br /&gt;
*Electrical Engineering Major&lt;br /&gt;
*Robotics Minor&lt;br /&gt;
*Class of 2013.&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
Project topics I'm interested in:&lt;br /&gt;
* RCs - Using remote control for hobbies&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
== Mini Pprojects ==&lt;br /&gt;
&lt;br /&gt;
Mini Project 1&lt;br /&gt;
&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
Mini Project 2&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
Mini Project 4&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|thumb|left|Once the script is up and running you will begin to see the sensor data rendered across the time axis plots with regards to each rotational direction of the gyroscope as well as its internal temperature]]&lt;br /&gt;
&lt;br /&gt;
*[[SparkFun:_ITG-3200,Triple-Axis_Gyro_Display]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/ruffsl/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
== How To ==&lt;br /&gt;
* none yet&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/SparkFun:_ITG-3200,Triple-Axis_Gyro_Display</id>
		<title>SparkFun: ITG-3200,Triple-Axis Gyro Display</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/SparkFun:_ITG-3200,Triple-Axis_Gyro_Display"/>
				<updated>2012-10-24T04:44:21Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
{{RuffHead}}&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This project show how the ITG-3200, a three-axis gyro sensor, can read and displayed using the beagle bone, a web browser and node.js. This project expands upon what was documented in [[SparkFun:_ITG-3200,Triple-Axis_Gyro]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone2.jpg|thumb|ITG-3200 breakout board pin-out]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo1.png|thumb|Here's the first display screen you will see after entering the bones web address, go ahead and click on the Button Dox Demo link]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|thumb|left|Once the script is up and running you will begin to see the sensor data rendered across the time axis plots with regards to each rotational direction of the gyroscope as well as its internal temperature]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The goal here is to add a web-based graphical display to the gyroscopic sensor. Using examples of node.js servers that display realtime data from the beagle, I have altered the example code to display specifically the three axes of rotation for the gyroscope as well as in addition the internal temperature of the sensor itself.&lt;br /&gt;
&lt;br /&gt;
; buttonBox.js, buttonBox.html&lt;br /&gt;
: This is a bone-based example that reads a gpio port, analog in and an i2c device and displays the output in a web browser.These will be there two main files that will contain many of my alterations.&lt;br /&gt;
&lt;br /&gt;
== Running the code ==&lt;br /&gt;
First off, you'll need to download the code through the get hub repository onto a local directory within your Beagle bone. You will then need to navigate to:&lt;br /&gt;
 beagle$ '''cd ~/MiniProject04/node.js/realtime'''&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install nodejs'''  (Don't install '''node''', it's not what you think.)&lt;br /&gt;
&lt;br /&gt;
On the Bone:&lt;br /&gt;
 beagle$ '''node buttonBox.js'''&lt;br /&gt;
&lt;br /&gt;
Simply press ‘CTRL’ + ‘C’ to quit the program.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Bone===&lt;br /&gt;
&lt;br /&gt;
Then point a browser to '''beaglebone.local:8081'''.  The default port is 8081.  You can change it if you like.&lt;br /&gt;
&lt;br /&gt;
== How it works ==&lt;br /&gt;
&lt;br /&gt;
The prior examples included the script within the HTML file that polled the server continuously for data updates. However I have altered the code within the HTML file as well as the .js file to allow the server to be so fully responsible for pushing the data to the client.&lt;br /&gt;
&lt;br /&gt;
Another alteration I have made is to alter the I2C function that is called to acquisition the sensor data. Using the source code within mini project two, I have made a stripped-down version that simply returns all the relevant registers within the sensor. This is interpreted as a string within the server's .js file and is streamed to the client browser where the script parses the relevant information to each specific axis and temperature variable. This is then plotted on the grass and rendered on-screen over time.&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGPIO.png|thumb|This setup is accurate for the Sample Code up to the point about the brackeout board pinout. Just adjust the pin to the ITG-3200 accordingly to by description below. See [[EBC Exercise 12 I2C]] for more detail]]&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Node.js Code ===&lt;br /&gt;
&lt;br /&gt;
The code shown below is part sample code to demonstrate reading the registers via I2C and displaying the data with node.js. The alteration that has been made is to specify a timeout period for the server, as well as an additional function that will execute the terminal commands required to poll the gyroscopic sensor in return its register values. The code will also zero out the gyro to account for the internal bias the gyro might have just being stationary and level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// From Getting Started With node.js and socket.io &lt;br /&gt;
// http://codehenge.net/blog/2011/12/getting-started-with-node-js-and-socket-io-v0-7-part-2/&lt;br /&gt;
&amp;quot;use strict&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
var http = require('http'),&lt;br /&gt;
    url = require('url'),&lt;br /&gt;
    fs = require('fs'),&lt;br /&gt;
    exec = require('child_process').exec,&lt;br /&gt;
    server,&lt;br /&gt;
    connectCount = 0;	// Number of connections to server&lt;br /&gt;
&lt;br /&gt;
server = http.createServer(function (req, res) {&lt;br /&gt;
// server code&lt;br /&gt;
    var path = url.parse(req.url).pathname;&lt;br /&gt;
    console.log(&amp;quot;path: &amp;quot; + path);&lt;br /&gt;
    switch (path) {&lt;br /&gt;
    case '/':&lt;br /&gt;
        res.writeHead(200, {'Content-Type': 'text/html'});&lt;br /&gt;
        res.write('&amp;lt;h1&amp;gt;Hello!&amp;lt;/h1&amp;gt;Try&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;/buttonBox.html&amp;quot;&amp;gt;Button Box Demo&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;');&lt;br /&gt;
&lt;br /&gt;
        res.end();&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    default:		// This is so all the files will be sent.&lt;br /&gt;
        fs.readFile(__dirname + path, function (err, data) {&lt;br /&gt;
            if (err) {return send404(res); }&lt;br /&gt;
//            console.log(&amp;quot;path2: &amp;quot; + path);&lt;br /&gt;
            res.write(data, 'utf8');&lt;br /&gt;
            res.end();&lt;br /&gt;
        });&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
var send404 = function (res) {&lt;br /&gt;
    res.writeHead(404);&lt;br /&gt;
    res.write('404');&lt;br /&gt;
    res.end();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
server.listen(8081);&lt;br /&gt;
&lt;br /&gt;
// socket.io, I choose you&lt;br /&gt;
var io = require('socket.io').listen(server);&lt;br /&gt;
io.set('log level', 2);&lt;br /&gt;
&lt;br /&gt;
// on a 'connection' event&lt;br /&gt;
io.sockets.on('connection', function (socket) {&lt;br /&gt;
    var frameCount = 0;	// Counts the frames from arecord&lt;br /&gt;
    var lastFrame = 0;	// Last frame sent to browser&lt;br /&gt;
    console.log(&amp;quot;Connection &amp;quot; + socket.id + &amp;quot; accepted.&amp;quot;);&lt;br /&gt;
//    console.log(&amp;quot;socket: &amp;quot; + socket);&lt;br /&gt;
&lt;br /&gt;
    // now that we have our connected 'socket' object, we can &lt;br /&gt;
    // define its event handlers&lt;br /&gt;
&lt;br /&gt;
    // Make sure some needed files are there&lt;br /&gt;
    // The path to the analog devices changed from A5 to A6.  Check both.&lt;br /&gt;
    var ainPath = &amp;quot;/sys/devices/platform/omap/tsc/&amp;quot;;&lt;br /&gt;
//    if(!fs.existsSync(ainPath)) {&lt;br /&gt;
//        ainPath = &amp;quot;/sys/devices/platform/tsc/&amp;quot;;&lt;br /&gt;
//        if(!fs.existsSync(ainPath)) {&lt;br /&gt;
//            throw &amp;quot;Can't find &amp;quot; + ainPath;&lt;br /&gt;
//        }&lt;br /&gt;
//    }&lt;br /&gt;
    // Make sure gpio 7 is available.&lt;br /&gt;
    exec(&amp;quot;echo 7 &amp;gt; /sys/class/gpio/export&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    // Send value every time a 'message' is received.&lt;br /&gt;
    socket.on('ain', function (ainNum) {&lt;br /&gt;
//        var ainPath = &amp;quot;/sys/devices/platform/omap/tsc/ain&amp;quot; + ainNum;&lt;br /&gt;
        fs.readFile(ainPath + &amp;quot;ain&amp;quot; + ainNum, 'base64', function(err, data) {&lt;br /&gt;
            if(err) throw err;&lt;br /&gt;
            socket.emit('ain', data);&lt;br /&gt;
//            console.log('emitted ain: ' + data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('gpio', function (gpioNum) {&lt;br /&gt;
        var gpioPath = &amp;quot;/sys/class/gpio/gpio&amp;quot; + gpioNum + &amp;quot;/value&amp;quot;;&lt;br /&gt;
        fs.readFile(gpioPath, 'base64', function(err, data) {&lt;br /&gt;
            if (err) throw err;&lt;br /&gt;
            socket.emit('gpio', data);&lt;br /&gt;
//            console.log('emitted gpio: ' + data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('i2c', function (i2cNum) {&lt;br /&gt;
//        console.log('Got i2c request:' + i2cNum);&lt;br /&gt;
        exec('i2cget -y 3 ' + i2cNum + ' 0 w',&lt;br /&gt;
            function (error, stdout, stderr) {&lt;br /&gt;
//		The TMP102 returns a 12 bit value with the digits swapped&lt;br /&gt;
                stdout = '0x' + stdout.substring(4,6) + stdout.substring(2,4);&lt;br /&gt;
//                console.log('i2cget: &amp;quot;' + stdout + '&amp;quot;');&lt;br /&gt;
                if(error) { console.log('error: ' + error); }&lt;br /&gt;
                if(stderr) {console.log('stderr: ' + stderr); }&lt;br /&gt;
                socket.emit('i2c', stdout);&lt;br /&gt;
            });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('led', function (ledNum) {&lt;br /&gt;
        var ledPath = &amp;quot;/sys/class/leds/beaglebone::usr&amp;quot; + ledNum + &amp;quot;/brightness&amp;quot;;&lt;br /&gt;
//        console.log('LED: ' + ledPath);&lt;br /&gt;
        fs.readFile(ledPath, 'utf8', function (err, data) {&lt;br /&gt;
            if(err) throw err;&lt;br /&gt;
            data = data.substring(0,1) === &amp;quot;1&amp;quot; ? &amp;quot;0&amp;quot; : &amp;quot;1&amp;quot;;&lt;br /&gt;
//            console.log(&amp;quot;LED%d: %s&amp;quot;, ledNum, data);&lt;br /&gt;
            fs.writeFile(ledPath, data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
   var updateInterval = 100;&lt;br /&gt;
   function pushMessage() {&lt;br /&gt;
//        console.log('Got i2c request:' + 6);&lt;br /&gt;
        exec('/home/root/ECE497/MiniProject04/node.js/realtime/./a.out 0 0 ' + 3,&lt;br /&gt;
            function (error, stdout, stderr) {&lt;br /&gt;
		console.log('stdout:' + stdout);&lt;br /&gt;
		//console.log('stdout:' + parseFloat(stdout.substring(51,58))/100.0);&lt;br /&gt;
                if(error) { console.log('error: ' + error); }&lt;br /&gt;
                if(stderr) {console.log('stderr: ' + stderr); }&lt;br /&gt;
                socket.emit('i2c', stdout);&lt;br /&gt;
            });&lt;br /&gt;
        setTimeout(pushMessage, updateInterval);&lt;br /&gt;
    }&lt;br /&gt;
    pushMessage();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    socket.on('disconnect', function () {&lt;br /&gt;
        console.log(&amp;quot;Connection &amp;quot; + socket.id + &amp;quot; terminated.&amp;quot;);&lt;br /&gt;
        connectCount--;&lt;br /&gt;
        if(connectCount === 0) {&lt;br /&gt;
        }&lt;br /&gt;
        console.log(&amp;quot;connectCount = &amp;quot; + connectCount);&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    connectCount++;&lt;br /&gt;
    console.log(&amp;quot;connectCount = &amp;quot; + connectCount);&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== HTML Code ===&lt;br /&gt;
&lt;br /&gt;
This file is altered from example code and contains all the necessary formatting for the user interface and data representation. A also contains the script necessary to parse the string containing the sensor data sent by the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!doctype html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;Gyro Demo&amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;script src=&amp;quot;/json.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;!-- for ie --&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;/socket.io/socket.io.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;link href=&amp;quot;layout.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.flot.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.flot.navigate.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;h1&amp;gt;Gyro Demo &amp;lt;a href=&amp;quot;http://Rose-Hulman.edu&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;RoseLogo96.png&amp;quot; width=200 style=&amp;quot;float:right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
    &amp;lt;button id=&amp;quot;connect&amp;quot; onClick='connect()'/&amp;gt;Connect&amp;lt;/button&amp;gt;&lt;br /&gt;
    &amp;lt;button id=&amp;quot;disconnect&amp;quot; onClick='disconnect()'&amp;gt;Disconnect&amp;lt;/button&amp;gt;&lt;br /&gt;
    &amp;lt;span style=&amp;quot;position:relative; left:150px&amp;quot;&amp;gt;&lt;br /&gt;
    Analog: &amp;lt;input id=&amp;quot;ainNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:2em&amp;quot;&amp;gt;&lt;br /&gt;
    gpio: &amp;lt;input id=&amp;quot;gpioNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:2em&amp;quot;&amp;gt;&lt;br /&gt;
    i2c: &amp;lt;input id=&amp;quot;i2cNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;!--    &amp;lt;button id=&amp;quot;send&amp;quot; onClick='send()'/&amp;gt;Send Message&amp;lt;/button&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td&amp;gt;&amp;lt;div id=&amp;quot;plotTop&amp;quot; style=&amp;quot;width:550px;height:300px;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;samples&amp;lt;/center&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
    Update: &amp;lt;input id=&amp;quot;updateTopInterval&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt; ms&lt;br /&gt;
    &amp;lt;button id=&amp;quot;zoomout&amp;quot; onClick='plotTop.zoomOut()'&amp;gt;Zoom Out&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td&amp;gt;&amp;lt;div id=&amp;quot;plotBot&amp;quot; style=&amp;quot;width:550px;height:300px;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;samples&amp;lt;/center&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
    Update: &amp;lt;input id=&amp;quot;updateBotInterval&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt; ms&lt;br /&gt;
    &amp;lt;button id=&amp;quot;zoomout&amp;quot; onClick='plotBot.zoomOut()'&amp;gt;Zoom Out&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led0&amp;quot; onClick='led(0)'/&amp;gt;LED 0&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led1&amp;quot; onClick='led(1)'/&amp;gt;LED 1&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led2&amp;quot; onClick='led(2)'/&amp;gt;LED 2&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led3&amp;quot; onClick='led(3)'/&amp;gt;LED 3&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Button Box demo from the &amp;lt;a href=&amp;quot;http://elinux.org/index.php?title=Category:ECE497&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;32-bit Embedded Linux Class&amp;lt;/a&amp;gt;.&amp;lt;/b&amp;gt;&lt;br /&gt;
In this demo, the beagle bone pushes it sensor data to the web browser. Try moving the gyro or touching it to change its temprature. Try double-clicking to zoom and click and dragging to pan.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;a href=&amp;quot;http://beagleboard.org&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;beagle-hd-logo.gif&amp;quot; width=200 align=&amp;quot;right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;p id=&amp;quot;status&amp;quot;&amp;gt;Waiting for input&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;a href=&amp;quot;http://www.ti.com/sitara&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;hdr_ti_logo.gif&amp;quot; width=200 align=&amp;quot;right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;p id=&amp;quot;message&amp;quot;&amp;gt;message&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt; &lt;br /&gt;
By &amp;lt;i&amp;gt;Ruffin White&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    var socket;&lt;br /&gt;
    var firstconnect = true,&lt;br /&gt;
        fs = 8000,&lt;br /&gt;
        Ts = 1/fs*1000,&lt;br /&gt;
        samples = 100,&lt;br /&gt;
        plotTop,&lt;br /&gt;
        plotBot,&lt;br /&gt;
        ainData = [],  iain = 0, &lt;br /&gt;
        gpioData = [], igpio = 0,&lt;br /&gt;
        i2cXData = [],  ii2cX = 0,&lt;br /&gt;
        i2cYData = [],  ii2cY = 0,&lt;br /&gt;
        i2cZData = [],  ii2cZ = 0,&lt;br /&gt;
        i2cTData = [],  ii2cT = 0,&lt;br /&gt;
        gpioNum = 7,&lt;br /&gt;
        ainNum  = 6,&lt;br /&gt;
        i2cNum  = &amp;quot;0x48&amp;quot;;&lt;br /&gt;
    ainData[samples] = 0;&lt;br /&gt;
    gpioData[samples] = 0;&lt;br /&gt;
    i2cXData[samples] = 0;&lt;br /&gt;
    i2cYData[samples] = 0;&lt;br /&gt;
    i2cZData[samples] = 0;&lt;br /&gt;
    i2cTData[samples] = 0;&lt;br /&gt;
&lt;br /&gt;
    function connect() {&lt;br /&gt;
      if(firstconnect) {&lt;br /&gt;
        socket = io.connect(null);&lt;br /&gt;
&lt;br /&gt;
        socket.on('message', function(data)&lt;br /&gt;
            { status_update(&amp;quot;Received: message&amp;quot;);});&lt;br /&gt;
        socket.on('connect', function()&lt;br /&gt;
            { status_update(&amp;quot;Connected to Server&amp;quot;); });&lt;br /&gt;
        socket.on('disconnect', function()&lt;br /&gt;
            { status_update(&amp;quot;Disconnected from Server&amp;quot;); });&lt;br /&gt;
        socket.on('reconnect', function()&lt;br /&gt;
            { status_update(&amp;quot;Reconnected to Server&amp;quot;); });&lt;br /&gt;
        socket.on('reconnecting', function( nextRetry )&lt;br /&gt;
            { status_update(&amp;quot;Reconnecting in &amp;quot; + nextRetry/1000 + &amp;quot; s&amp;quot;); });&lt;br /&gt;
        socket.on('reconnect_failed', function()&lt;br /&gt;
            { message(&amp;quot;Reconnect Failed&amp;quot;); });&lt;br /&gt;
&lt;br /&gt;
        socket.on('ain',  ain);&lt;br /&gt;
        socket.on('gpio', gpio);&lt;br /&gt;
        socket.on('i2c',  i2c);&lt;br /&gt;
&lt;br /&gt;
        firstconnect = false;&lt;br /&gt;
      }&lt;br /&gt;
      else {&lt;br /&gt;
        socket.socket.reconnect();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function disconnect() {&lt;br /&gt;
      socket.disconnect();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function led(ledNum) {&lt;br /&gt;
        socket.emit('led', ledNum);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // When new data arrived, convert it and plot it.&lt;br /&gt;
    function ain(data) {&lt;br /&gt;
        data = atob(data)/4096 * 1.8;&lt;br /&gt;
        data = isNaN(data) ? 0 : data;&lt;br /&gt;
//        status_update(&amp;quot;ain: &amp;quot; + data);&lt;br /&gt;
        ainData[iain] = [iain, data];&lt;br /&gt;
        iain++;&lt;br /&gt;
        if(iain &amp;gt;= samples) {&lt;br /&gt;
            iain = 0;&lt;br /&gt;
            ainData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotTop.setData([ ainData, gpioData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function gpio(data) {&lt;br /&gt;
        data = atob(data);&lt;br /&gt;
//        status_update(&amp;quot;gpio: &amp;quot; + data);&lt;br /&gt;
        gpioData[igpio] = [igpio, data];&lt;br /&gt;
        igpio++;&lt;br /&gt;
        if(igpio &amp;gt;= samples) {&lt;br /&gt;
            igpio = 0;&lt;br /&gt;
            gpioData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotTop.setData([ ainData, gpioData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
//gyroX: -00026 gyroY: -00012 gyroZ: 000073 gyroTemp: 002602&lt;br /&gt;
&lt;br /&gt;
    function i2c(data) {&lt;br /&gt;
        Xdata = parseInt(data.substring(6,12));&lt;br /&gt;
        Ydata = parseInt(data.substring(20,26));&lt;br /&gt;
        Zdata = parseInt(data.substring(34,40));&lt;br /&gt;
        Tdata = parseInt(data.substring(51,56));&lt;br /&gt;
        i2cXData[ii2cX] = [ii2cX, Xdata];&lt;br /&gt;
        i2cYData[ii2cY] = [ii2cY, Ydata];&lt;br /&gt;
        i2cZData[ii2cZ] = [ii2cZ, Zdata];&lt;br /&gt;
        i2cTData[ii2cT] = [ii2cT, Tdata];&lt;br /&gt;
        ii2cX++;&lt;br /&gt;
        if(ii2cX &amp;gt;= samples) {&lt;br /&gt;
            ii2cX = 0;&lt;br /&gt;
            i2cXData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cY] = [ii2cY, Xdata];&lt;br /&gt;
        ii2cY++;&lt;br /&gt;
        if(ii2cY &amp;gt;= samples) {&lt;br /&gt;
            ii2cY = 0;&lt;br /&gt;
            i2cYData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cZ] = [ii2cZ, Xdata];&lt;br /&gt;
        ii2cZ++;&lt;br /&gt;
        if(ii2cZ &amp;gt;= samples) {&lt;br /&gt;
            ii2cZ = 0;&lt;br /&gt;
            i2cZData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cT] = [ii2cT, Xdata];&lt;br /&gt;
        ii2cT++;&lt;br /&gt;
        if(ii2cT &amp;gt;= samples) {&lt;br /&gt;
            ii2cT = 0;&lt;br /&gt;
            i2cTData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotBot.setData([ i2cXData, i2cYData, i2cZData]);&lt;br /&gt;
        plotBot.draw();&lt;br /&gt;
        plotTop.setData([ i2cTData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function status_update(txt){&lt;br /&gt;
      document.getElementById('status').innerHTML = txt;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function send(){&lt;br /&gt;
      socket.emit(&amp;quot;ain&amp;quot;, &amp;quot;Hello Server!&amp;quot;);    &lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    connect();&lt;br /&gt;
&lt;br /&gt;
$(function () {&lt;br /&gt;
&lt;br /&gt;
    function initPlotData() {&lt;br /&gt;
        // zip the generated y values with the x values&lt;br /&gt;
        var result = [];&lt;br /&gt;
        for (var i = 0; i &amp;lt;= samples; i++)&lt;br /&gt;
            result[i] = [i, 0];&lt;br /&gt;
        return result;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // setup control widget&lt;br /&gt;
    $(&amp;quot;#ainNum&amp;quot;).val(ainNum).change(function () {&lt;br /&gt;
        ainNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    $(&amp;quot;#gpioNum&amp;quot;).val(gpioNum).change(function () {&lt;br /&gt;
        gpioNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    $(&amp;quot;#i2cNum&amp;quot;).val(i2cNum).change(function () {&lt;br /&gt;
        i2cNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    var updateTopInterval = 100;&lt;br /&gt;
    $(&amp;quot;#updateTopInterval&amp;quot;).val(updateTopInterval).change(function () {&lt;br /&gt;
        var v = $(this).val();&lt;br /&gt;
        if (v &amp;amp;&amp;amp; !isNaN(+v)) {&lt;br /&gt;
            updateTopInterval = +v;&lt;br /&gt;
            if (updateTopInterval &amp;lt; 25)&lt;br /&gt;
                updateTopInterval = 25;&lt;br /&gt;
            if (updateTopInterval &amp;gt; 2000)&lt;br /&gt;
                updateTopInterval = 2000;&lt;br /&gt;
            $(this).val(&amp;quot;&amp;quot; + updateTopInterval);&lt;br /&gt;
        }&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    var updateBotInterval = 100;&lt;br /&gt;
    $(&amp;quot;#updateBotInterval&amp;quot;).val(updateBotInterval).change(function () {&lt;br /&gt;
        var v = $(this).val();&lt;br /&gt;
        if (v &amp;amp;&amp;amp; !isNaN(+v)) {&lt;br /&gt;
            updateBotInterval = +v;&lt;br /&gt;
            if (updateBotInterval &amp;lt; 25)&lt;br /&gt;
                updateBotInterval = 25;&lt;br /&gt;
            if (updateBotInterval &amp;gt; 2000)&lt;br /&gt;
                updateBotInterval = 2000;&lt;br /&gt;
            $(this).val(&amp;quot;&amp;quot; + updateBotInterval);&lt;br /&gt;
        }&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    // setup plot&lt;br /&gt;
    var optionsTop = {&lt;br /&gt;
        series: { &lt;br /&gt;
            shadowSize: 0, // drawing is faster without shadows&lt;br /&gt;
            points: { show: false},&lt;br /&gt;
            lines:  { show: true, lineWidth: 5},&lt;br /&gt;
        }, &lt;br /&gt;
        yaxis:	{ min: 10, max: 35, &lt;br /&gt;
                  zoomRange: [10, 256], panRange: [-128, 128] },&lt;br /&gt;
        xaxis:	{ show: true, &lt;br /&gt;
                  zoomRange: [10, 100], panRange: [0, 100] },&lt;br /&gt;
        legend:	{ position: &amp;quot;sw&amp;quot; },&lt;br /&gt;
        zoom:	{ interactive: true, amount: 1.1 },&lt;br /&gt;
        pan:	{ interactive: true }&lt;br /&gt;
    };&lt;br /&gt;
    plotTop = $.plot($(&amp;quot;#plotTop&amp;quot;), &lt;br /&gt;
        [ &lt;br /&gt;
          { data:  initPlotData(), &lt;br /&gt;
            label: &amp;quot;GyroTemp&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
            optionsTop);&lt;br /&gt;
&lt;br /&gt;
    var optionsBot = {&lt;br /&gt;
        series: { &lt;br /&gt;
            shadowSize: 0, // drawing is faster without shadows&lt;br /&gt;
            points: { show: false},&lt;br /&gt;
            lines:  { show: true, lineWidth: 5},&lt;br /&gt;
            //color: 2&lt;br /&gt;
        }, &lt;br /&gt;
        yaxis:	{ min: -100, max: 100, &lt;br /&gt;
                  zoomRange: [10, 256], panRange: [60, 100] },&lt;br /&gt;
        xaxis:	{ show: true, &lt;br /&gt;
                  zoomRange: [10, 100], panRange: [0, 100] },&lt;br /&gt;
        legend:	{ position: &amp;quot;sw&amp;quot; },&lt;br /&gt;
        zoom:	{ interactive: true, amount: 1.1 },&lt;br /&gt;
        pan:	{ interactive: true }&lt;br /&gt;
    };&lt;br /&gt;
    plotBot = $.plot($(&amp;quot;#plotBot&amp;quot;), &lt;br /&gt;
        [ &lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroX&amp;quot;},&lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroY&amp;quot;},&lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroZ&amp;quot;}&lt;br /&gt;
        ],&lt;br /&gt;
            optionsBot);&lt;br /&gt;
&lt;br /&gt;
    // Request data every updateInterval ms&lt;br /&gt;
    function updateTop() {&lt;br /&gt;
        socket.emit(&amp;quot;ain&amp;quot;,  ainNum);&lt;br /&gt;
        socket.emit(&amp;quot;gpio&amp;quot;, gpioNum);&lt;br /&gt;
        setTimeout(updateTop, updateTopInterval);&lt;br /&gt;
    }&lt;br /&gt;
    //updateTop();&lt;br /&gt;
&lt;br /&gt;
    function updateBot() {&lt;br /&gt;
        socket.emit(&amp;quot;i2c&amp;quot;,  i2cNum);&lt;br /&gt;
        setTimeout(updateBot, updateBotInterval);&lt;br /&gt;
    }&lt;br /&gt;
    //updateBot();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documents ==&lt;br /&gt;
&lt;br /&gt;
[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/ITG-3200-v10.pdf Schematic]&lt;br /&gt;
&lt;br /&gt;
[http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Gyros/3-Axis/ITG-3200-v11.zip Eagle Files]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/tutorials/265 Quickstart Guide]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf ITG-3200 Datasheet]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/IDG-3200-ATmega328-4-30-10.zip Code (ATmega328)]&lt;br /&gt;
&lt;br /&gt;
[http://mbed.org/cookbook/ITG-3200-Gyroscope Example]&lt;br /&gt;
&lt;br /&gt;
[https://www.sparkfun.com/products/9801 Sparkfun]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ruffsl/ECE497 Github Repo]&lt;br /&gt;
&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/SparkFun:_ITG-3200,Triple-Axis_Gyro_Display</id>
		<title>SparkFun: ITG-3200,Triple-Axis Gyro Display</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/SparkFun:_ITG-3200,Triple-Axis_Gyro_Display"/>
				<updated>2012-10-24T04:43:40Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
{{RuffHead}}&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo1.png|frame|Here's the first display screen you will see after entering the bones web address, go ahead and click on the Button Dox Demo link]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|frame|left|Once the script is up and running you will begin to see the sensor data rendered across the time axis plots with regards to each rotational direction of the gyroscope as well as its internal temperature]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This project show how the ITG-3200, a three-axis gyro sensor, can read and displayed using the beagle bone, a web browser and node.js. This project expands upon what was documented in [[SparkFun:_ITG-3200,Triple-Axis_Gyro]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone2.jpg|thumb|ITG-3200 breakout board pin-out]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The goal here is to add a web-based graphical display to the gyroscopic sensor. Using examples of node.js servers that display realtime data from the beagle, I have altered the example code to display specifically the three axes of rotation for the gyroscope as well as in addition the internal temperature of the sensor itself.&lt;br /&gt;
&lt;br /&gt;
; buttonBox.js, buttonBox.html&lt;br /&gt;
: This is a bone-based example that reads a gpio port, analog in and an i2c device and displays the output in a web browser.These will be there two main files that will contain many of my alterations.&lt;br /&gt;
&lt;br /&gt;
== Running the code ==&lt;br /&gt;
First off, you'll need to download the code through the get hub repository onto a local directory within your Beagle bone. You will then need to navigate to:&lt;br /&gt;
 beagle$ '''cd ~/MiniProject04/node.js/realtime'''&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install nodejs'''  (Don't install '''node''', it's not what you think.)&lt;br /&gt;
&lt;br /&gt;
On the Bone:&lt;br /&gt;
 beagle$ '''node buttonBox.js'''&lt;br /&gt;
&lt;br /&gt;
Simply press ‘CTRL’ + ‘C’ to quit the program.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Bone===&lt;br /&gt;
&lt;br /&gt;
Then point a browser to '''beaglebone.local:8081'''.  The default port is 8081.  You can change it if you like.&lt;br /&gt;
&lt;br /&gt;
== How it works ==&lt;br /&gt;
&lt;br /&gt;
The prior examples included the script within the HTML file that polled the server continuously for data updates. However I have altered the code within the HTML file as well as the .js file to allow the server to be so fully responsible for pushing the data to the client.&lt;br /&gt;
&lt;br /&gt;
Another alteration I have made is to alter the I2C function that is called to acquisition the sensor data. Using the source code within mini project two, I have made a stripped-down version that simply returns all the relevant registers within the sensor. This is interpreted as a string within the server's .js file and is streamed to the client browser where the script parses the relevant information to each specific axis and temperature variable. This is then plotted on the grass and rendered on-screen over time.&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGPIO.png|thumb|This setup is accurate for the Sample Code up to the point about the brackeout board pinout. Just adjust the pin to the ITG-3200 accordingly to by description below. See [[EBC Exercise 12 I2C]] for more detail]]&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Node.js Code ===&lt;br /&gt;
&lt;br /&gt;
The code shown below is part sample code to demonstrate reading the registers via I2C and displaying the data with node.js. The alteration that has been made is to specify a timeout period for the server, as well as an additional function that will execute the terminal commands required to poll the gyroscopic sensor in return its register values. The code will also zero out the gyro to account for the internal bias the gyro might have just being stationary and level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// From Getting Started With node.js and socket.io &lt;br /&gt;
// http://codehenge.net/blog/2011/12/getting-started-with-node-js-and-socket-io-v0-7-part-2/&lt;br /&gt;
&amp;quot;use strict&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
var http = require('http'),&lt;br /&gt;
    url = require('url'),&lt;br /&gt;
    fs = require('fs'),&lt;br /&gt;
    exec = require('child_process').exec,&lt;br /&gt;
    server,&lt;br /&gt;
    connectCount = 0;	// Number of connections to server&lt;br /&gt;
&lt;br /&gt;
server = http.createServer(function (req, res) {&lt;br /&gt;
// server code&lt;br /&gt;
    var path = url.parse(req.url).pathname;&lt;br /&gt;
    console.log(&amp;quot;path: &amp;quot; + path);&lt;br /&gt;
    switch (path) {&lt;br /&gt;
    case '/':&lt;br /&gt;
        res.writeHead(200, {'Content-Type': 'text/html'});&lt;br /&gt;
        res.write('&amp;lt;h1&amp;gt;Hello!&amp;lt;/h1&amp;gt;Try&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;/buttonBox.html&amp;quot;&amp;gt;Button Box Demo&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;');&lt;br /&gt;
&lt;br /&gt;
        res.end();&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    default:		// This is so all the files will be sent.&lt;br /&gt;
        fs.readFile(__dirname + path, function (err, data) {&lt;br /&gt;
            if (err) {return send404(res); }&lt;br /&gt;
//            console.log(&amp;quot;path2: &amp;quot; + path);&lt;br /&gt;
            res.write(data, 'utf8');&lt;br /&gt;
            res.end();&lt;br /&gt;
        });&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
var send404 = function (res) {&lt;br /&gt;
    res.writeHead(404);&lt;br /&gt;
    res.write('404');&lt;br /&gt;
    res.end();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
server.listen(8081);&lt;br /&gt;
&lt;br /&gt;
// socket.io, I choose you&lt;br /&gt;
var io = require('socket.io').listen(server);&lt;br /&gt;
io.set('log level', 2);&lt;br /&gt;
&lt;br /&gt;
// on a 'connection' event&lt;br /&gt;
io.sockets.on('connection', function (socket) {&lt;br /&gt;
    var frameCount = 0;	// Counts the frames from arecord&lt;br /&gt;
    var lastFrame = 0;	// Last frame sent to browser&lt;br /&gt;
    console.log(&amp;quot;Connection &amp;quot; + socket.id + &amp;quot; accepted.&amp;quot;);&lt;br /&gt;
//    console.log(&amp;quot;socket: &amp;quot; + socket);&lt;br /&gt;
&lt;br /&gt;
    // now that we have our connected 'socket' object, we can &lt;br /&gt;
    // define its event handlers&lt;br /&gt;
&lt;br /&gt;
    // Make sure some needed files are there&lt;br /&gt;
    // The path to the analog devices changed from A5 to A6.  Check both.&lt;br /&gt;
    var ainPath = &amp;quot;/sys/devices/platform/omap/tsc/&amp;quot;;&lt;br /&gt;
//    if(!fs.existsSync(ainPath)) {&lt;br /&gt;
//        ainPath = &amp;quot;/sys/devices/platform/tsc/&amp;quot;;&lt;br /&gt;
//        if(!fs.existsSync(ainPath)) {&lt;br /&gt;
//            throw &amp;quot;Can't find &amp;quot; + ainPath;&lt;br /&gt;
//        }&lt;br /&gt;
//    }&lt;br /&gt;
    // Make sure gpio 7 is available.&lt;br /&gt;
    exec(&amp;quot;echo 7 &amp;gt; /sys/class/gpio/export&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    // Send value every time a 'message' is received.&lt;br /&gt;
    socket.on('ain', function (ainNum) {&lt;br /&gt;
//        var ainPath = &amp;quot;/sys/devices/platform/omap/tsc/ain&amp;quot; + ainNum;&lt;br /&gt;
        fs.readFile(ainPath + &amp;quot;ain&amp;quot; + ainNum, 'base64', function(err, data) {&lt;br /&gt;
            if(err) throw err;&lt;br /&gt;
            socket.emit('ain', data);&lt;br /&gt;
//            console.log('emitted ain: ' + data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('gpio', function (gpioNum) {&lt;br /&gt;
        var gpioPath = &amp;quot;/sys/class/gpio/gpio&amp;quot; + gpioNum + &amp;quot;/value&amp;quot;;&lt;br /&gt;
        fs.readFile(gpioPath, 'base64', function(err, data) {&lt;br /&gt;
            if (err) throw err;&lt;br /&gt;
            socket.emit('gpio', data);&lt;br /&gt;
//            console.log('emitted gpio: ' + data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('i2c', function (i2cNum) {&lt;br /&gt;
//        console.log('Got i2c request:' + i2cNum);&lt;br /&gt;
        exec('i2cget -y 3 ' + i2cNum + ' 0 w',&lt;br /&gt;
            function (error, stdout, stderr) {&lt;br /&gt;
//		The TMP102 returns a 12 bit value with the digits swapped&lt;br /&gt;
                stdout = '0x' + stdout.substring(4,6) + stdout.substring(2,4);&lt;br /&gt;
//                console.log('i2cget: &amp;quot;' + stdout + '&amp;quot;');&lt;br /&gt;
                if(error) { console.log('error: ' + error); }&lt;br /&gt;
                if(stderr) {console.log('stderr: ' + stderr); }&lt;br /&gt;
                socket.emit('i2c', stdout);&lt;br /&gt;
            });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('led', function (ledNum) {&lt;br /&gt;
        var ledPath = &amp;quot;/sys/class/leds/beaglebone::usr&amp;quot; + ledNum + &amp;quot;/brightness&amp;quot;;&lt;br /&gt;
//        console.log('LED: ' + ledPath);&lt;br /&gt;
        fs.readFile(ledPath, 'utf8', function (err, data) {&lt;br /&gt;
            if(err) throw err;&lt;br /&gt;
            data = data.substring(0,1) === &amp;quot;1&amp;quot; ? &amp;quot;0&amp;quot; : &amp;quot;1&amp;quot;;&lt;br /&gt;
//            console.log(&amp;quot;LED%d: %s&amp;quot;, ledNum, data);&lt;br /&gt;
            fs.writeFile(ledPath, data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
   var updateInterval = 100;&lt;br /&gt;
   function pushMessage() {&lt;br /&gt;
//        console.log('Got i2c request:' + 6);&lt;br /&gt;
        exec('/home/root/ECE497/MiniProject04/node.js/realtime/./a.out 0 0 ' + 3,&lt;br /&gt;
            function (error, stdout, stderr) {&lt;br /&gt;
		console.log('stdout:' + stdout);&lt;br /&gt;
		//console.log('stdout:' + parseFloat(stdout.substring(51,58))/100.0);&lt;br /&gt;
                if(error) { console.log('error: ' + error); }&lt;br /&gt;
                if(stderr) {console.log('stderr: ' + stderr); }&lt;br /&gt;
                socket.emit('i2c', stdout);&lt;br /&gt;
            });&lt;br /&gt;
        setTimeout(pushMessage, updateInterval);&lt;br /&gt;
    }&lt;br /&gt;
    pushMessage();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    socket.on('disconnect', function () {&lt;br /&gt;
        console.log(&amp;quot;Connection &amp;quot; + socket.id + &amp;quot; terminated.&amp;quot;);&lt;br /&gt;
        connectCount--;&lt;br /&gt;
        if(connectCount === 0) {&lt;br /&gt;
        }&lt;br /&gt;
        console.log(&amp;quot;connectCount = &amp;quot; + connectCount);&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    connectCount++;&lt;br /&gt;
    console.log(&amp;quot;connectCount = &amp;quot; + connectCount);&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== HTML Code ===&lt;br /&gt;
&lt;br /&gt;
This file is altered from example code and contains all the necessary formatting for the user interface and data representation. A also contains the script necessary to parse the string containing the sensor data sent by the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!doctype html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;Gyro Demo&amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;script src=&amp;quot;/json.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;!-- for ie --&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;/socket.io/socket.io.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;link href=&amp;quot;layout.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.flot.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.flot.navigate.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;h1&amp;gt;Gyro Demo &amp;lt;a href=&amp;quot;http://Rose-Hulman.edu&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;RoseLogo96.png&amp;quot; width=200 style=&amp;quot;float:right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
    &amp;lt;button id=&amp;quot;connect&amp;quot; onClick='connect()'/&amp;gt;Connect&amp;lt;/button&amp;gt;&lt;br /&gt;
    &amp;lt;button id=&amp;quot;disconnect&amp;quot; onClick='disconnect()'&amp;gt;Disconnect&amp;lt;/button&amp;gt;&lt;br /&gt;
    &amp;lt;span style=&amp;quot;position:relative; left:150px&amp;quot;&amp;gt;&lt;br /&gt;
    Analog: &amp;lt;input id=&amp;quot;ainNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:2em&amp;quot;&amp;gt;&lt;br /&gt;
    gpio: &amp;lt;input id=&amp;quot;gpioNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:2em&amp;quot;&amp;gt;&lt;br /&gt;
    i2c: &amp;lt;input id=&amp;quot;i2cNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;!--    &amp;lt;button id=&amp;quot;send&amp;quot; onClick='send()'/&amp;gt;Send Message&amp;lt;/button&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td&amp;gt;&amp;lt;div id=&amp;quot;plotTop&amp;quot; style=&amp;quot;width:550px;height:300px;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;samples&amp;lt;/center&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
    Update: &amp;lt;input id=&amp;quot;updateTopInterval&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt; ms&lt;br /&gt;
    &amp;lt;button id=&amp;quot;zoomout&amp;quot; onClick='plotTop.zoomOut()'&amp;gt;Zoom Out&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td&amp;gt;&amp;lt;div id=&amp;quot;plotBot&amp;quot; style=&amp;quot;width:550px;height:300px;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;samples&amp;lt;/center&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
    Update: &amp;lt;input id=&amp;quot;updateBotInterval&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt; ms&lt;br /&gt;
    &amp;lt;button id=&amp;quot;zoomout&amp;quot; onClick='plotBot.zoomOut()'&amp;gt;Zoom Out&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led0&amp;quot; onClick='led(0)'/&amp;gt;LED 0&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led1&amp;quot; onClick='led(1)'/&amp;gt;LED 1&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led2&amp;quot; onClick='led(2)'/&amp;gt;LED 2&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led3&amp;quot; onClick='led(3)'/&amp;gt;LED 3&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Button Box demo from the &amp;lt;a href=&amp;quot;http://elinux.org/index.php?title=Category:ECE497&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;32-bit Embedded Linux Class&amp;lt;/a&amp;gt;.&amp;lt;/b&amp;gt;&lt;br /&gt;
In this demo, the beagle bone pushes it sensor data to the web browser. Try moving the gyro or touching it to change its temprature. Try double-clicking to zoom and click and dragging to pan.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;a href=&amp;quot;http://beagleboard.org&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;beagle-hd-logo.gif&amp;quot; width=200 align=&amp;quot;right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;p id=&amp;quot;status&amp;quot;&amp;gt;Waiting for input&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;a href=&amp;quot;http://www.ti.com/sitara&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;hdr_ti_logo.gif&amp;quot; width=200 align=&amp;quot;right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;p id=&amp;quot;message&amp;quot;&amp;gt;message&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt; &lt;br /&gt;
By &amp;lt;i&amp;gt;Ruffin White&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    var socket;&lt;br /&gt;
    var firstconnect = true,&lt;br /&gt;
        fs = 8000,&lt;br /&gt;
        Ts = 1/fs*1000,&lt;br /&gt;
        samples = 100,&lt;br /&gt;
        plotTop,&lt;br /&gt;
        plotBot,&lt;br /&gt;
        ainData = [],  iain = 0, &lt;br /&gt;
        gpioData = [], igpio = 0,&lt;br /&gt;
        i2cXData = [],  ii2cX = 0,&lt;br /&gt;
        i2cYData = [],  ii2cY = 0,&lt;br /&gt;
        i2cZData = [],  ii2cZ = 0,&lt;br /&gt;
        i2cTData = [],  ii2cT = 0,&lt;br /&gt;
        gpioNum = 7,&lt;br /&gt;
        ainNum  = 6,&lt;br /&gt;
        i2cNum  = &amp;quot;0x48&amp;quot;;&lt;br /&gt;
    ainData[samples] = 0;&lt;br /&gt;
    gpioData[samples] = 0;&lt;br /&gt;
    i2cXData[samples] = 0;&lt;br /&gt;
    i2cYData[samples] = 0;&lt;br /&gt;
    i2cZData[samples] = 0;&lt;br /&gt;
    i2cTData[samples] = 0;&lt;br /&gt;
&lt;br /&gt;
    function connect() {&lt;br /&gt;
      if(firstconnect) {&lt;br /&gt;
        socket = io.connect(null);&lt;br /&gt;
&lt;br /&gt;
        socket.on('message', function(data)&lt;br /&gt;
            { status_update(&amp;quot;Received: message&amp;quot;);});&lt;br /&gt;
        socket.on('connect', function()&lt;br /&gt;
            { status_update(&amp;quot;Connected to Server&amp;quot;); });&lt;br /&gt;
        socket.on('disconnect', function()&lt;br /&gt;
            { status_update(&amp;quot;Disconnected from Server&amp;quot;); });&lt;br /&gt;
        socket.on('reconnect', function()&lt;br /&gt;
            { status_update(&amp;quot;Reconnected to Server&amp;quot;); });&lt;br /&gt;
        socket.on('reconnecting', function( nextRetry )&lt;br /&gt;
            { status_update(&amp;quot;Reconnecting in &amp;quot; + nextRetry/1000 + &amp;quot; s&amp;quot;); });&lt;br /&gt;
        socket.on('reconnect_failed', function()&lt;br /&gt;
            { message(&amp;quot;Reconnect Failed&amp;quot;); });&lt;br /&gt;
&lt;br /&gt;
        socket.on('ain',  ain);&lt;br /&gt;
        socket.on('gpio', gpio);&lt;br /&gt;
        socket.on('i2c',  i2c);&lt;br /&gt;
&lt;br /&gt;
        firstconnect = false;&lt;br /&gt;
      }&lt;br /&gt;
      else {&lt;br /&gt;
        socket.socket.reconnect();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function disconnect() {&lt;br /&gt;
      socket.disconnect();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function led(ledNum) {&lt;br /&gt;
        socket.emit('led', ledNum);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // When new data arrived, convert it and plot it.&lt;br /&gt;
    function ain(data) {&lt;br /&gt;
        data = atob(data)/4096 * 1.8;&lt;br /&gt;
        data = isNaN(data) ? 0 : data;&lt;br /&gt;
//        status_update(&amp;quot;ain: &amp;quot; + data);&lt;br /&gt;
        ainData[iain] = [iain, data];&lt;br /&gt;
        iain++;&lt;br /&gt;
        if(iain &amp;gt;= samples) {&lt;br /&gt;
            iain = 0;&lt;br /&gt;
            ainData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotTop.setData([ ainData, gpioData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function gpio(data) {&lt;br /&gt;
        data = atob(data);&lt;br /&gt;
//        status_update(&amp;quot;gpio: &amp;quot; + data);&lt;br /&gt;
        gpioData[igpio] = [igpio, data];&lt;br /&gt;
        igpio++;&lt;br /&gt;
        if(igpio &amp;gt;= samples) {&lt;br /&gt;
            igpio = 0;&lt;br /&gt;
            gpioData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotTop.setData([ ainData, gpioData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
//gyroX: -00026 gyroY: -00012 gyroZ: 000073 gyroTemp: 002602&lt;br /&gt;
&lt;br /&gt;
    function i2c(data) {&lt;br /&gt;
        Xdata = parseInt(data.substring(6,12));&lt;br /&gt;
        Ydata = parseInt(data.substring(20,26));&lt;br /&gt;
        Zdata = parseInt(data.substring(34,40));&lt;br /&gt;
        Tdata = parseInt(data.substring(51,56));&lt;br /&gt;
        i2cXData[ii2cX] = [ii2cX, Xdata];&lt;br /&gt;
        i2cYData[ii2cY] = [ii2cY, Ydata];&lt;br /&gt;
        i2cZData[ii2cZ] = [ii2cZ, Zdata];&lt;br /&gt;
        i2cTData[ii2cT] = [ii2cT, Tdata];&lt;br /&gt;
        ii2cX++;&lt;br /&gt;
        if(ii2cX &amp;gt;= samples) {&lt;br /&gt;
            ii2cX = 0;&lt;br /&gt;
            i2cXData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cY] = [ii2cY, Xdata];&lt;br /&gt;
        ii2cY++;&lt;br /&gt;
        if(ii2cY &amp;gt;= samples) {&lt;br /&gt;
            ii2cY = 0;&lt;br /&gt;
            i2cYData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cZ] = [ii2cZ, Xdata];&lt;br /&gt;
        ii2cZ++;&lt;br /&gt;
        if(ii2cZ &amp;gt;= samples) {&lt;br /&gt;
            ii2cZ = 0;&lt;br /&gt;
            i2cZData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cT] = [ii2cT, Xdata];&lt;br /&gt;
        ii2cT++;&lt;br /&gt;
        if(ii2cT &amp;gt;= samples) {&lt;br /&gt;
            ii2cT = 0;&lt;br /&gt;
            i2cTData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotBot.setData([ i2cXData, i2cYData, i2cZData]);&lt;br /&gt;
        plotBot.draw();&lt;br /&gt;
        plotTop.setData([ i2cTData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function status_update(txt){&lt;br /&gt;
      document.getElementById('status').innerHTML = txt;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function send(){&lt;br /&gt;
      socket.emit(&amp;quot;ain&amp;quot;, &amp;quot;Hello Server!&amp;quot;);    &lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    connect();&lt;br /&gt;
&lt;br /&gt;
$(function () {&lt;br /&gt;
&lt;br /&gt;
    function initPlotData() {&lt;br /&gt;
        // zip the generated y values with the x values&lt;br /&gt;
        var result = [];&lt;br /&gt;
        for (var i = 0; i &amp;lt;= samples; i++)&lt;br /&gt;
            result[i] = [i, 0];&lt;br /&gt;
        return result;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // setup control widget&lt;br /&gt;
    $(&amp;quot;#ainNum&amp;quot;).val(ainNum).change(function () {&lt;br /&gt;
        ainNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    $(&amp;quot;#gpioNum&amp;quot;).val(gpioNum).change(function () {&lt;br /&gt;
        gpioNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    $(&amp;quot;#i2cNum&amp;quot;).val(i2cNum).change(function () {&lt;br /&gt;
        i2cNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    var updateTopInterval = 100;&lt;br /&gt;
    $(&amp;quot;#updateTopInterval&amp;quot;).val(updateTopInterval).change(function () {&lt;br /&gt;
        var v = $(this).val();&lt;br /&gt;
        if (v &amp;amp;&amp;amp; !isNaN(+v)) {&lt;br /&gt;
            updateTopInterval = +v;&lt;br /&gt;
            if (updateTopInterval &amp;lt; 25)&lt;br /&gt;
                updateTopInterval = 25;&lt;br /&gt;
            if (updateTopInterval &amp;gt; 2000)&lt;br /&gt;
                updateTopInterval = 2000;&lt;br /&gt;
            $(this).val(&amp;quot;&amp;quot; + updateTopInterval);&lt;br /&gt;
        }&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    var updateBotInterval = 100;&lt;br /&gt;
    $(&amp;quot;#updateBotInterval&amp;quot;).val(updateBotInterval).change(function () {&lt;br /&gt;
        var v = $(this).val();&lt;br /&gt;
        if (v &amp;amp;&amp;amp; !isNaN(+v)) {&lt;br /&gt;
            updateBotInterval = +v;&lt;br /&gt;
            if (updateBotInterval &amp;lt; 25)&lt;br /&gt;
                updateBotInterval = 25;&lt;br /&gt;
            if (updateBotInterval &amp;gt; 2000)&lt;br /&gt;
                updateBotInterval = 2000;&lt;br /&gt;
            $(this).val(&amp;quot;&amp;quot; + updateBotInterval);&lt;br /&gt;
        }&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    // setup plot&lt;br /&gt;
    var optionsTop = {&lt;br /&gt;
        series: { &lt;br /&gt;
            shadowSize: 0, // drawing is faster without shadows&lt;br /&gt;
            points: { show: false},&lt;br /&gt;
            lines:  { show: true, lineWidth: 5},&lt;br /&gt;
        }, &lt;br /&gt;
        yaxis:	{ min: 10, max: 35, &lt;br /&gt;
                  zoomRange: [10, 256], panRange: [-128, 128] },&lt;br /&gt;
        xaxis:	{ show: true, &lt;br /&gt;
                  zoomRange: [10, 100], panRange: [0, 100] },&lt;br /&gt;
        legend:	{ position: &amp;quot;sw&amp;quot; },&lt;br /&gt;
        zoom:	{ interactive: true, amount: 1.1 },&lt;br /&gt;
        pan:	{ interactive: true }&lt;br /&gt;
    };&lt;br /&gt;
    plotTop = $.plot($(&amp;quot;#plotTop&amp;quot;), &lt;br /&gt;
        [ &lt;br /&gt;
          { data:  initPlotData(), &lt;br /&gt;
            label: &amp;quot;GyroTemp&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
            optionsTop);&lt;br /&gt;
&lt;br /&gt;
    var optionsBot = {&lt;br /&gt;
        series: { &lt;br /&gt;
            shadowSize: 0, // drawing is faster without shadows&lt;br /&gt;
            points: { show: false},&lt;br /&gt;
            lines:  { show: true, lineWidth: 5},&lt;br /&gt;
            //color: 2&lt;br /&gt;
        }, &lt;br /&gt;
        yaxis:	{ min: -100, max: 100, &lt;br /&gt;
                  zoomRange: [10, 256], panRange: [60, 100] },&lt;br /&gt;
        xaxis:	{ show: true, &lt;br /&gt;
                  zoomRange: [10, 100], panRange: [0, 100] },&lt;br /&gt;
        legend:	{ position: &amp;quot;sw&amp;quot; },&lt;br /&gt;
        zoom:	{ interactive: true, amount: 1.1 },&lt;br /&gt;
        pan:	{ interactive: true }&lt;br /&gt;
    };&lt;br /&gt;
    plotBot = $.plot($(&amp;quot;#plotBot&amp;quot;), &lt;br /&gt;
        [ &lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroX&amp;quot;},&lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroY&amp;quot;},&lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroZ&amp;quot;}&lt;br /&gt;
        ],&lt;br /&gt;
            optionsBot);&lt;br /&gt;
&lt;br /&gt;
    // Request data every updateInterval ms&lt;br /&gt;
    function updateTop() {&lt;br /&gt;
        socket.emit(&amp;quot;ain&amp;quot;,  ainNum);&lt;br /&gt;
        socket.emit(&amp;quot;gpio&amp;quot;, gpioNum);&lt;br /&gt;
        setTimeout(updateTop, updateTopInterval);&lt;br /&gt;
    }&lt;br /&gt;
    //updateTop();&lt;br /&gt;
&lt;br /&gt;
    function updateBot() {&lt;br /&gt;
        socket.emit(&amp;quot;i2c&amp;quot;,  i2cNum);&lt;br /&gt;
        setTimeout(updateBot, updateBotInterval);&lt;br /&gt;
    }&lt;br /&gt;
    //updateBot();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documents ==&lt;br /&gt;
&lt;br /&gt;
[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/ITG-3200-v10.pdf Schematic]&lt;br /&gt;
&lt;br /&gt;
[http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Gyros/3-Axis/ITG-3200-v11.zip Eagle Files]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/tutorials/265 Quickstart Guide]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf ITG-3200 Datasheet]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/IDG-3200-ATmega328-4-30-10.zip Code (ATmega328)]&lt;br /&gt;
&lt;br /&gt;
[http://mbed.org/cookbook/ITG-3200-Gyroscope Example]&lt;br /&gt;
&lt;br /&gt;
[https://www.sparkfun.com/products/9801 Sparkfun]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ruffsl/ECE497 Github Repo]&lt;br /&gt;
&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	<entry>
		<id>http://elinux.org/SparkFun:_ITG-3200,Triple-Axis_Gyro_Display</id>
		<title>SparkFun: ITG-3200,Triple-Axis Gyro Display</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/SparkFun:_ITG-3200,Triple-Axis_Gyro_Display"/>
				<updated>2012-10-24T04:43:12Z</updated>
		
		<summary type="html">&lt;p&gt;Ruff: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
{{RuffHead}}&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone.jpg|thumb|Breakout board for InvenSense's ITG-3200]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This project show how the ITG-3200, a three-axis gyro sensor, can read and displayed using the beagle bone, a web browser and node.js. This project expands upon what was documented in [[SparkFun:_ITG-3200,Triple-Axis_Gyro]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:ITG3200Bone2.jpg|thumb|ITG-3200 breakout board pin-out]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo1.png|frame|Here's the first display screen you will see after entering the bones web address, go ahead and click on the Button Dox Demo link]]&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGyroDemo2.png|frame|left|Once the script is up and running you will begin to see the sensor data rendered across the time axis plots with regards to each rotational direction of the gyroscope as well as its internal temperature]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The goal here is to add a web-based graphical display to the gyroscopic sensor. Using examples of node.js servers that display realtime data from the beagle, I have altered the example code to display specifically the three axes of rotation for the gyroscope as well as in addition the internal temperature of the sensor itself.&lt;br /&gt;
&lt;br /&gt;
; buttonBox.js, buttonBox.html&lt;br /&gt;
: This is a bone-based example that reads a gpio port, analog in and an i2c device and displays the output in a web browser.These will be there two main files that will contain many of my alterations.&lt;br /&gt;
&lt;br /&gt;
== Running the code ==&lt;br /&gt;
First off, you'll need to download the code through the get hub repository onto a local directory within your Beagle bone. You will then need to navigate to:&lt;br /&gt;
 beagle$ '''cd ~/MiniProject04/node.js/realtime'''&lt;br /&gt;
 beagle$ '''opkg update'''&lt;br /&gt;
 beagle$ '''opkg install nodejs'''  (Don't install '''node''', it's not what you think.)&lt;br /&gt;
&lt;br /&gt;
On the Bone:&lt;br /&gt;
 beagle$ '''node buttonBox.js'''&lt;br /&gt;
&lt;br /&gt;
Simply press ‘CTRL’ + ‘C’ to quit the program.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Bone===&lt;br /&gt;
&lt;br /&gt;
Then point a browser to '''beaglebone.local:8081'''.  The default port is 8081.  You can change it if you like.&lt;br /&gt;
&lt;br /&gt;
== How it works ==&lt;br /&gt;
&lt;br /&gt;
The prior examples included the script within the HTML file that polled the server continuously for data updates. However I have altered the code within the HTML file as well as the .js file to allow the server to be so fully responsible for pushing the data to the client.&lt;br /&gt;
&lt;br /&gt;
Another alteration I have made is to alter the I2C function that is called to acquisition the sensor data. Using the source code within mini project two, I have made a stripped-down version that simply returns all the relevant registers within the sensor. This is interpreted as a string within the server's .js file and is streamed to the client browser where the script parses the relevant information to each specific axis and temperature variable. This is then plotted on the grass and rendered on-screen over time.&lt;br /&gt;
&lt;br /&gt;
[[File:BoneGPIO.png|thumb|This setup is accurate for the Sample Code up to the point about the brackeout board pinout. Just adjust the pin to the ITG-3200 accordingly to by description below. See [[EBC Exercise 12 I2C]] for more detail]]&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Node.js Code ===&lt;br /&gt;
&lt;br /&gt;
The code shown below is part sample code to demonstrate reading the registers via I2C and displaying the data with node.js. The alteration that has been made is to specify a timeout period for the server, as well as an additional function that will execute the terminal commands required to poll the gyroscopic sensor in return its register values. The code will also zero out the gyro to account for the internal bias the gyro might have just being stationary and level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// From Getting Started With node.js and socket.io &lt;br /&gt;
// http://codehenge.net/blog/2011/12/getting-started-with-node-js-and-socket-io-v0-7-part-2/&lt;br /&gt;
&amp;quot;use strict&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
var http = require('http'),&lt;br /&gt;
    url = require('url'),&lt;br /&gt;
    fs = require('fs'),&lt;br /&gt;
    exec = require('child_process').exec,&lt;br /&gt;
    server,&lt;br /&gt;
    connectCount = 0;	// Number of connections to server&lt;br /&gt;
&lt;br /&gt;
server = http.createServer(function (req, res) {&lt;br /&gt;
// server code&lt;br /&gt;
    var path = url.parse(req.url).pathname;&lt;br /&gt;
    console.log(&amp;quot;path: &amp;quot; + path);&lt;br /&gt;
    switch (path) {&lt;br /&gt;
    case '/':&lt;br /&gt;
        res.writeHead(200, {'Content-Type': 'text/html'});&lt;br /&gt;
        res.write('&amp;lt;h1&amp;gt;Hello!&amp;lt;/h1&amp;gt;Try&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;/buttonBox.html&amp;quot;&amp;gt;Button Box Demo&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;');&lt;br /&gt;
&lt;br /&gt;
        res.end();&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    default:		// This is so all the files will be sent.&lt;br /&gt;
        fs.readFile(__dirname + path, function (err, data) {&lt;br /&gt;
            if (err) {return send404(res); }&lt;br /&gt;
//            console.log(&amp;quot;path2: &amp;quot; + path);&lt;br /&gt;
            res.write(data, 'utf8');&lt;br /&gt;
            res.end();&lt;br /&gt;
        });&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
var send404 = function (res) {&lt;br /&gt;
    res.writeHead(404);&lt;br /&gt;
    res.write('404');&lt;br /&gt;
    res.end();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
server.listen(8081);&lt;br /&gt;
&lt;br /&gt;
// socket.io, I choose you&lt;br /&gt;
var io = require('socket.io').listen(server);&lt;br /&gt;
io.set('log level', 2);&lt;br /&gt;
&lt;br /&gt;
// on a 'connection' event&lt;br /&gt;
io.sockets.on('connection', function (socket) {&lt;br /&gt;
    var frameCount = 0;	// Counts the frames from arecord&lt;br /&gt;
    var lastFrame = 0;	// Last frame sent to browser&lt;br /&gt;
    console.log(&amp;quot;Connection &amp;quot; + socket.id + &amp;quot; accepted.&amp;quot;);&lt;br /&gt;
//    console.log(&amp;quot;socket: &amp;quot; + socket);&lt;br /&gt;
&lt;br /&gt;
    // now that we have our connected 'socket' object, we can &lt;br /&gt;
    // define its event handlers&lt;br /&gt;
&lt;br /&gt;
    // Make sure some needed files are there&lt;br /&gt;
    // The path to the analog devices changed from A5 to A6.  Check both.&lt;br /&gt;
    var ainPath = &amp;quot;/sys/devices/platform/omap/tsc/&amp;quot;;&lt;br /&gt;
//    if(!fs.existsSync(ainPath)) {&lt;br /&gt;
//        ainPath = &amp;quot;/sys/devices/platform/tsc/&amp;quot;;&lt;br /&gt;
//        if(!fs.existsSync(ainPath)) {&lt;br /&gt;
//            throw &amp;quot;Can't find &amp;quot; + ainPath;&lt;br /&gt;
//        }&lt;br /&gt;
//    }&lt;br /&gt;
    // Make sure gpio 7 is available.&lt;br /&gt;
    exec(&amp;quot;echo 7 &amp;gt; /sys/class/gpio/export&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    // Send value every time a 'message' is received.&lt;br /&gt;
    socket.on('ain', function (ainNum) {&lt;br /&gt;
//        var ainPath = &amp;quot;/sys/devices/platform/omap/tsc/ain&amp;quot; + ainNum;&lt;br /&gt;
        fs.readFile(ainPath + &amp;quot;ain&amp;quot; + ainNum, 'base64', function(err, data) {&lt;br /&gt;
            if(err) throw err;&lt;br /&gt;
            socket.emit('ain', data);&lt;br /&gt;
//            console.log('emitted ain: ' + data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('gpio', function (gpioNum) {&lt;br /&gt;
        var gpioPath = &amp;quot;/sys/class/gpio/gpio&amp;quot; + gpioNum + &amp;quot;/value&amp;quot;;&lt;br /&gt;
        fs.readFile(gpioPath, 'base64', function(err, data) {&lt;br /&gt;
            if (err) throw err;&lt;br /&gt;
            socket.emit('gpio', data);&lt;br /&gt;
//            console.log('emitted gpio: ' + data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('i2c', function (i2cNum) {&lt;br /&gt;
//        console.log('Got i2c request:' + i2cNum);&lt;br /&gt;
        exec('i2cget -y 3 ' + i2cNum + ' 0 w',&lt;br /&gt;
            function (error, stdout, stderr) {&lt;br /&gt;
//		The TMP102 returns a 12 bit value with the digits swapped&lt;br /&gt;
                stdout = '0x' + stdout.substring(4,6) + stdout.substring(2,4);&lt;br /&gt;
//                console.log('i2cget: &amp;quot;' + stdout + '&amp;quot;');&lt;br /&gt;
                if(error) { console.log('error: ' + error); }&lt;br /&gt;
                if(stderr) {console.log('stderr: ' + stderr); }&lt;br /&gt;
                socket.emit('i2c', stdout);&lt;br /&gt;
            });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    socket.on('led', function (ledNum) {&lt;br /&gt;
        var ledPath = &amp;quot;/sys/class/leds/beaglebone::usr&amp;quot; + ledNum + &amp;quot;/brightness&amp;quot;;&lt;br /&gt;
//        console.log('LED: ' + ledPath);&lt;br /&gt;
        fs.readFile(ledPath, 'utf8', function (err, data) {&lt;br /&gt;
            if(err) throw err;&lt;br /&gt;
            data = data.substring(0,1) === &amp;quot;1&amp;quot; ? &amp;quot;0&amp;quot; : &amp;quot;1&amp;quot;;&lt;br /&gt;
//            console.log(&amp;quot;LED%d: %s&amp;quot;, ledNum, data);&lt;br /&gt;
            fs.writeFile(ledPath, data);&lt;br /&gt;
        });&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
   var updateInterval = 100;&lt;br /&gt;
   function pushMessage() {&lt;br /&gt;
//        console.log('Got i2c request:' + 6);&lt;br /&gt;
        exec('/home/root/ECE497/MiniProject04/node.js/realtime/./a.out 0 0 ' + 3,&lt;br /&gt;
            function (error, stdout, stderr) {&lt;br /&gt;
		console.log('stdout:' + stdout);&lt;br /&gt;
		//console.log('stdout:' + parseFloat(stdout.substring(51,58))/100.0);&lt;br /&gt;
                if(error) { console.log('error: ' + error); }&lt;br /&gt;
                if(stderr) {console.log('stderr: ' + stderr); }&lt;br /&gt;
                socket.emit('i2c', stdout);&lt;br /&gt;
            });&lt;br /&gt;
        setTimeout(pushMessage, updateInterval);&lt;br /&gt;
    }&lt;br /&gt;
    pushMessage();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    socket.on('disconnect', function () {&lt;br /&gt;
        console.log(&amp;quot;Connection &amp;quot; + socket.id + &amp;quot; terminated.&amp;quot;);&lt;br /&gt;
        connectCount--;&lt;br /&gt;
        if(connectCount === 0) {&lt;br /&gt;
        }&lt;br /&gt;
        console.log(&amp;quot;connectCount = &amp;quot; + connectCount);&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    connectCount++;&lt;br /&gt;
    console.log(&amp;quot;connectCount = &amp;quot; + connectCount);&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== HTML Code ===&lt;br /&gt;
&lt;br /&gt;
This file is altered from example code and contains all the necessary formatting for the user interface and data representation. A also contains the script necessary to parse the string containing the sensor data sent by the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!doctype html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;Gyro Demo&amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;script src=&amp;quot;/json.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;!-- for ie --&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;/socket.io/socket.io.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;link href=&amp;quot;layout.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.flot.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
    &amp;lt;script src=&amp;quot;jquery.flot.navigate.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;h1&amp;gt;Gyro Demo &amp;lt;a href=&amp;quot;http://Rose-Hulman.edu&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;RoseLogo96.png&amp;quot; width=200 style=&amp;quot;float:right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
    &amp;lt;button id=&amp;quot;connect&amp;quot; onClick='connect()'/&amp;gt;Connect&amp;lt;/button&amp;gt;&lt;br /&gt;
    &amp;lt;button id=&amp;quot;disconnect&amp;quot; onClick='disconnect()'&amp;gt;Disconnect&amp;lt;/button&amp;gt;&lt;br /&gt;
    &amp;lt;span style=&amp;quot;position:relative; left:150px&amp;quot;&amp;gt;&lt;br /&gt;
    Analog: &amp;lt;input id=&amp;quot;ainNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:2em&amp;quot;&amp;gt;&lt;br /&gt;
    gpio: &amp;lt;input id=&amp;quot;gpioNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:2em&amp;quot;&amp;gt;&lt;br /&gt;
    i2c: &amp;lt;input id=&amp;quot;i2cNum&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;!--    &amp;lt;button id=&amp;quot;send&amp;quot; onClick='send()'/&amp;gt;Send Message&amp;lt;/button&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td&amp;gt;&amp;lt;div id=&amp;quot;plotTop&amp;quot; style=&amp;quot;width:550px;height:300px;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;samples&amp;lt;/center&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
    Update: &amp;lt;input id=&amp;quot;updateTopInterval&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt; ms&lt;br /&gt;
    &amp;lt;button id=&amp;quot;zoomout&amp;quot; onClick='plotTop.zoomOut()'&amp;gt;Zoom Out&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td&amp;gt;&amp;lt;div id=&amp;quot;plotBot&amp;quot; style=&amp;quot;width:550px;height:300px;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;samples&amp;lt;/center&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
    Update: &amp;lt;input id=&amp;quot;updateBotInterval&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;text-align: right; width:3em&amp;quot;&amp;gt; ms&lt;br /&gt;
    &amp;lt;button id=&amp;quot;zoomout&amp;quot; onClick='plotBot.zoomOut()'&amp;gt;Zoom Out&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led0&amp;quot; onClick='led(0)'/&amp;gt;LED 0&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led1&amp;quot; onClick='led(1)'/&amp;gt;LED 1&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led2&amp;quot; onClick='led(2)'/&amp;gt;LED 2&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;button id=&amp;quot;led3&amp;quot; onClick='led(3)'/&amp;gt;LED 3&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Button Box demo from the &amp;lt;a href=&amp;quot;http://elinux.org/index.php?title=Category:ECE497&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;32-bit Embedded Linux Class&amp;lt;/a&amp;gt;.&amp;lt;/b&amp;gt;&lt;br /&gt;
In this demo, the beagle bone pushes it sensor data to the web browser. Try moving the gyro or touching it to change its temprature. Try double-clicking to zoom and click and dragging to pan.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;a href=&amp;quot;http://beagleboard.org&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;beagle-hd-logo.gif&amp;quot; width=200 align=&amp;quot;right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;p id=&amp;quot;status&amp;quot;&amp;gt;Waiting for input&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;a href=&amp;quot;http://www.ti.com/sitara&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;img src=&amp;quot;hdr_ti_logo.gif&amp;quot; width=200 align=&amp;quot;right&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;p id=&amp;quot;message&amp;quot;&amp;gt;message&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt; &lt;br /&gt;
By &amp;lt;i&amp;gt;Ruffin White&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    var socket;&lt;br /&gt;
    var firstconnect = true,&lt;br /&gt;
        fs = 8000,&lt;br /&gt;
        Ts = 1/fs*1000,&lt;br /&gt;
        samples = 100,&lt;br /&gt;
        plotTop,&lt;br /&gt;
        plotBot,&lt;br /&gt;
        ainData = [],  iain = 0, &lt;br /&gt;
        gpioData = [], igpio = 0,&lt;br /&gt;
        i2cXData = [],  ii2cX = 0,&lt;br /&gt;
        i2cYData = [],  ii2cY = 0,&lt;br /&gt;
        i2cZData = [],  ii2cZ = 0,&lt;br /&gt;
        i2cTData = [],  ii2cT = 0,&lt;br /&gt;
        gpioNum = 7,&lt;br /&gt;
        ainNum  = 6,&lt;br /&gt;
        i2cNum  = &amp;quot;0x48&amp;quot;;&lt;br /&gt;
    ainData[samples] = 0;&lt;br /&gt;
    gpioData[samples] = 0;&lt;br /&gt;
    i2cXData[samples] = 0;&lt;br /&gt;
    i2cYData[samples] = 0;&lt;br /&gt;
    i2cZData[samples] = 0;&lt;br /&gt;
    i2cTData[samples] = 0;&lt;br /&gt;
&lt;br /&gt;
    function connect() {&lt;br /&gt;
      if(firstconnect) {&lt;br /&gt;
        socket = io.connect(null);&lt;br /&gt;
&lt;br /&gt;
        socket.on('message', function(data)&lt;br /&gt;
            { status_update(&amp;quot;Received: message&amp;quot;);});&lt;br /&gt;
        socket.on('connect', function()&lt;br /&gt;
            { status_update(&amp;quot;Connected to Server&amp;quot;); });&lt;br /&gt;
        socket.on('disconnect', function()&lt;br /&gt;
            { status_update(&amp;quot;Disconnected from Server&amp;quot;); });&lt;br /&gt;
        socket.on('reconnect', function()&lt;br /&gt;
            { status_update(&amp;quot;Reconnected to Server&amp;quot;); });&lt;br /&gt;
        socket.on('reconnecting', function( nextRetry )&lt;br /&gt;
            { status_update(&amp;quot;Reconnecting in &amp;quot; + nextRetry/1000 + &amp;quot; s&amp;quot;); });&lt;br /&gt;
        socket.on('reconnect_failed', function()&lt;br /&gt;
            { message(&amp;quot;Reconnect Failed&amp;quot;); });&lt;br /&gt;
&lt;br /&gt;
        socket.on('ain',  ain);&lt;br /&gt;
        socket.on('gpio', gpio);&lt;br /&gt;
        socket.on('i2c',  i2c);&lt;br /&gt;
&lt;br /&gt;
        firstconnect = false;&lt;br /&gt;
      }&lt;br /&gt;
      else {&lt;br /&gt;
        socket.socket.reconnect();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function disconnect() {&lt;br /&gt;
      socket.disconnect();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function led(ledNum) {&lt;br /&gt;
        socket.emit('led', ledNum);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // When new data arrived, convert it and plot it.&lt;br /&gt;
    function ain(data) {&lt;br /&gt;
        data = atob(data)/4096 * 1.8;&lt;br /&gt;
        data = isNaN(data) ? 0 : data;&lt;br /&gt;
//        status_update(&amp;quot;ain: &amp;quot; + data);&lt;br /&gt;
        ainData[iain] = [iain, data];&lt;br /&gt;
        iain++;&lt;br /&gt;
        if(iain &amp;gt;= samples) {&lt;br /&gt;
            iain = 0;&lt;br /&gt;
            ainData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotTop.setData([ ainData, gpioData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function gpio(data) {&lt;br /&gt;
        data = atob(data);&lt;br /&gt;
//        status_update(&amp;quot;gpio: &amp;quot; + data);&lt;br /&gt;
        gpioData[igpio] = [igpio, data];&lt;br /&gt;
        igpio++;&lt;br /&gt;
        if(igpio &amp;gt;= samples) {&lt;br /&gt;
            igpio = 0;&lt;br /&gt;
            gpioData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotTop.setData([ ainData, gpioData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
//gyroX: -00026 gyroY: -00012 gyroZ: 000073 gyroTemp: 002602&lt;br /&gt;
&lt;br /&gt;
    function i2c(data) {&lt;br /&gt;
        Xdata = parseInt(data.substring(6,12));&lt;br /&gt;
        Ydata = parseInt(data.substring(20,26));&lt;br /&gt;
        Zdata = parseInt(data.substring(34,40));&lt;br /&gt;
        Tdata = parseInt(data.substring(51,56));&lt;br /&gt;
        i2cXData[ii2cX] = [ii2cX, Xdata];&lt;br /&gt;
        i2cYData[ii2cY] = [ii2cY, Ydata];&lt;br /&gt;
        i2cZData[ii2cZ] = [ii2cZ, Zdata];&lt;br /&gt;
        i2cTData[ii2cT] = [ii2cT, Tdata];&lt;br /&gt;
        ii2cX++;&lt;br /&gt;
        if(ii2cX &amp;gt;= samples) {&lt;br /&gt;
            ii2cX = 0;&lt;br /&gt;
            i2cXData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cY] = [ii2cY, Xdata];&lt;br /&gt;
        ii2cY++;&lt;br /&gt;
        if(ii2cY &amp;gt;= samples) {&lt;br /&gt;
            ii2cY = 0;&lt;br /&gt;
            i2cYData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cZ] = [ii2cZ, Xdata];&lt;br /&gt;
        ii2cZ++;&lt;br /&gt;
        if(ii2cZ &amp;gt;= samples) {&lt;br /&gt;
            ii2cZ = 0;&lt;br /&gt;
            i2cZData = [];&lt;br /&gt;
        }&lt;br /&gt;
        i2cXData[ii2cT] = [ii2cT, Xdata];&lt;br /&gt;
        ii2cT++;&lt;br /&gt;
        if(ii2cT &amp;gt;= samples) {&lt;br /&gt;
            ii2cT = 0;&lt;br /&gt;
            i2cTData = [];&lt;br /&gt;
        }&lt;br /&gt;
        plotBot.setData([ i2cXData, i2cYData, i2cZData]);&lt;br /&gt;
        plotBot.draw();&lt;br /&gt;
        plotTop.setData([ i2cTData ]);&lt;br /&gt;
        plotTop.draw();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function status_update(txt){&lt;br /&gt;
      document.getElementById('status').innerHTML = txt;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function send(){&lt;br /&gt;
      socket.emit(&amp;quot;ain&amp;quot;, &amp;quot;Hello Server!&amp;quot;);    &lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    connect();&lt;br /&gt;
&lt;br /&gt;
$(function () {&lt;br /&gt;
&lt;br /&gt;
    function initPlotData() {&lt;br /&gt;
        // zip the generated y values with the x values&lt;br /&gt;
        var result = [];&lt;br /&gt;
        for (var i = 0; i &amp;lt;= samples; i++)&lt;br /&gt;
            result[i] = [i, 0];&lt;br /&gt;
        return result;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // setup control widget&lt;br /&gt;
    $(&amp;quot;#ainNum&amp;quot;).val(ainNum).change(function () {&lt;br /&gt;
        ainNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    $(&amp;quot;#gpioNum&amp;quot;).val(gpioNum).change(function () {&lt;br /&gt;
        gpioNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    $(&amp;quot;#i2cNum&amp;quot;).val(i2cNum).change(function () {&lt;br /&gt;
        i2cNum = $(this).val();&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    var updateTopInterval = 100;&lt;br /&gt;
    $(&amp;quot;#updateTopInterval&amp;quot;).val(updateTopInterval).change(function () {&lt;br /&gt;
        var v = $(this).val();&lt;br /&gt;
        if (v &amp;amp;&amp;amp; !isNaN(+v)) {&lt;br /&gt;
            updateTopInterval = +v;&lt;br /&gt;
            if (updateTopInterval &amp;lt; 25)&lt;br /&gt;
                updateTopInterval = 25;&lt;br /&gt;
            if (updateTopInterval &amp;gt; 2000)&lt;br /&gt;
                updateTopInterval = 2000;&lt;br /&gt;
            $(this).val(&amp;quot;&amp;quot; + updateTopInterval);&lt;br /&gt;
        }&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    var updateBotInterval = 100;&lt;br /&gt;
    $(&amp;quot;#updateBotInterval&amp;quot;).val(updateBotInterval).change(function () {&lt;br /&gt;
        var v = $(this).val();&lt;br /&gt;
        if (v &amp;amp;&amp;amp; !isNaN(+v)) {&lt;br /&gt;
            updateBotInterval = +v;&lt;br /&gt;
            if (updateBotInterval &amp;lt; 25)&lt;br /&gt;
                updateBotInterval = 25;&lt;br /&gt;
            if (updateBotInterval &amp;gt; 2000)&lt;br /&gt;
                updateBotInterval = 2000;&lt;br /&gt;
            $(this).val(&amp;quot;&amp;quot; + updateBotInterval);&lt;br /&gt;
        }&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    // setup plot&lt;br /&gt;
    var optionsTop = {&lt;br /&gt;
        series: { &lt;br /&gt;
            shadowSize: 0, // drawing is faster without shadows&lt;br /&gt;
            points: { show: false},&lt;br /&gt;
            lines:  { show: true, lineWidth: 5},&lt;br /&gt;
        }, &lt;br /&gt;
        yaxis:	{ min: 10, max: 35, &lt;br /&gt;
                  zoomRange: [10, 256], panRange: [-128, 128] },&lt;br /&gt;
        xaxis:	{ show: true, &lt;br /&gt;
                  zoomRange: [10, 100], panRange: [0, 100] },&lt;br /&gt;
        legend:	{ position: &amp;quot;sw&amp;quot; },&lt;br /&gt;
        zoom:	{ interactive: true, amount: 1.1 },&lt;br /&gt;
        pan:	{ interactive: true }&lt;br /&gt;
    };&lt;br /&gt;
    plotTop = $.plot($(&amp;quot;#plotTop&amp;quot;), &lt;br /&gt;
        [ &lt;br /&gt;
          { data:  initPlotData(), &lt;br /&gt;
            label: &amp;quot;GyroTemp&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
            optionsTop);&lt;br /&gt;
&lt;br /&gt;
    var optionsBot = {&lt;br /&gt;
        series: { &lt;br /&gt;
            shadowSize: 0, // drawing is faster without shadows&lt;br /&gt;
            points: { show: false},&lt;br /&gt;
            lines:  { show: true, lineWidth: 5},&lt;br /&gt;
            //color: 2&lt;br /&gt;
        }, &lt;br /&gt;
        yaxis:	{ min: -100, max: 100, &lt;br /&gt;
                  zoomRange: [10, 256], panRange: [60, 100] },&lt;br /&gt;
        xaxis:	{ show: true, &lt;br /&gt;
                  zoomRange: [10, 100], panRange: [0, 100] },&lt;br /&gt;
        legend:	{ position: &amp;quot;sw&amp;quot; },&lt;br /&gt;
        zoom:	{ interactive: true, amount: 1.1 },&lt;br /&gt;
        pan:	{ interactive: true }&lt;br /&gt;
    };&lt;br /&gt;
    plotBot = $.plot($(&amp;quot;#plotBot&amp;quot;), &lt;br /&gt;
        [ &lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroX&amp;quot;},&lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroY&amp;quot;},&lt;br /&gt;
          { data:  initPlotData(),&lt;br /&gt;
            label: &amp;quot;GyroZ&amp;quot;}&lt;br /&gt;
        ],&lt;br /&gt;
            optionsBot);&lt;br /&gt;
&lt;br /&gt;
    // Request data every updateInterval ms&lt;br /&gt;
    function updateTop() {&lt;br /&gt;
        socket.emit(&amp;quot;ain&amp;quot;,  ainNum);&lt;br /&gt;
        socket.emit(&amp;quot;gpio&amp;quot;, gpioNum);&lt;br /&gt;
        setTimeout(updateTop, updateTopInterval);&lt;br /&gt;
    }&lt;br /&gt;
    //updateTop();&lt;br /&gt;
&lt;br /&gt;
    function updateBot() {&lt;br /&gt;
        socket.emit(&amp;quot;i2c&amp;quot;,  i2cNum);&lt;br /&gt;
        setTimeout(updateBot, updateBotInterval);&lt;br /&gt;
    }&lt;br /&gt;
    //updateBot();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documents ==&lt;br /&gt;
&lt;br /&gt;
[[SparkFun:_ITG-3200,Triple-Axis_Gyro]]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/ITG-3200-v10.pdf Schematic]&lt;br /&gt;
&lt;br /&gt;
[http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Gyros/3-Axis/ITG-3200-v11.zip Eagle Files]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/tutorials/265 Quickstart Guide]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf ITG-3200 Datasheet]&lt;br /&gt;
&lt;br /&gt;
[http://www.sparkfun.com/datasheets/Sensors/Gyro/IDG-3200-ATmega328-4-30-10.zip Code (ATmega328)]&lt;br /&gt;
&lt;br /&gt;
[http://mbed.org/cookbook/ITG-3200-Gyroscope Example]&lt;br /&gt;
&lt;br /&gt;
[https://www.sparkfun.com/products/9801 Sparkfun]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ruffsl/ECE497 Github Repo]&lt;br /&gt;
&lt;br /&gt;
{{RuffFoot}}&lt;/div&gt;</summary>
		<author><name>Ruff</name></author>	</entry>

	</feed>