<?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=Geislekj&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=Geislekj&amp;feedformat=atom"/>
		<link rel="alternate" type="text/html" href="http://elinux.org/Special:Contributions/Geislekj"/>
		<updated>2013-05-24T10:41:13Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.21alpha</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>2012-11-14T04:16:45Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* Conclusions */&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 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;
[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>Geislekj</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-14T04:15:14Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* Install 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 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;
[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>Geislekj</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-14T04:14:39Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &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 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;
::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>Geislekj</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-13T17:50:46Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
*'''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>Geislekj</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-13T17:43:28Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
*'''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;
:*'''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;
== 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>Geislekj</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-13T17:40:36Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* Install 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 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;
*'''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;
:*'''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;
== 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>Geislekj</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-13T17:40:08Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
*'''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;
*'''github'''&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;
:*'''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;
== 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>Geislekj</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-13T17:39:47Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* Install 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 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;
*'''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;
*'''github'''&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;
:*'''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;
== 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>Geislekj</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-13T17:39:05Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* Install 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 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;
*'''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;
*'''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$ '''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;
:*'''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;
== 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>Geislekj</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-13T17:28:44Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
*'''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;
*'''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;
== 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;
== 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>Geislekj</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-13T17:28:00Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
== Install Instructions ==&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;
== 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;
== 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>Geislekj</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-13T17:26:56Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
== 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>Geislekj</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-13T17:13:27Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* Conclusions */&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 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 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>Geislekj</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-13T17:04:11Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
&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 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 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;
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>Geislekj</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-13T17:02:18Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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 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;
:::This is a c program that exist in the C-Program Directory.&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;
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>Geislekj</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:59:03Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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 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;
:::This is a c program that exist in the C-Program Directory.&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;
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>Geislekj</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:58:28Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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 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;
:::This is a c program that exist in the C-Program Directory.&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;
&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>Geislekj</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:57:52Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* Python */&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 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;
:::This is a c program that exist in the C-Program Directory.&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 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>Geislekj</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:55:50Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* C */&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 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;
:::This is a c program that exist in the C-Program Directory.&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;
&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>Geislekj</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:50:14Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
&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 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;
:::This is a c program that exist in the C-Program Directory.&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>Geislekj</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:47:16Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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 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 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>Geislekj</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:30:37Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;What do I have to change to make this work in my Bone?&amp;lt;/span&amp;gt;&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>Geislekj</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:22:26Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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'''&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;What do I have to change to make this work in my Bone?&amp;lt;/span&amp;gt;&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>Geislekj</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-08T03:58:59Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
== 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'''&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;What do I have to change to make this work in my Bone?&amp;lt;/span&amp;gt;&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>Geislekj</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-08T03:58:32Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
== 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'''&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;('''Bold''' the command the user types)&amp;lt;/span&amp;gt;&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;(Why did the ''plughw'' number change?)&amp;lt;/span&amp;gt;&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;What do I have to change to make this work in my Bone?&amp;lt;/span&amp;gt;&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>Geislekj</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-08T03:21:00Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
== 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'''&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;('''Bold''' the command the user types)&amp;lt;/span&amp;gt;&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;(Why did the ''plughw'' number change?)&amp;lt;/span&amp;gt;&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;What do I have to change to make this work in my Bone?&amp;lt;/span&amp;gt;&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>Geislekj</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-08T03:20:37Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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 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;
== 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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;(Use the 'Git Read-Only' path here)&amp;lt;/span&amp;gt;&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;
== 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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;('''Bold''' the command the user types)&amp;lt;/span&amp;gt;&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;(Why did the ''plughw'' number change?)&amp;lt;/span&amp;gt;&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;What do I have to change to make this work in my Bone?&amp;lt;/span&amp;gt;&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>Geislekj</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-08T03:16:34Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &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 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;
== 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 https://github.com/geislekj/BeagleBoardVNS.git'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;(Use the 'Git Read-Only' path here)&amp;lt;/span&amp;gt;&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;
== 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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;('''Bold''' the command the user types)&amp;lt;/span&amp;gt;&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;(Why did the ''plughw'' number change?)&amp;lt;/span&amp;gt;&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;What do I have to change to make this work in my Bone?&amp;lt;/span&amp;gt;&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>Geislekj</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-08T03:15:31Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &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 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;
== Hardware ==&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;(I suggest putting this before the Software section.  An interested user needs to know what hardware to have before downloading the software)&amp;lt;/span&amp;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;
== 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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;(Use the 'Git Read-Only' path here)&amp;lt;/span&amp;gt;&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;
== 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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;('''Bold''' the command the user types)&amp;lt;/span&amp;gt;&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;(Why did the ''plughw'' number change?)&amp;lt;/span&amp;gt;&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;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;What do I have to change to make this work in my Bone?&amp;lt;/span&amp;gt;&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>Geislekj</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Contributions_and_Project_Status</id>
		<title>ECE497 Contributions and Project Status</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Contributions_and_Project_Status"/>
				<updated>2012-11-06T17:32:47Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Contributions]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
== Fall 2012 ==&lt;br /&gt;
&lt;br /&gt;
=== Project Status ===&lt;br /&gt;
&lt;br /&gt;
Please edit this page and add your project to this list. Copy my [[ECE497 Project Template]] to your own eLinux page and include the title of your project in the name of the page.  &lt;br /&gt;
&lt;br /&gt;
Please make the list alphabetical by family name.&lt;br /&gt;
&lt;br /&gt;
Take a look at what you and others have contributed.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Contributions&lt;br /&gt;
! Project&lt;br /&gt;
! git repository&lt;br /&gt;
|-&lt;br /&gt;
| [[User:atniptw | Tom Atnip]]&lt;br /&gt;
| [[Special:Contributions/atniptw|contrib]]&lt;br /&gt;
| [[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
| [https://github.com/atniptw/ atniptw]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:larmorgs | Greg Larmore]]&lt;br /&gt;
| [[Special:Contributions/larmorgs|contrib]]&lt;br /&gt;
| [[ECE497 SPI Project | SPI Project]]&lt;br /&gt;
| [https://github.com/larmorgs Greg Larmore]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:jessebrannon | Jesse Brannon]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE497 Project Rover | Rover]]&lt;br /&gt;
| [https://github.com/brannojs/ brannojs]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Xinyu1991 | Xinyu Cheng]]&lt;br /&gt;
| [[Special:Contributions/Xinyu1991|contrib]]&lt;br /&gt;
| [[ECE497_Project:_Kinect | Kinect]]&lt;br /&gt;
| [https://github.com/xinyu1991/ Xinyu Cheng]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:correlbn | Bryan Correll]]&lt;br /&gt;
| [[Special:Contributions/correlbn|contrib]]&lt;br /&gt;
| [[BeagleBone PRU | BeagleBone PRU]]&lt;br /&gt;
| [https://github.com/correlbn/My-Beagle-Project/ Correlbn]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:draneaw | Alex Drane]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE497 draneaw Project | My Beagle Project]]&lt;br /&gt;
| [https://github.com/draneaw/My-Beagle-Project draneaw]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:duganje | Josh Dugan]]&lt;br /&gt;
| [[Special:Contributions/duganje|contrib]]&lt;br /&gt;
| [[ECE497 Project: XBee|XBee]]&lt;br /&gt;
| [https://github.com/duganje/ duganje]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Geislekj | Kevin Geisler]]&lt;br /&gt;
| [[Special:Contributions/geislekj|contrib]]&lt;br /&gt;
| [[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
| [https://github.com/geislekj/ geislekj]&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| [[User:chris.good | Christopher A Good]]&lt;br /&gt;
| [[Special:Contributions/Chris.good|contrib]]&lt;br /&gt;
| [[ECE497 Project RoverGUI | RoverGUI]]&lt;br /&gt;
| [https://github.com/goodca/ goodca]&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| [[User:hansenrl | Ross Hansen]]&lt;br /&gt;
| [[Special:Contributions/hansenrl|contrib]]&lt;br /&gt;
| [[ECE497 Project Rover | Rover]]&lt;br /&gt;
| [https://github.com/hansenrl/ Hansenrl]&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| [[User:jungeml | Michael Junge]]&lt;br /&gt;
| [[Special:Contributions/jungeml|contrib]]&lt;br /&gt;
| [[ECE497 Project Rover | Rover]]&lt;br /&gt;
| [https://github.com/jungeml/ Jungeml]&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Lix | Xia Li]]&lt;br /&gt;
| [[Special:Contributions/Lix|contrib]]&lt;br /&gt;
| [[ECE497 Project: Kinect | Kinect]]&lt;br /&gt;
| [https://github.com/1984xiali/ xiali]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:mmoravec | Matthew Moravec]]&lt;br /&gt;
| [[Special:Contributions/mmoravec|contrib]]&lt;br /&gt;
| [[ECE497 Project: XBee|XBee]]&lt;br /&gt;
| [https://github.com/mmoravec/ mmoravec]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:ngop | Peter Ngo]]&lt;br /&gt;
| [[Special:Contributions/ngop|contrib]]&lt;br /&gt;
| [[BeagleBone PRU | BeagleBone PRU]]&lt;br /&gt;
| [https://github.com/ngop/ ngop]&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| [[User:shinnsm|Stephen Shinn]]&lt;br /&gt;
| [[Special:Contributions/shinnsm|contrib]]&lt;br /&gt;
| [[ECE497 Project: XBee|XBee]]&lt;br /&gt;
| [https://github.com/shinnsm shinnsm]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Yoder | Mark A. Yoder]]&lt;br /&gt;
| [[Special:Contributions/Yoder | contrib]]&lt;br /&gt;
| [[ECE497 Project Template | My Beagle Project]]&lt;br /&gt;
| [https://github.com/MarkAYoder MarkAYoder]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Popenhjc | James Popenhagen]]&lt;br /&gt;
| [[Special:Contributions/Popenhjc|contrib]]&lt;br /&gt;
| [[BeagleBone PRU | BeagleBone PRU]]&lt;br /&gt;
| [https://github.com/popenhjc/ popenhjc]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Whiteer | Elias White]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE497 SLAM via ROS | My Beagle Project]]&lt;br /&gt;
| [https://github.com/whiteer whiteer]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:ruff | Ruffin White]]&lt;br /&gt;
| [[Special:Contributions/ruff|contrib]]&lt;br /&gt;
| [[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
| [https://github.com/ruffsl/ ruffsl]&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Richarsm | Sean Richardson]]&lt;br /&gt;
| [[Special:Contributions/Richarsm|contrib]]&lt;br /&gt;
| [[ECE497 SPI Project | SPI Project]]&lt;br /&gt;
| [https://github.com/seanrich Sean Richardson]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Millerap | Andrew Miller]]&lt;br /&gt;
| [[Special:Contributions/Millerap|contrib]]&lt;br /&gt;
| [[BeagleBone PRU | BeagleBone PRU]]&lt;br /&gt;
| [https://github.com/millerap millerap]&lt;br /&gt;
|-| &lt;br /&gt;
| [[User:Astroricks | Yue Zhang]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE497 Yue Zhang Project | My Beagle Project]]&lt;br /&gt;
| [https://github.com/Astroricks/Beagle-Project Yue Zhang]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Lobdeljt | John Lobdell]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE 497 lobdeljt Project | My Beagle Project]]&lt;br /&gt;
| [https://github.com/jtlobdell jtlobdell]&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Winter 2011-2012 ==&lt;br /&gt;
&lt;br /&gt;
=== Contributions ===&lt;br /&gt;
&lt;br /&gt;
# [[Special:Contributions/Yuming | Yuming Cao]]&lt;br /&gt;
# [[Special:Contributions/Yifei | Yifei Li]]&lt;br /&gt;
# [[Special:Contributions/Harrisgw | Greg Harrison]]&lt;br /&gt;
# [[Special:Contributions/mac | Jack Ma]]&lt;br /&gt;
# [[Special:Contributions/Gemini91 | Guanqun Wang]]&lt;br /&gt;
# [[Special:Contributions/Yanj | Mona Yan]]&lt;br /&gt;
# [[Special:Contributions/Yoder | Mark A. Yoder]]&lt;br /&gt;
# [[Special:Contributions/Yuhasmj | Michael Yuhas]]&lt;br /&gt;
# [[Special:Contributions/Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
# [[Special:Contributions/Zitnikdj | David Zitnik]]&lt;br /&gt;
# [[Special:Contributions/Zitnikdj | Alex Drane]]&lt;br /&gt;
# [[Special:Contributions/jessebrannon | Jesse Brannon]]&lt;br /&gt;
# [[Special:Contributions/larmorgs | Greg Larmore]]&lt;br /&gt;
# [[Special:Contributions/jungeml | Michael Junge]]&lt;br /&gt;
# [[Special:Contributions/millerap | Andrew Miller]]&lt;br /&gt;
# [[Special:Contributions/correlbn | Bryan Correll]]&lt;br /&gt;
&lt;br /&gt;
=== Project Status ===&lt;br /&gt;
&lt;br /&gt;
# [[User:Yoder | Mark A. Yoder]], [[ECE497 Project Template | My Beagle Project]]&lt;br /&gt;
# [[user:Yanj|Mona Yan]] and [[user:Harrisgw| Greg Harrison]], [[PS EYE QT PROJECT | Playstation Eye Audio with Qt]]&lt;br /&gt;
# [[user:Caogecym | Yuming Cao]] and [[user:Ziyi Zhang | Ziyi Zhang]], [[Node.js Weather Station]]&lt;br /&gt;
# [[user:Yifei| Yifei Li]] and [[user:Gemini91| Guanqun Wang]], [[ Kinect Project | Play games using Kinect on Beagleboard]]&lt;br /&gt;
# [[user:Yuhasmj| Michael J. Yuhas]] and [[user:mac | Jack Ma]], [[ Multiple Partitions via U-boot | Multiple Partitions via U-boot ]]&lt;br /&gt;
# [[user:Zitnikdj| David Zitnik]], [[ ECE497 Project: Twitter Java Application | Twitter Java Application ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Geislekj</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Contributions_and_Project_Status</id>
		<title>ECE497 Contributions and Project Status</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Contributions_and_Project_Status"/>
				<updated>2012-11-06T17:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Contributions]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
== Fall 2012 ==&lt;br /&gt;
&lt;br /&gt;
=== Project Status ===&lt;br /&gt;
&lt;br /&gt;
Please edit this page and add your project to this list. Copy my [[ECE497 Project Template]] to your own eLinux page and include the title of your project in the name of the page.  &lt;br /&gt;
&lt;br /&gt;
Please make the list alphabetical by family name.&lt;br /&gt;
&lt;br /&gt;
Take a look at what you and others have contributed.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Contributions&lt;br /&gt;
! Project&lt;br /&gt;
! git repository&lt;br /&gt;
|-&lt;br /&gt;
| [[User:atniptw | Tom Atnip]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
| [https://github.com/atniptw/ atniptw]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:larmorgs | Greg Larmore]]&lt;br /&gt;
| [[Special:Contributions/larmorgs|contrib]]&lt;br /&gt;
| [[ECE497 SPI Project | SPI Project]]&lt;br /&gt;
| [https://github.com/larmorgs Greg Larmore]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:jessebrannon | Jesse Brannon]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE497 Project Rover | Rover]]&lt;br /&gt;
| [https://github.com/brannojs/ brannojs]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Xinyu1991 | Xinyu Cheng]]&lt;br /&gt;
| [[Special:Contributions/Xinyu1991|contrib]]&lt;br /&gt;
| [[ECE497_Project:_Kinect | Kinect]]&lt;br /&gt;
| [https://github.com/xinyu1991/ Xinyu Cheng]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:correlbn | Bryan Correll]]&lt;br /&gt;
| [[Special:Contributions/correlbn|contrib]]&lt;br /&gt;
| [[BeagleBone PRU | BeagleBone PRU]]&lt;br /&gt;
| [https://github.com/correlbn/My-Beagle-Project/ Correlbn]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:draneaw | Alex Drane]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE497 draneaw Project | My Beagle Project]]&lt;br /&gt;
| [https://github.com/draneaw/My-Beagle-Project draneaw]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:duganje | Josh Dugan]]&lt;br /&gt;
| [[Special:Contributions/duganje|contrib]]&lt;br /&gt;
| [[ECE497 Project: XBee|XBee]]&lt;br /&gt;
| [https://github.com/duganje/ duganje]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Geislekj | Kevin Geisler]]&lt;br /&gt;
| [[Special:Contributions/geislekj|contrib]]&lt;br /&gt;
| [[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
| [https://github.com/geislekj/ geislekj]&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| [[User:chris.good | Christopher A Good]]&lt;br /&gt;
| [[Special:Contributions/Chris.good|contrib]]&lt;br /&gt;
| [[ECE497 Project RoverGUI | RoverGUI]]&lt;br /&gt;
| [https://github.com/goodca/ goodca]&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| [[User:hansenrl | Ross Hansen]]&lt;br /&gt;
| [[Special:Contributions/hansenrl|contrib]]&lt;br /&gt;
| [[ECE497 Project Rover | Rover]]&lt;br /&gt;
| [https://github.com/hansenrl/ Hansenrl]&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| [[User:jungeml | Michael Junge]]&lt;br /&gt;
| [[Special:Contributions/jungeml|contrib]]&lt;br /&gt;
| [[ECE497 Project Rover | Rover]]&lt;br /&gt;
| [https://github.com/jungeml/ Jungeml]&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Lix | Xia Li]]&lt;br /&gt;
| [[Special:Contributions/Lix|contrib]]&lt;br /&gt;
| [[ECE497 Project: Kinect | Kinect]]&lt;br /&gt;
| [https://github.com/1984xiali/ xiali]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:mmoravec | Matthew Moravec]]&lt;br /&gt;
| [[Special:Contributions/mmoravec|contrib]]&lt;br /&gt;
| [[ECE497 Project: XBee|XBee]]&lt;br /&gt;
| [https://github.com/mmoravec/ mmoravec]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:ngop | Peter Ngo]]&lt;br /&gt;
| [[Special:Contributions/ngop|contrib]]&lt;br /&gt;
| [[BeagleBone PRU | BeagleBone PRU]]&lt;br /&gt;
| [https://github.com/ngop/ ngop]&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| [[User:shinnsm|Stephen Shinn]]&lt;br /&gt;
| [[Special:Contributions/shinnsm|contrib]]&lt;br /&gt;
| [[ECE497 Project: XBee|XBee]]&lt;br /&gt;
| [https://github.com/shinnsm shinnsm]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Yoder | Mark A. Yoder]]&lt;br /&gt;
| [[Special:Contributions/Yoder | contrib]]&lt;br /&gt;
| [[ECE497 Project Template | My Beagle Project]]&lt;br /&gt;
| [https://github.com/MarkAYoder MarkAYoder]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Popenhjc | James Popenhagen]]&lt;br /&gt;
| [[Special:Contributions/Popenhjc|contrib]]&lt;br /&gt;
| [[BeagleBone PRU | BeagleBone PRU]]&lt;br /&gt;
| [https://github.com/popenhjc/ popenhjc]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Whiteer | Elias White]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE497 SLAM via ROS | My Beagle Project]]&lt;br /&gt;
| [https://github.com/whiteer whiteer]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:ruff | Ruffin White]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
| [https://github.com/ruffsl/ ruffsl]&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Richarsm | Sean Richardson]]&lt;br /&gt;
| [[Special:Contributions/Richarsm|contrib]]&lt;br /&gt;
| [[ECE497 SPI Project | SPI Project]]&lt;br /&gt;
| [https://github.com/seanrich Sean Richardson]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Millerap | Andrew Miller]]&lt;br /&gt;
| [[Special:Contributions/Millerap|contrib]]&lt;br /&gt;
| [[BeagleBone PRU | BeagleBone PRU]]&lt;br /&gt;
| [https://github.com/millerap millerap]&lt;br /&gt;
|-| &lt;br /&gt;
| [[User:Astroricks | Yue Zhang]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE497 Yue Zhang Project | My Beagle Project]]&lt;br /&gt;
| [https://github.com/Astroricks/Beagle-Project Yue Zhang]&lt;br /&gt;
|-&lt;br /&gt;
| [[User:Lobdeljt | John Lobdell]]&lt;br /&gt;
| &lt;br /&gt;
| [[ECE 497 lobdeljt Project | My Beagle Project]]&lt;br /&gt;
| [https://github.com/jtlobdell jtlobdell]&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Winter 2011-2012 ==&lt;br /&gt;
&lt;br /&gt;
=== Contributions ===&lt;br /&gt;
&lt;br /&gt;
# [[Special:Contributions/Yuming | Yuming Cao]]&lt;br /&gt;
# [[Special:Contributions/Yifei | Yifei Li]]&lt;br /&gt;
# [[Special:Contributions/Harrisgw | Greg Harrison]]&lt;br /&gt;
# [[Special:Contributions/mac | Jack Ma]]&lt;br /&gt;
# [[Special:Contributions/Gemini91 | Guanqun Wang]]&lt;br /&gt;
# [[Special:Contributions/Yanj | Mona Yan]]&lt;br /&gt;
# [[Special:Contributions/Yoder | Mark A. Yoder]]&lt;br /&gt;
# [[Special:Contributions/Yuhasmj | Michael Yuhas]]&lt;br /&gt;
# [[Special:Contributions/Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
# [[Special:Contributions/Zitnikdj | David Zitnik]]&lt;br /&gt;
# [[Special:Contributions/Zitnikdj | Alex Drane]]&lt;br /&gt;
# [[Special:Contributions/jessebrannon | Jesse Brannon]]&lt;br /&gt;
# [[Special:Contributions/larmorgs | Greg Larmore]]&lt;br /&gt;
# [[Special:Contributions/jungeml | Michael Junge]]&lt;br /&gt;
# [[Special:Contributions/millerap | Andrew Miller]]&lt;br /&gt;
# [[Special:Contributions/correlbn | Bryan Correll]]&lt;br /&gt;
&lt;br /&gt;
=== Project Status ===&lt;br /&gt;
&lt;br /&gt;
# [[User:Yoder | Mark A. Yoder]], [[ECE497 Project Template | My Beagle Project]]&lt;br /&gt;
# [[user:Yanj|Mona Yan]] and [[user:Harrisgw| Greg Harrison]], [[PS EYE QT PROJECT | Playstation Eye Audio with Qt]]&lt;br /&gt;
# [[user:Caogecym | Yuming Cao]] and [[user:Ziyi Zhang | Ziyi Zhang]], [[Node.js Weather Station]]&lt;br /&gt;
# [[user:Yifei| Yifei Li]] and [[user:Gemini91| Guanqun Wang]], [[ Kinect Project | Play games using Kinect on Beagleboard]]&lt;br /&gt;
# [[user:Yuhasmj| Michael J. Yuhas]] and [[user:mac | Jack Ma]], [[ Multiple Partitions via U-boot | Multiple Partitions via U-boot ]]&lt;br /&gt;
# [[user:Zitnikdj| David Zitnik]], [[ ECE497 Project: Twitter Java Application | Twitter Java Application ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Geislekj</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Geislekj</id>
		<title>User:Geislekj</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Geislekj"/>
				<updated>2012-11-06T17:29:13Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{GeislekjHead}}&lt;br /&gt;
&lt;br /&gt;
* Computer Science Major, Class of 2013 &lt;br /&gt;
* Robotics Minor&lt;br /&gt;
* Electrical Engineering Minor&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
[[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
&lt;br /&gt;
== Mini-projects ==&lt;br /&gt;
*[[Sparkfun:_Large_Piezo_Vibration_Sensor_-_With_Mass]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/geislekj/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497 |Ug]]&lt;/div&gt;</summary>
		<author><name>Geislekj</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-02T16:05:55Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &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|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;
::: 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;
'''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, google is blocking attachments however&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>Geislekj</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-02T16:04:05Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
== 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|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;
::: 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;
'''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, google is blocking attachments however&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>Geislekj</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-02T16:03:39Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
== 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|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;
::: 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;
'''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, google is blocking attachments however&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>Geislekj</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-02T16:02:40Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
== 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|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;
::: 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;
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, google is blocking attachments however&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>Geislekj</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-02T16:01:01Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
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;
*'''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|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;
::: 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: &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;
# 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 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>Geislekj</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Geislekj</id>
		<title>User:Geislekj</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Geislekj"/>
				<updated>2012-11-02T04:59:23Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{GeislekjHead}}&lt;br /&gt;
&lt;br /&gt;
* Computer Science Major, Class of 2013 &lt;br /&gt;
* Robotics Minor&lt;br /&gt;
* Electrical Engineering Minor&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
[[ECE497 Beagle VNS | Beagle VNS]]&lt;br /&gt;
&lt;br /&gt;
== Mini-projects ==&lt;br /&gt;
*[[Sparkfun:_Large_Piezo_Vibration_Sensor_-_With_Mass]]&lt;br /&gt;
&lt;br /&gt;
== Github Repo ==&lt;br /&gt;
&lt;br /&gt;
[[http://github.com/geislekj/ECE497 github]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497]]&lt;/div&gt;</summary>
		<author><name>Geislekj</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_Large_Piezo_Vibration_Sensor_-_With_Mass</id>
		<title>Sparkfun: Large Piezo Vibration Sensor - With Mass</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_Large_Piezo_Vibration_Sensor_-_With_Mass"/>
				<updated>2012-11-02T04:55:45Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{GeislekjHead}}&lt;br /&gt;
[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview: 1, Nice overview, but a close up picture of the device would help.&lt;br /&gt;
Wiring:   1, What op-amp are you using?  A schematic of your actual circuit would be a big help.&lt;br /&gt;
Code:     2&lt;br /&gt;
git:      2&lt;br /&gt;
Demo:     2&lt;br /&gt;
Total:    8/10&lt;br /&gt;
Comments: Good start, but more specific details are needed.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
The [http://dlnmh9ip6v2uc.cloudfront.net/images/products/9/1/9/7/09197-02-L.jpg Large Piezo Vibration Sensor] is a basic piezo sensor which is often used for flex, touch, vibration and shock measurements.  This sensor acts like a small capacitor which discharges up to +/-90V when the film moves back and forth. Some common uses this type of sensor are for impact sensing or as a flexible switch.  A larger scale example are piezo sensors that are laid within the road for use of traffic signals.&lt;br /&gt;
&lt;br /&gt;
This sensor can be purchased at [https://www.sparkfun.com/products/9197 SparkFun].&lt;br /&gt;
&lt;br /&gt;
The [https://www.sparkfun.com/datasheets/Sensors/Flex/MSI-techman.pdf Technical Manual] and [http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/ForceFlex/LDT_Series.pdf datasheet] can also be found on Sparkfun's website.&lt;br /&gt;
&lt;br /&gt;
[[File:PiezoCircuit.PNG|thumb |alt=Example alt text |This is and example circuit layout of the piezo vibration sensor using an op amp and the beagle board.]]&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Since the piezo sensor acts like a small capacitor, you can connect on a bread board as such.  However an additional resistor is needed in order affect the low frequency of measurement. This is called the &amp;quot;loading effect&amp;quot;.  Additionally, if the signal from the piezo sensor is too low an op amp may be necessary.&lt;br /&gt;
&lt;br /&gt;
More specific information and circuit diagrams can be found in the [https://www.sparkfun.com/datasheets/Sensors/Flex/MSI-techman.pdf Technical Manual] on pages 36-40.&lt;br /&gt;
&lt;br /&gt;
==Beagle Bone Usage==&lt;br /&gt;
&lt;br /&gt;
The value being read from the piezo sensor will be a voltage up to +/-0.5V.  This means that an analog pin must be used to read the value from the sensor.  The voltage being supplied to the sensor affects how much sensitivity you will receive.  Look in the technical manual to find a desired voltage that will work for you.  For the example below, I simply used a 5V source.&lt;br /&gt;
&lt;br /&gt;
[[File:Piezo-breadboard-layout.jpg|thumb |alt=Example alt text |This is a picture of the layout of the piezo vibration sensor using an op amp and the beagle board.]]&lt;br /&gt;
&lt;br /&gt;
==Reading the Analog Signal==&lt;br /&gt;
&lt;br /&gt;
You can simply read the value of the piezo sensor from the terminal by reading the contents of a file in the /sys/devices/platform/omap/tsc/ain# directory.  The # is 1 + the number of the analog pin you selected as your analog input.  However this method will not allow you to accurately see the change of voltage as the film moves.  To do this you will need to write a c program to print the values to the terminal repeatably or plot the voltage over time.  The sample code below shows a simple program to print the voltage of the sensor to the screen.&lt;br /&gt;
&lt;br /&gt;
==Sample Code==&lt;br /&gt;
The following code can be found on [https://github.com/geislekj/ECE497/tree/master/miniProject2 git hub].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/**************************************&lt;br /&gt;
Example Program for the Large Piezo Vibration Sensor - With Mass&lt;br /&gt;
&lt;br /&gt;
This will display the value of the AIN0 Pin directly to the terminal repeatively.&lt;br /&gt;
&lt;br /&gt;
wrtten by Kevin Geisler, 23-Sept-2012&lt;br /&gt;
***************************************/&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define SYSFS_AIN1_DIR &amp;quot;/sys/devices/platform/omap/tsc/ain2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FILE *fp; &lt;br /&gt;
&lt;br /&gt;
int readanalog(){&lt;br /&gt;
	if ((fp = fopen(SYSFS_AIN1_DIR, &amp;quot;r&amp;quot;)) == NULL)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Cannot open value file.\n&amp;quot;);&lt;br /&gt;
		exit(1);&lt;br /&gt;
	}	&lt;br /&gt;
&lt;br /&gt;
	//Set pointer to begining of the file&lt;br /&gt;
	rewind(fp);&lt;br /&gt;
	//Write our value of &amp;quot;0&amp;quot; to the file &lt;br /&gt;
	char inString[10];&lt;br /&gt;
	fgets(&amp;amp;inString, 10, fp);&lt;br /&gt;
	fflush(fp);&lt;br /&gt;
//			printf(&amp;quot;...value set to 0...\n&amp;quot;);	&lt;br /&gt;
	fclose(fp);&lt;br /&gt;
//	printf(inString);&lt;br /&gt;
	return atoi(&amp;amp;inString);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
	//Run an infinite loop - will require Ctrl-C to exit this program&lt;br /&gt;
	while(1)&lt;br /&gt;
	{&lt;br /&gt;
	printf(&amp;quot;%d\n&amp;quot;,readanalog());&lt;br /&gt;
	usleep(100000);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Geislekj</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_Large_Piezo_Vibration_Sensor_-_With_Mass</id>
		<title>Sparkfun: Large Piezo Vibration Sensor - With Mass</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_Large_Piezo_Vibration_Sensor_-_With_Mass"/>
				<updated>2012-11-02T04:55:25Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{GeislerHead}}&lt;br /&gt;
[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview: 1, Nice overview, but a close up picture of the device would help.&lt;br /&gt;
Wiring:   1, What op-amp are you using?  A schematic of your actual circuit would be a big help.&lt;br /&gt;
Code:     2&lt;br /&gt;
git:      2&lt;br /&gt;
Demo:     2&lt;br /&gt;
Total:    8/10&lt;br /&gt;
Comments: Good start, but more specific details are needed.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
The [http://dlnmh9ip6v2uc.cloudfront.net/images/products/9/1/9/7/09197-02-L.jpg Large Piezo Vibration Sensor] is a basic piezo sensor which is often used for flex, touch, vibration and shock measurements.  This sensor acts like a small capacitor which discharges up to +/-90V when the film moves back and forth. Some common uses this type of sensor are for impact sensing or as a flexible switch.  A larger scale example are piezo sensors that are laid within the road for use of traffic signals.&lt;br /&gt;
&lt;br /&gt;
This sensor can be purchased at [https://www.sparkfun.com/products/9197 SparkFun].&lt;br /&gt;
&lt;br /&gt;
The [https://www.sparkfun.com/datasheets/Sensors/Flex/MSI-techman.pdf Technical Manual] and [http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/ForceFlex/LDT_Series.pdf datasheet] can also be found on Sparkfun's website.&lt;br /&gt;
&lt;br /&gt;
[[File:PiezoCircuit.PNG|thumb |alt=Example alt text |This is and example circuit layout of the piezo vibration sensor using an op amp and the beagle board.]]&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Since the piezo sensor acts like a small capacitor, you can connect on a bread board as such.  However an additional resistor is needed in order affect the low frequency of measurement. This is called the &amp;quot;loading effect&amp;quot;.  Additionally, if the signal from the piezo sensor is too low an op amp may be necessary.&lt;br /&gt;
&lt;br /&gt;
More specific information and circuit diagrams can be found in the [https://www.sparkfun.com/datasheets/Sensors/Flex/MSI-techman.pdf Technical Manual] on pages 36-40.&lt;br /&gt;
&lt;br /&gt;
==Beagle Bone Usage==&lt;br /&gt;
&lt;br /&gt;
The value being read from the piezo sensor will be a voltage up to +/-0.5V.  This means that an analog pin must be used to read the value from the sensor.  The voltage being supplied to the sensor affects how much sensitivity you will receive.  Look in the technical manual to find a desired voltage that will work for you.  For the example below, I simply used a 5V source.&lt;br /&gt;
&lt;br /&gt;
[[File:Piezo-breadboard-layout.jpg|thumb |alt=Example alt text |This is a picture of the layout of the piezo vibration sensor using an op amp and the beagle board.]]&lt;br /&gt;
&lt;br /&gt;
==Reading the Analog Signal==&lt;br /&gt;
&lt;br /&gt;
You can simply read the value of the piezo sensor from the terminal by reading the contents of a file in the /sys/devices/platform/omap/tsc/ain# directory.  The # is 1 + the number of the analog pin you selected as your analog input.  However this method will not allow you to accurately see the change of voltage as the film moves.  To do this you will need to write a c program to print the values to the terminal repeatably or plot the voltage over time.  The sample code below shows a simple program to print the voltage of the sensor to the screen.&lt;br /&gt;
&lt;br /&gt;
==Sample Code==&lt;br /&gt;
The following code can be found on [https://github.com/geislekj/ECE497/tree/master/miniProject2 git hub].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/**************************************&lt;br /&gt;
Example Program for the Large Piezo Vibration Sensor - With Mass&lt;br /&gt;
&lt;br /&gt;
This will display the value of the AIN0 Pin directly to the terminal repeatively.&lt;br /&gt;
&lt;br /&gt;
wrtten by Kevin Geisler, 23-Sept-2012&lt;br /&gt;
***************************************/&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define SYSFS_AIN1_DIR &amp;quot;/sys/devices/platform/omap/tsc/ain2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FILE *fp; &lt;br /&gt;
&lt;br /&gt;
int readanalog(){&lt;br /&gt;
	if ((fp = fopen(SYSFS_AIN1_DIR, &amp;quot;r&amp;quot;)) == NULL)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Cannot open value file.\n&amp;quot;);&lt;br /&gt;
		exit(1);&lt;br /&gt;
	}	&lt;br /&gt;
&lt;br /&gt;
	//Set pointer to begining of the file&lt;br /&gt;
	rewind(fp);&lt;br /&gt;
	//Write our value of &amp;quot;0&amp;quot; to the file &lt;br /&gt;
	char inString[10];&lt;br /&gt;
	fgets(&amp;amp;inString, 10, fp);&lt;br /&gt;
	fflush(fp);&lt;br /&gt;
//			printf(&amp;quot;...value set to 0...\n&amp;quot;);	&lt;br /&gt;
	fclose(fp);&lt;br /&gt;
//	printf(inString);&lt;br /&gt;
	return atoi(&amp;amp;inString);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
	//Run an infinite loop - will require Ctrl-C to exit this program&lt;br /&gt;
	while(1)&lt;br /&gt;
	{&lt;br /&gt;
	printf(&amp;quot;%d\n&amp;quot;,readanalog());&lt;br /&gt;
	usleep(100000);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Geislekj</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Geislekj</id>
		<title>User:Geislekj</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Geislekj"/>
				<updated>2012-11-02T04:53:22Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{GeislekjHead}}&lt;br /&gt;
&lt;br /&gt;
* Computer Science Major, Class of 2013 &lt;br /&gt;
* Robotics Minor&lt;br /&gt;
* Electrical Engineering Minor&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
Project topics I'm interested in:&lt;br /&gt;
* Autonomous Robots or Drones&lt;br /&gt;
&lt;br /&gt;
== Mini-projects ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:ECE497]]&lt;/div&gt;</summary>
		<author><name>Geislekj</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Template:GeislekjHead</id>
		<title>Template:GeislekjHead</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Template:GeislekjHead"/>
				<updated>2012-11-02T04:52:33Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: Created page with &amp;quot;thumb‎  '''Embedded Linux Class'''  Kevin  Geisler [http://Rose-Hulman.edu ''RHIT'']&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:RoseLogo96.png|150px|thumb‎]]  '''Embedded Linux Class''' [[User:geislekj | Kevin  Geisler]] [http://Rose-Hulman.edu ''RHIT'']&lt;/div&gt;</summary>
		<author><name>Geislekj</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:49:04Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
== 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;
*'''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>Geislekj</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:48:07Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
== 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;
*'''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;
# 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>Geislekj</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:47:26Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
== 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;
*'''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&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>Geislekj</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:46:46Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
== 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;
*'''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 and 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&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>Geislekj</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:40:04Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
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 &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;
*'''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;
&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>Geislekj</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:23:03Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
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 &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>Geislekj</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:09:47Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
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;
*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>Geislekj</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:06:54Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
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;
  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;
*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>Geislekj</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:56:05Z</updated>
		
		<summary type="html">&lt;p&gt;Geislekj: /* 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;
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;
*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>Geislekj</name></author>	</entry>

	</feed>