<?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=Ziyi+Zhang&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=Ziyi+Zhang&amp;feedformat=atom"/>
		<link rel="alternate" type="text/html" href="http://elinux.org/Special:Contributions/Ziyi_Zhang"/>
		<updated>2013-05-21T05:03:01Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.21alpha</generator>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-19T06:58:23Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: /* User Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. We also tried to make our web server send automatic email when temperature goes too high. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
The automatic email sender is not working correctly. More work needs to be done to set a proper configuration to the SMTP server 'postfix'.&lt;br /&gt;
&lt;br /&gt;
This turns out to be a very fun application-level project and Node.js is really a very friendly, easy-to-use emerging technology that should be promoted to wider industry use.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install mailer module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install mailer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install SMTP server postfix&lt;br /&gt;
Go to [http://postfix.energybeam.com/source/index.html] download the source of postfix, then unzip the .gz file, then run 'make', then run &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sh postfix-install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
Go to our github address above, our final work resides in the &amp;quot;/Project/new&amp;quot; [https://github.com/caoy1/Project/tree/master/new directory]. Pull everything out in that folder, then go into this &amp;quot;new&amp;quot; directory on your host computer, executes the index.js program, then you are good to go:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
node index.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the console, &amp;quot;Server has started&amp;quot; will be printed out.&lt;br /&gt;
Fire up any of your browser, and visit the beagleboard's IP address:3001(port number). Currently the address is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://137.112.101.67:3001&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The webpage will show up and the temperature is real-time updated. You can also select the LED toggle mode on the page, and when you hit &amp;quot;select&amp;quot;, the LED light on the board will toggle in the way you specify on the page.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Remote monitoring parameters like room temperature, if sensors are equipped on board, and control hardware pins on board, at anywhere, anytime, when you have access to the Internet.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
To build a web server, we need, in essence, both client side and server side scripts. Client side scripts mainly just involve ordinary javascripts that can be embedded in HTML file; while at the server-side, we adopt the emerging node.js, which is a really simple server side script that accomplishes equivalent tasks like ASP, PHP will do, but with even simpler implementation details.&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts. The following code snippet can accomplish this (borrowed and modified based on Jadon's code):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function loadHTMLFile(uri, res, temp) {&lt;br /&gt;
 var filename = path.join(process.cwd(), uri);&lt;br /&gt;
 path.exists(&lt;br /&gt;
  filename,&lt;br /&gt;
  function(exists) {&lt;br /&gt;
   if(!exists) {&lt;br /&gt;
    res.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    res.write(&amp;quot;404 Not Found\n&amp;quot;);&lt;br /&gt;
    res.end();&lt;br /&gt;
    return;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fs.readFile(&lt;br /&gt;
    filename,&lt;br /&gt;
    encoding='utf8',&lt;br /&gt;
    function(err, file) {&lt;br /&gt;
     if(err) {&lt;br /&gt;
      res.writeHead(500, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
      res.write(err + &amp;quot;\n&amp;quot;);&lt;br /&gt;
      res.end();&lt;br /&gt;
      return;&lt;br /&gt;
     }&lt;br /&gt;
     res.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/html&amp;quot;});&lt;br /&gt;
     var str = (&amp;quot;&amp;quot; + file).replace(&amp;quot;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;quot;, temp);&lt;br /&gt;
     res.write(str);&lt;br /&gt;
     res.end();&lt;br /&gt;
    }&lt;br /&gt;
   );&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And outside the above function, the main routine, we have similar code as listed in 3, but insert the function call:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				loadHTMLFile('/index.html', response, stdout);&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes. Here is the simple client script for accomplishing this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
setInterval(&amp;quot;document.forms[0].submit()&amp;quot;,5000);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Welcome to the world of Node.js&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here is the demo of the weather station.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Current temperature:&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;temperature output&amp;quot;&amp;gt;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/test.js&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;get temperature&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Now we are trying to do something fancy! We want to send the user an automatic warning email when the temperature is too high. Here's the Javascript code using node.js mailer module. This code use SMTP server to send email to the destination.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var email = require('mailer');&lt;br /&gt;
&lt;br /&gt;
email.SMTP = {&lt;br /&gt;
    host: 'smtp.gmail.com',&lt;br /&gt;
    port: 587,&lt;br /&gt;
    ssl: false,&lt;br /&gt;
    use_authentication: false,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
email.send({&lt;br /&gt;
    to : &amp;quot;caoy1@rose-hulman.edu&amp;quot;,&lt;br /&gt;
    from : &amp;quot;obama@whitehouse.gov&amp;quot;,&lt;br /&gt;
    subject : &amp;quot;I love beagleboard!&amp;quot;,&lt;br /&gt;
    body: &amp;quot;Hello beagle world.&amp;quot;,&lt;br /&gt;
}, &lt;br /&gt;
&lt;br /&gt;
function(err, result) {&lt;br /&gt;
    if(err) {&lt;br /&gt;
	console.log(err);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* However, the configuration on our beagle has some problem. The server has no response to mailer's request. We've tried telnet localhost 587, and connection can be connected. This means the 587 port is already opened. Then I tried the same code under my ubuntu system, it turns out everything works fine, the caoy1@rose-hulman.edu can receive the e-mail, except some client-side warning error when running the mail.js file. I think the reason it works on ubuntu is because when installing postfix, there's an automatic configuration step, which doesn't exist on our beagle installation. So there must be some problem with the postfix configuration of beagleboard. I've tried to copy all the configuration files under /etc/postfix to our beagleboard, but there's just the same problem. If I have more time, or someone else who's interested in continuing this project, I suggest you have some research on the configuration thing. Everytime you make some config changes, just run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postfix reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to apply the change.&lt;br /&gt;
&lt;br /&gt;
5. Our next goal is to toggle LED via web page, whose control flow structure is essentially similar to the i2c communications, plus, we have already learned the way to write to the led pin via nodejs script(see note1 above).&lt;br /&gt;
* Before actually doing that, let's first organize our code in a more hierarchical and reasonable way.Thanks to Mr. Manuel Kiessling's excellent introductory tutorial &amp;quot;[http://www.nodebeginner.org The Node Beginner Book]&amp;quot;, which gives a pretty decent explanation on how a formal web server architecture should be constructed using nodejs. Basically, we should maintain an index.js that starts all of our code, have a server.js to actually create the server and listen on the port for any posts from the client side, and pass the request and response to the router.js to handle different requests. In requestHandlers.js, each function then does the real work based on the request information and execute corresponding server responses. &lt;br /&gt;
* The following is what's in index.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var server = require(&amp;quot;./server&amp;quot;);&lt;br /&gt;
var router = require(&amp;quot;./router&amp;quot;);&lt;br /&gt;
var requestHandlers = require(&amp;quot;./requestHandlers&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
var handle = {}&lt;br /&gt;
handle[&amp;quot;/&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
handle[&amp;quot;/led&amp;quot;] = requestHandlers.led;&lt;br /&gt;
handle[&amp;quot;/i2c&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
&lt;br /&gt;
server.start(router.route, handle);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* And we abstract the server.js to be a general form so that it is independent of what will actually be done at the server, such details are left for requestHandlers.js to accomplish:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
var url = require(&amp;quot;url&amp;quot;);&lt;br /&gt;
var sys = require('sys'); &lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
var events = require('events');&lt;br /&gt;
&lt;br /&gt;
function start(route, handle) {&lt;br /&gt;
	function onRequest(request, response){&lt;br /&gt;
      var pathname = url.parse(request.url).pathname;&lt;br /&gt;
      route(handle, pathname, response, request);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  http.createServer(onRequest).listen(3001);&lt;br /&gt;
  console.log(&amp;quot;Server has started.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.start = start;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* router.js gets the request's pathname and call different functions according to different request url:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function route(handle, pathname, response, request) {&lt;br /&gt;
  console.log(&amp;quot;About to route a request for &amp;quot; + pathname);&lt;br /&gt;
  if (typeof handle[pathname] === 'function') {&lt;br /&gt;
    handle[pathname](response, request);&lt;br /&gt;
  } else {&lt;br /&gt;
    console.log(&amp;quot;No request handler found for &amp;quot; + pathname);&lt;br /&gt;
    response.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    response.write(&amp;quot;404 Not found&amp;quot;);&lt;br /&gt;
    response.end();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.route = route;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* In requestHandlers.js, we need two functions, one for handle i2c request, another for led toggling request:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function i2c(response, request) {&lt;br /&gt;
  var uri = url.parse(request.url).pathname;&lt;br /&gt;
  ...//same as described above, including calling loadHTMLFile function that's also in requestHandlers.js&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  ...//details in below&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. Now it's time for us to think about how to toggle LED via web page. Turns out it's very similar to how i2c works. However, this time we need to not only parse the uri of the request, but also get the posted data from the request, parse them and write them into the appropriate file system. The event-driven nodejs utilizes &amp;quot;addListener&amp;quot; function to achieve the task, with parameter &amp;quot;data&amp;quot; to receive the data and &amp;quot;end&amp;quot; to handle and process them. The data received(in type of string) should be converted to object class by the &amp;quot;querystring&amp;quot; module. &lt;br /&gt;
&lt;br /&gt;
On the client side, we use exclusive radio button to allow user to choose the toggle mode of LED:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/led&amp;quot; method=&amp;quot;post&amp;quot; size=&amp;quot;30&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;nand-disk&amp;quot; &amp;gt;nand-disk&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;mmc0&amp;quot; /&amp;gt;mmc0&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;heartbeat&amp;quot; &amp;gt;heartbeat&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;none&amp;quot; &amp;gt;none&lt;br /&gt;
            &amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Select&amp;quot;  onclick=&amp;quot;xmlhttpPost()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding javascript just submits this form to /led, which then be handled by router to execute led() function:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function xmlhttpPost() {&lt;br /&gt;
documents.forms[1].submit();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The following is the server side function code in requestHandlers.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var qs = require('querystring');&lt;br /&gt;
var url = require('url');&lt;br /&gt;
var sys = require('sys');&lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  var postData = &amp;quot;&amp;quot;;&lt;br /&gt;
   var pathname = url.parse(request.url).pathname;&lt;br /&gt;
   console.log(&amp;quot;Request for &amp;quot; + pathname + &amp;quot; received.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    request.setEncoding(&amp;quot;utf8&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    request.addListener(&amp;quot;data&amp;quot;, function(postDataChunk) {&lt;br /&gt;
      postData += postDataChunk;&lt;br /&gt;
      console.log(&amp;quot;Received POST data chunk '&amp;quot;+&lt;br /&gt;
      postDataChunk + &amp;quot;'.&amp;quot;);&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    request.addListener(&amp;quot;end&amp;quot;, function() {&lt;br /&gt;
      var ledtype = qs.parse(postData);&lt;br /&gt;
          console.log(ledtype.mode);&lt;br /&gt;
          fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, ledtype.mode);&lt;br /&gt;
    });&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Another thing to notice is, in order for this requestHandler for led.js not to jump to a brand new web page but stay on the current one, the normal &amp;quot;request.end()&amp;quot; code, which indicates the completion of an intact .js page, should be left out.&lt;br /&gt;
&lt;br /&gt;
7. Eventually we did a little bit beautification on the html page --- somehow CSS does not work as intended, we simply change some font and color of the output to make it a bit neater.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
This project dabbles in the possibility of setting a web-server written in nodejs on the embedded environment and accomplishes the proposed idea of interacting with underlying hardware pins and system via upper-level user interface. nodejs is very simple and easy to implement, its non-blocking, event-driven and single-threaded mechanism is exactly suitable for the embedded system and our project gives a good instance of its application. Our demo system can be scaled up with far more features in remote monitoring and smart control industry. If, for example, the nodemailer can work well on the Angstrom (apparently it's working on Ubuntu, but somehow does not seem to be compatible with Angstrom), or other embedded Linux distribution, it can become as powerful as intelligent agent in monitoring various parameters, like temperature, moisture, so on so forth.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-19T06:55:36Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. We also tried to make our web server send automatic email when temperature goes too high. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
The automatic email sender is not working correctly. More work needs to be done to set a proper configuration to the SMTP server 'postfix'.&lt;br /&gt;
&lt;br /&gt;
This turns out to be a very fun application-level project and Node.js is really a very friendly, easy-to-use emerging technology that should be promoted to wider industry use.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install mailer module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install mailer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install SMTP server postfix&lt;br /&gt;
Go to [http://postfix.energybeam.com/source/index.html] download the source of postfix, then unzip the .gz file, then run 'make', then run &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sh postfix-install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
Go to our github address above, our final work resides in the &amp;quot;new&amp;quot; folder. Pull everything out in that folder, then go into this &amp;quot;new&amp;quot; directory on your host computer, executes the index.js program, then you are good to go:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
node index.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the console, &amp;quot;Server has started&amp;quot; will be printed out.&lt;br /&gt;
Fire up any of your browser, and visit the beagleboard's IP address:3001(port number). Currently the address is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://137.112.101.67:3001&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The webpage will show up and the temperature is real-time updated. You can also select the LED toggle mode on the page, and when you hit &amp;quot;select&amp;quot;, the LED light on the board will toggle in the way you specify on the page.&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Remote monitoring parameters like room temperature, if sensors are equipped on board, and control hardware pins on board, at anywhere, anytime, when you have access to the Internet.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
To build a web server, we need, in essence, both client side and server side scripts. Client side scripts mainly just involve ordinary javascripts that can be embedded in HTML file; while at the server-side, we adopt the emerging node.js, which is a really simple server side script that accomplishes equivalent tasks like ASP, PHP will do, but with even simpler implementation details.&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts. The following code snippet can accomplish this (borrowed and modified based on Jadon's code):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function loadHTMLFile(uri, res, temp) {&lt;br /&gt;
 var filename = path.join(process.cwd(), uri);&lt;br /&gt;
 path.exists(&lt;br /&gt;
  filename,&lt;br /&gt;
  function(exists) {&lt;br /&gt;
   if(!exists) {&lt;br /&gt;
    res.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    res.write(&amp;quot;404 Not Found\n&amp;quot;);&lt;br /&gt;
    res.end();&lt;br /&gt;
    return;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fs.readFile(&lt;br /&gt;
    filename,&lt;br /&gt;
    encoding='utf8',&lt;br /&gt;
    function(err, file) {&lt;br /&gt;
     if(err) {&lt;br /&gt;
      res.writeHead(500, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
      res.write(err + &amp;quot;\n&amp;quot;);&lt;br /&gt;
      res.end();&lt;br /&gt;
      return;&lt;br /&gt;
     }&lt;br /&gt;
     res.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/html&amp;quot;});&lt;br /&gt;
     var str = (&amp;quot;&amp;quot; + file).replace(&amp;quot;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;quot;, temp);&lt;br /&gt;
     res.write(str);&lt;br /&gt;
     res.end();&lt;br /&gt;
    }&lt;br /&gt;
   );&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And outside the above function, the main routine, we have similar code as listed in 3, but insert the function call:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				loadHTMLFile('/index.html', response, stdout);&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes. Here is the simple client script for accomplishing this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
setInterval(&amp;quot;document.forms[0].submit()&amp;quot;,5000);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Welcome to the world of Node.js&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here is the demo of the weather station.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Current temperature:&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;temperature output&amp;quot;&amp;gt;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/test.js&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;get temperature&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Now we are trying to do something fancy! We want to send the user an automatic warning email when the temperature is too high. Here's the Javascript code using node.js mailer module. This code use SMTP server to send email to the destination.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var email = require('mailer');&lt;br /&gt;
&lt;br /&gt;
email.SMTP = {&lt;br /&gt;
    host: 'smtp.gmail.com',&lt;br /&gt;
    port: 587,&lt;br /&gt;
    ssl: false,&lt;br /&gt;
    use_authentication: false,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
email.send({&lt;br /&gt;
    to : &amp;quot;caoy1@rose-hulman.edu&amp;quot;,&lt;br /&gt;
    from : &amp;quot;obama@whitehouse.gov&amp;quot;,&lt;br /&gt;
    subject : &amp;quot;I love beagleboard!&amp;quot;,&lt;br /&gt;
    body: &amp;quot;Hello beagle world.&amp;quot;,&lt;br /&gt;
}, &lt;br /&gt;
&lt;br /&gt;
function(err, result) {&lt;br /&gt;
    if(err) {&lt;br /&gt;
	console.log(err);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* However, the configuration on our beagle has some problem. The server has no response to mailer's request. We've tried telnet localhost 587, and connection can be connected. This means the 587 port is already opened. Then I tried the same code under my ubuntu system, it turns out everything works fine, the caoy1@rose-hulman.edu can receive the e-mail, except some client-side warning error when running the mail.js file. I think the reason it works on ubuntu is because when installing postfix, there's an automatic configuration step, which doesn't exist on our beagle installation. So there must be some problem with the postfix configuration of beagleboard. I've tried to copy all the configuration files under /etc/postfix to our beagleboard, but there's just the same problem. If I have more time, or someone else who's interested in continuing this project, I suggest you have some research on the configuration thing. Everytime you make some config changes, just run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postfix reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to apply the change.&lt;br /&gt;
&lt;br /&gt;
5. Our next goal is to toggle LED via web page, whose control flow structure is essentially similar to the i2c communications, plus, we have already learned the way to write to the led pin via nodejs script(see note1 above).&lt;br /&gt;
* Before actually doing that, let's first organize our code in a more hierarchical and reasonable way.Thanks to Mr. Manuel Kiessling's excellent introductory tutorial &amp;quot;[http://www.nodebeginner.org The Node Beginner Book]&amp;quot;, which gives a pretty decent explanation on how a formal web server architecture should be constructed using nodejs. Basically, we should maintain an index.js that starts all of our code, have a server.js to actually create the server and listen on the port for any posts from the client side, and pass the request and response to the router.js to handle different requests. In requestHandlers.js, each function then does the real work based on the request information and execute corresponding server responses. &lt;br /&gt;
* The following is what's in index.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var server = require(&amp;quot;./server&amp;quot;);&lt;br /&gt;
var router = require(&amp;quot;./router&amp;quot;);&lt;br /&gt;
var requestHandlers = require(&amp;quot;./requestHandlers&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
var handle = {}&lt;br /&gt;
handle[&amp;quot;/&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
handle[&amp;quot;/led&amp;quot;] = requestHandlers.led;&lt;br /&gt;
handle[&amp;quot;/i2c&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
&lt;br /&gt;
server.start(router.route, handle);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* And we abstract the server.js to be a general form so that it is independent of what will actually be done at the server, such details are left for requestHandlers.js to accomplish:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
var url = require(&amp;quot;url&amp;quot;);&lt;br /&gt;
var sys = require('sys'); &lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
var events = require('events');&lt;br /&gt;
&lt;br /&gt;
function start(route, handle) {&lt;br /&gt;
	function onRequest(request, response){&lt;br /&gt;
      var pathname = url.parse(request.url).pathname;&lt;br /&gt;
      route(handle, pathname, response, request);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  http.createServer(onRequest).listen(3001);&lt;br /&gt;
  console.log(&amp;quot;Server has started.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.start = start;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* router.js gets the request's pathname and call different functions according to different request url:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function route(handle, pathname, response, request) {&lt;br /&gt;
  console.log(&amp;quot;About to route a request for &amp;quot; + pathname);&lt;br /&gt;
  if (typeof handle[pathname] === 'function') {&lt;br /&gt;
    handle[pathname](response, request);&lt;br /&gt;
  } else {&lt;br /&gt;
    console.log(&amp;quot;No request handler found for &amp;quot; + pathname);&lt;br /&gt;
    response.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    response.write(&amp;quot;404 Not found&amp;quot;);&lt;br /&gt;
    response.end();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.route = route;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* In requestHandlers.js, we need two functions, one for handle i2c request, another for led toggling request:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function i2c(response, request) {&lt;br /&gt;
  var uri = url.parse(request.url).pathname;&lt;br /&gt;
  ...//same as described above, including calling loadHTMLFile function that's also in requestHandlers.js&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  ...//details in below&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. Now it's time for us to think about how to toggle LED via web page. Turns out it's very similar to how i2c works. However, this time we need to not only parse the uri of the request, but also get the posted data from the request, parse them and write them into the appropriate file system. The event-driven nodejs utilizes &amp;quot;addListener&amp;quot; function to achieve the task, with parameter &amp;quot;data&amp;quot; to receive the data and &amp;quot;end&amp;quot; to handle and process them. The data received(in type of string) should be converted to object class by the &amp;quot;querystring&amp;quot; module. &lt;br /&gt;
&lt;br /&gt;
On the client side, we use exclusive radio button to allow user to choose the toggle mode of LED:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/led&amp;quot; method=&amp;quot;post&amp;quot; size=&amp;quot;30&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;nand-disk&amp;quot; &amp;gt;nand-disk&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;mmc0&amp;quot; /&amp;gt;mmc0&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;heartbeat&amp;quot; &amp;gt;heartbeat&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;none&amp;quot; &amp;gt;none&lt;br /&gt;
            &amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Select&amp;quot;  onclick=&amp;quot;xmlhttpPost()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding javascript just submits this form to /led, which then be handled by router to execute led() function:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function xmlhttpPost() {&lt;br /&gt;
documents.forms[1].submit();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The following is the server side function code in requestHandlers.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var qs = require('querystring');&lt;br /&gt;
var url = require('url');&lt;br /&gt;
var sys = require('sys');&lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  var postData = &amp;quot;&amp;quot;;&lt;br /&gt;
   var pathname = url.parse(request.url).pathname;&lt;br /&gt;
   console.log(&amp;quot;Request for &amp;quot; + pathname + &amp;quot; received.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    request.setEncoding(&amp;quot;utf8&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    request.addListener(&amp;quot;data&amp;quot;, function(postDataChunk) {&lt;br /&gt;
      postData += postDataChunk;&lt;br /&gt;
      console.log(&amp;quot;Received POST data chunk '&amp;quot;+&lt;br /&gt;
      postDataChunk + &amp;quot;'.&amp;quot;);&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    request.addListener(&amp;quot;end&amp;quot;, function() {&lt;br /&gt;
      var ledtype = qs.parse(postData);&lt;br /&gt;
          console.log(ledtype.mode);&lt;br /&gt;
          fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, ledtype.mode);&lt;br /&gt;
    });&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Another thing to notice is, in order for this requestHandler for led.js not to jump to a brand new web page but stay on the current one, the normal &amp;quot;request.end()&amp;quot; code, which indicates the completion of an intact .js page, should be left out.&lt;br /&gt;
&lt;br /&gt;
7. Eventually we did a little bit beautification on the html page --- somehow CSS does not work as intended, we simply change some font and color of the output to make it a bit neater.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
This project dabbles in the possibility of setting a web-server written in nodejs on the embedded environment and accomplishes the proposed idea of interacting with underlying hardware pins and system via upper-level user interface. nodejs is very simple and easy to implement, its non-blocking, event-driven and single-threaded mechanism is exactly suitable for the embedded system and our project gives a good instance of its application. Our demo system can be scaled up with far more features in remote monitoring and smart control industry. If, for example, the nodemailer can work well on the Angstrom (apparently it's working on Ubuntu, but somehow does not seem to be compatible with Angstrom), or other embedded Linux distribution, it can become as powerful as intelligent agent in monitoring various parameters, like temperature, moisture, so on so forth.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-19T06:34:56Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: /* Work Breakdown */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. We also tried to make our web server send automatic email when temperature goes too high. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
The automatic email sender is not working correctly. More work needs to be done to set a proper configuration to the SMTP server 'postfix'.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install mailer module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install mailer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install SMTP server postfix&lt;br /&gt;
Go to [http://postfix.energybeam.com/source/index.html] download the source of postfix, then unzip the .gz file, then run 'make', then run &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sh postfix-install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
To build a web server, we need, in essence, both client side and server side scripts. Client side scripts mainly just involve ordinary javascripts that can be embedded in HTML file; while at the server-side, we adopt the emerging node.js, which is a really simple server side script that accomplishes equivalent tasks like ASP, PHP will do, but with even simpler implementation details.&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts. The following code snippet can accomplish this (borrowed and modified based on Jadon's code):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function loadHTMLFile(uri, res, temp) {&lt;br /&gt;
 var filename = path.join(process.cwd(), uri);&lt;br /&gt;
 path.exists(&lt;br /&gt;
  filename,&lt;br /&gt;
  function(exists) {&lt;br /&gt;
   if(!exists) {&lt;br /&gt;
    res.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    res.write(&amp;quot;404 Not Found\n&amp;quot;);&lt;br /&gt;
    res.end();&lt;br /&gt;
    return;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fs.readFile(&lt;br /&gt;
    filename,&lt;br /&gt;
    encoding='utf8',&lt;br /&gt;
    function(err, file) {&lt;br /&gt;
     if(err) {&lt;br /&gt;
      res.writeHead(500, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
      res.write(err + &amp;quot;\n&amp;quot;);&lt;br /&gt;
      res.end();&lt;br /&gt;
      return;&lt;br /&gt;
     }&lt;br /&gt;
     res.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/html&amp;quot;});&lt;br /&gt;
     var str = (&amp;quot;&amp;quot; + file).replace(&amp;quot;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;quot;, temp);&lt;br /&gt;
     res.write(str);&lt;br /&gt;
     res.end();&lt;br /&gt;
    }&lt;br /&gt;
   );&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And outside the above function, the main routine, we have similar code as listed in 3, but insert the function call:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				loadHTMLFile('/index.html', response, stdout);&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes. Here is the simple client script for accomplishing this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
setInterval(&amp;quot;document.forms[0].submit()&amp;quot;,5000);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Welcome to the world of Node.js&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here is the demo of the weather station.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Current temperature:&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;temperature output&amp;quot;&amp;gt;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/test.js&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;get temperature&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Now we are trying to do something fancy! We want to send the user an automatic warning email when the temperature is too high. Here's the Javascript code using node.js mailer module. This code use SMTP server to send email to the destination.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var email = require('mailer');&lt;br /&gt;
&lt;br /&gt;
email.SMTP = {&lt;br /&gt;
    host: 'smtp.gmail.com',&lt;br /&gt;
    port: 587,&lt;br /&gt;
    ssl: false,&lt;br /&gt;
    use_authentication: false,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
email.send({&lt;br /&gt;
    to : &amp;quot;caoy1@rose-hulman.edu&amp;quot;,&lt;br /&gt;
    from : &amp;quot;obama@whitehouse.gov&amp;quot;,&lt;br /&gt;
    subject : &amp;quot;I love beagleboard!&amp;quot;,&lt;br /&gt;
    body: &amp;quot;Hello beagle world.&amp;quot;,&lt;br /&gt;
}, &lt;br /&gt;
&lt;br /&gt;
function(err, result) {&lt;br /&gt;
    if(err) {&lt;br /&gt;
	console.log(err);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* However, the configuration on our beagle has some problem. The server has no response to mailer's request. We've tried telnet localhost 587, and connection can be connected. This means the 587 port is already opened. Then I tried the same code under my ubuntu system, it turns out everything works fine, the caoy1@rose-hulman.edu can receive the e-mail, except some client-side warning error when running the mail.js file. I think the reason it works on ubuntu is because when installing postfix, there's an automatic configuration step, which doesn't exist on our beagle installation. So there must be some problem with the postfix configuration of beagleboard. I've tried to copy all the configuration files under /etc/postfix to our beagleboard, but there's just the same problem. If I have more time, or someone else who's interested in continuing this project, I suggest you have some research on the configuration thing. Everytime you make some config changes, just run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postfix reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to apply the change.&lt;br /&gt;
&lt;br /&gt;
5. Our next goal is to toggle LED via web page, whose control flow structure is essentially similar to the i2c communications, plus, we have already learned the way to write to the led pin via nodejs script(see note1 above).&lt;br /&gt;
* Before actually doing that, let's first organize our code in a more hierarchical and reasonable way.Thanks to Mr. Manuel Kiessling's excellent introductory tutorial &amp;quot;[http://www.nodebeginner.org The Node Beginner Book]&amp;quot;, which gives a pretty decent explanation on how a formal web server architecture should be constructed using nodejs. Basically, we should maintain an index.js that starts all of our code, have a server.js to actually create the server and listen on the port for any posts from the client side, and pass the request and response to the router.js to handle different requests. In requestHandlers.js, each function then does the real work based on the request information and execute corresponding server responses. &lt;br /&gt;
* The following is what's in index.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var server = require(&amp;quot;./server&amp;quot;);&lt;br /&gt;
var router = require(&amp;quot;./router&amp;quot;);&lt;br /&gt;
var requestHandlers = require(&amp;quot;./requestHandlers&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
var handle = {}&lt;br /&gt;
handle[&amp;quot;/&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
handle[&amp;quot;/led&amp;quot;] = requestHandlers.led;&lt;br /&gt;
handle[&amp;quot;/i2c&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
&lt;br /&gt;
server.start(router.route, handle);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* And we abstract the server.js to be a general form so it is independent of what will actually be done at the server, such details is left for requestHandlers.js to accomplish:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
var url = require(&amp;quot;url&amp;quot;);&lt;br /&gt;
var sys = require('sys'); &lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
var events = require('events');&lt;br /&gt;
&lt;br /&gt;
function start(route, handle) {&lt;br /&gt;
	function onRequest(request, response){&lt;br /&gt;
      var pathname = url.parse(request.url).pathname;&lt;br /&gt;
      route(handle, pathname, response, request);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  http.createServer(onRequest).listen(3001);&lt;br /&gt;
  console.log(&amp;quot;Server has started.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.start = start;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* router.js gets the request's pathname and call different functions according to different request url:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function route(handle, pathname, response, request) {&lt;br /&gt;
  console.log(&amp;quot;About to route a request for &amp;quot; + pathname);&lt;br /&gt;
  if (typeof handle[pathname] === 'function') {&lt;br /&gt;
    handle[pathname](response, request);&lt;br /&gt;
  } else {&lt;br /&gt;
    console.log(&amp;quot;No request handler found for &amp;quot; + pathname);&lt;br /&gt;
    response.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    response.write(&amp;quot;404 Not found&amp;quot;);&lt;br /&gt;
    response.end();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.route = route;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* In requestHandlers.js, we need two functions, one for handle i2c request, another for led toggling request:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function i2c(response, request) {&lt;br /&gt;
  var uri = url.parse(request.url).pathname;&lt;br /&gt;
  ...//same as described above, including calling loadHTMLFile function that's also in requestHandlers.js&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  ...//details in below&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. Now it's time for us to think about how to toggle LED via web page. Turns out it's very similar to how i2c works. However, this time we need to not only parse the uri of the request, but also get the posted data from the request, parse them and write them into the appropriate file system. The event-driven nodejs utilizes &amp;quot;addListener&amp;quot; function to achieve the task, with parameter &amp;quot;data&amp;quot; to receive the data and &amp;quot;end&amp;quot; to handle and process them. The data received(in type of string) should be converted to object class by the &amp;quot;querystring&amp;quot; module. &lt;br /&gt;
&lt;br /&gt;
On the client side, we use exclusive radio button to allow user to choose the toggle mode of LED:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/led&amp;quot; method=&amp;quot;post&amp;quot; size=&amp;quot;30&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;nand-disk&amp;quot; &amp;gt;nand-disk&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;mmc0&amp;quot; /&amp;gt;mmc0&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;heartbeat&amp;quot; &amp;gt;heartbeat&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;none&amp;quot; &amp;gt;none&lt;br /&gt;
            &amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Select&amp;quot;  onclick=&amp;quot;xmlhttpPost()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding javascript just submits this form to /led, which then be handled by router to execute led() function:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function xmlhttpPost() {&lt;br /&gt;
documents.forms[1].submit();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The following is the server side function code in requestHandlers.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var qs = require('querystring');&lt;br /&gt;
var url = require('url');&lt;br /&gt;
var sys = require('sys');&lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  var postData = &amp;quot;&amp;quot;;&lt;br /&gt;
   var pathname = url.parse(request.url).pathname;&lt;br /&gt;
   console.log(&amp;quot;Request for &amp;quot; + pathname + &amp;quot; received.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    request.setEncoding(&amp;quot;utf8&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    request.addListener(&amp;quot;data&amp;quot;, function(postDataChunk) {&lt;br /&gt;
      postData += postDataChunk;&lt;br /&gt;
      console.log(&amp;quot;Received POST data chunk '&amp;quot;+&lt;br /&gt;
      postDataChunk + &amp;quot;'.&amp;quot;);&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    request.addListener(&amp;quot;end&amp;quot;, function() {&lt;br /&gt;
      var ledtype = qs.parse(postData);&lt;br /&gt;
          console.log(ledtype.mode);&lt;br /&gt;
          fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, ledtype.mode);&lt;br /&gt;
    });&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Another thing to notice is, in order for this requestHandler for led.js not to jump to a brand new web page but stay on the current one, the normal &amp;quot;request.end()&amp;quot; code, which indicates the completion of an intact .js page, should be left out.&lt;br /&gt;
&lt;br /&gt;
7. Eventually we did a little bit beautification on the html page --- somehow CSS does not work as intended, we simply change some font and color of the output to make it a bit neater.&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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-19T06:34:13Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. We also tried to make our web server send automatic email when temperature goes too high. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
The automatic email sender is not working correctly. More work needs to be done to set a proper configuration to the SMTP server 'postfix'.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install mailer module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install mailer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install SMTP server postfix&lt;br /&gt;
Go to [http://postfix.energybeam.com/source/index.html] download the source of postfix, then unzip the .gz file, then run 'make', then run &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sh postfix-install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
To build a web server, we need, in essence, both client side and server side scripts. Client side scripts mainly just involve ordinary javascripts that can be embedded in HTML file; while at the server-side, we adopt the emerging node.js, which is a really simple server side script that accomplishes equivalent tasks like ASP, PHP will do, but with even simpler implementation details.&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts. The following code snippet can accomplish this (borrowed and modified based on Jadon's code):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function loadHTMLFile(uri, res, temp) {&lt;br /&gt;
 var filename = path.join(process.cwd(), uri);&lt;br /&gt;
 path.exists(&lt;br /&gt;
  filename,&lt;br /&gt;
  function(exists) {&lt;br /&gt;
   if(!exists) {&lt;br /&gt;
    res.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    res.write(&amp;quot;404 Not Found\n&amp;quot;);&lt;br /&gt;
    res.end();&lt;br /&gt;
    return;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fs.readFile(&lt;br /&gt;
    filename,&lt;br /&gt;
    encoding='utf8',&lt;br /&gt;
    function(err, file) {&lt;br /&gt;
     if(err) {&lt;br /&gt;
      res.writeHead(500, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
      res.write(err + &amp;quot;\n&amp;quot;);&lt;br /&gt;
      res.end();&lt;br /&gt;
      return;&lt;br /&gt;
     }&lt;br /&gt;
     res.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/html&amp;quot;});&lt;br /&gt;
     var str = (&amp;quot;&amp;quot; + file).replace(&amp;quot;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;quot;, temp);&lt;br /&gt;
     res.write(str);&lt;br /&gt;
     res.end();&lt;br /&gt;
    }&lt;br /&gt;
   );&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And outside the above function, the main routine, we have similar code as listed in 3, but insert the function call:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				loadHTMLFile('/index.html', response, stdout);&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes. Here is the simple client script for accomplishing this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
setInterval(&amp;quot;document.forms[0].submit()&amp;quot;,5000);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Welcome to the world of Node.js&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here is the demo of the weather station.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Current temperature:&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;temperature output&amp;quot;&amp;gt;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/test.js&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;get temperature&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Now we are trying to do something fancy! We want to send the user an automatic warning email when the temperature is too high. Here's the Javascript code using node.js mailer module. This code use SMTP server to send email to the destination.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var email = require('mailer');&lt;br /&gt;
&lt;br /&gt;
email.SMTP = {&lt;br /&gt;
    host: 'smtp.gmail.com',&lt;br /&gt;
    port: 587,&lt;br /&gt;
    ssl: false,&lt;br /&gt;
    use_authentication: false,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
email.send({&lt;br /&gt;
    to : &amp;quot;caoy1@rose-hulman.edu&amp;quot;,&lt;br /&gt;
    from : &amp;quot;obama@whitehouse.gov&amp;quot;,&lt;br /&gt;
    subject : &amp;quot;I love beagleboard!&amp;quot;,&lt;br /&gt;
    body: &amp;quot;Hello beagle world.&amp;quot;,&lt;br /&gt;
}, &lt;br /&gt;
&lt;br /&gt;
function(err, result) {&lt;br /&gt;
    if(err) {&lt;br /&gt;
	console.log(err);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* However, the configuration on our beagle has some problem. The server has no response to mailer's request. We've tried telnet localhost 587, and connection can be connected. This means the 587 port is already opened. Then I tried the same code under my ubuntu system, it turns out everything works fine, the caoy1@rose-hulman.edu can receive the e-mail, except some client-side warning error when running the mail.js file. I think the reason it works on ubuntu is because when installing postfix, there's an automatic configuration step, which doesn't exist on our beagle installation. So there must be some problem with the postfix configuration of beagleboard. I've tried to copy all the configuration files under /etc/postfix to our beagleboard, but there's just the same problem. If I have more time, or someone else who's interested in continuing this project, I suggest you have some research on the configuration thing. Everytime you make some config changes, just run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postfix reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to apply the change.&lt;br /&gt;
&lt;br /&gt;
5. Our next goal is to toggle LED via web page, whose control flow structure is essentially similar to the i2c communications, plus, we have already learned the way to write to the led pin via nodejs script(see note1 above).&lt;br /&gt;
* Before actually doing that, let's first organize our code in a more hierarchical and reasonable way.Thanks to Mr. Manuel Kiessling's excellent introductory tutorial &amp;quot;[http://www.nodebeginner.org The Node Beginner Book]&amp;quot;, which gives a pretty decent explanation on how a formal web server architecture should be constructed using nodejs. Basically, we should maintain an index.js that starts all of our code, have a server.js to actually create the server and listen on the port for any posts from the client side, and pass the request and response to the router.js to handle different requests. In requestHandlers.js, each function then does the real work based on the request information and execute corresponding server responses. &lt;br /&gt;
* The following is what's in index.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var server = require(&amp;quot;./server&amp;quot;);&lt;br /&gt;
var router = require(&amp;quot;./router&amp;quot;);&lt;br /&gt;
var requestHandlers = require(&amp;quot;./requestHandlers&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
var handle = {}&lt;br /&gt;
handle[&amp;quot;/&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
handle[&amp;quot;/led&amp;quot;] = requestHandlers.led;&lt;br /&gt;
handle[&amp;quot;/i2c&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
&lt;br /&gt;
server.start(router.route, handle);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* And we abstract the server.js to be a general form so it is independent of what will actually be done at the server, such details is left for requestHandlers.js to accomplish:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
var url = require(&amp;quot;url&amp;quot;);&lt;br /&gt;
var sys = require('sys'); &lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
var events = require('events');&lt;br /&gt;
&lt;br /&gt;
function start(route, handle) {&lt;br /&gt;
	function onRequest(request, response){&lt;br /&gt;
      var pathname = url.parse(request.url).pathname;&lt;br /&gt;
      route(handle, pathname, response, request);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  http.createServer(onRequest).listen(3001);&lt;br /&gt;
  console.log(&amp;quot;Server has started.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.start = start;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* router.js gets the request's pathname and call different functions according to different request url:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function route(handle, pathname, response, request) {&lt;br /&gt;
  console.log(&amp;quot;About to route a request for &amp;quot; + pathname);&lt;br /&gt;
  if (typeof handle[pathname] === 'function') {&lt;br /&gt;
    handle[pathname](response, request);&lt;br /&gt;
  } else {&lt;br /&gt;
    console.log(&amp;quot;No request handler found for &amp;quot; + pathname);&lt;br /&gt;
    response.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    response.write(&amp;quot;404 Not found&amp;quot;);&lt;br /&gt;
    response.end();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.route = route;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* In requestHandlers.js, we need two functions, one for handle i2c request, another for led toggling request:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function i2c(response, request) {&lt;br /&gt;
  var uri = url.parse(request.url).pathname;&lt;br /&gt;
  ...//same as described above, including calling loadHTMLFile function that's also in requestHandlers.js&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  ...//details in below&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. Now it's time for us to think about how to toggle LED via web page. Turns out it's very similar to how i2c works. However, this time we need to not only parse the uri of the request, but also get the posted data from the request, parse them and write them into the appropriate file system. The event-driven nodejs utilizes &amp;quot;addListener&amp;quot; function to achieve the task, with parameter &amp;quot;data&amp;quot; to receive the data and &amp;quot;end&amp;quot; to handle and process them. The data received(in type of string) should be converted to object class by the &amp;quot;querystring&amp;quot; module. &lt;br /&gt;
&lt;br /&gt;
On the client side, we use exclusive radio button to allow user to choose the toggle mode of LED:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/led&amp;quot; method=&amp;quot;post&amp;quot; size=&amp;quot;30&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;nand-disk&amp;quot; &amp;gt;nand-disk&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;mmc0&amp;quot; /&amp;gt;mmc0&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;heartbeat&amp;quot; &amp;gt;heartbeat&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;none&amp;quot; &amp;gt;none&lt;br /&gt;
            &amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Select&amp;quot;  onclick=&amp;quot;xmlhttpPost()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding javascript just submits this form to /led, which then be handled by router to execute led() function:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function xmlhttpPost() {&lt;br /&gt;
documents.forms[1].submit();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The following is the server side function code in requestHandlers.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var qs = require('querystring');&lt;br /&gt;
var url = require('url');&lt;br /&gt;
var sys = require('sys');&lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  var postData = &amp;quot;&amp;quot;;&lt;br /&gt;
   var pathname = url.parse(request.url).pathname;&lt;br /&gt;
   console.log(&amp;quot;Request for &amp;quot; + pathname + &amp;quot; received.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    request.setEncoding(&amp;quot;utf8&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    request.addListener(&amp;quot;data&amp;quot;, function(postDataChunk) {&lt;br /&gt;
      postData += postDataChunk;&lt;br /&gt;
      console.log(&amp;quot;Received POST data chunk '&amp;quot;+&lt;br /&gt;
      postDataChunk + &amp;quot;'.&amp;quot;);&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    request.addListener(&amp;quot;end&amp;quot;, function() {&lt;br /&gt;
      var ledtype = qs.parse(postData);&lt;br /&gt;
          console.log(ledtype.mode);&lt;br /&gt;
          fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, ledtype.mode);&lt;br /&gt;
    });&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Another thing to notice is, in order for this requestHandler for led.js not to jump to a brand new web page but stay on the current one, the normal &amp;quot;request.end()&amp;quot; code, which indicates the completion of an intact .js page, should be left out.&lt;br /&gt;
7. Eventually we did a little bit beautification on the html page --- somehow CSS does not work as intended, we simply change some font and color of the output to make it a bit neater.&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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-19T06:32:01Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. We also tried to make our web server send automatic email when temperature goes too high. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
The automatic email sender is not working correctly. More work needs to be done to set a proper configuration to the SMTP server 'postfix'.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install mailer module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install mailer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install SMTP server postfix&lt;br /&gt;
Go to [http://postfix.energybeam.com/source/index.html] download the source of postfix, then unzip the .gz file, then run 'make', then run &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sh postfix-install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
To build a web server, we need, in essence, both client side and server side scripts. Client side scripts mainly just involve ordinary javascripts that can be embedded in HTML file; while at the server-side, we adopt the emerging node.js, which is a really simple server side script that accomplishes equivalent tasks like ASP, PHP will do, but with even simpler implementation details.&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts. The following code snippet can accomplish this (borrowed and modified based on Jadon's code):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function loadHTMLFile(uri, res, temp) {&lt;br /&gt;
 var filename = path.join(process.cwd(), uri);&lt;br /&gt;
 path.exists(&lt;br /&gt;
  filename,&lt;br /&gt;
  function(exists) {&lt;br /&gt;
   if(!exists) {&lt;br /&gt;
    res.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    res.write(&amp;quot;404 Not Found\n&amp;quot;);&lt;br /&gt;
    res.end();&lt;br /&gt;
    return;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fs.readFile(&lt;br /&gt;
    filename,&lt;br /&gt;
    encoding='utf8',&lt;br /&gt;
    function(err, file) {&lt;br /&gt;
     if(err) {&lt;br /&gt;
      res.writeHead(500, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
      res.write(err + &amp;quot;\n&amp;quot;);&lt;br /&gt;
      res.end();&lt;br /&gt;
      return;&lt;br /&gt;
     }&lt;br /&gt;
     res.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/html&amp;quot;});&lt;br /&gt;
     var str = (&amp;quot;&amp;quot; + file).replace(&amp;quot;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;quot;, temp);&lt;br /&gt;
     res.write(str);&lt;br /&gt;
     res.end();&lt;br /&gt;
    }&lt;br /&gt;
   );&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And outside the above function, the main routine, we have similar code as listed in 3, but insert the function call:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				loadHTMLFile('/index.html', response, stdout);&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes. Here is the simple client script for accomplishing this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
setInterval(&amp;quot;document.forms[0].submit()&amp;quot;,5000);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Welcome to the world of Node.js&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here is the demo of the weather station.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Current temperature:&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;temperature output&amp;quot;&amp;gt;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/test.js&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;get temperature&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Now we are trying to do something fancy! We want to send the user an automatic warning email when the temperature is too high. Here's the Javascript code using node.js mailer module. This code use SMTP server to send email to the destination.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var email = require('mailer');&lt;br /&gt;
&lt;br /&gt;
email.SMTP = {&lt;br /&gt;
    host: 'smtp.gmail.com',&lt;br /&gt;
    port: 587,&lt;br /&gt;
    ssl: false,&lt;br /&gt;
    use_authentication: false,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
email.send({&lt;br /&gt;
    to : &amp;quot;caoy1@rose-hulman.edu&amp;quot;,&lt;br /&gt;
    from : &amp;quot;obama@whitehouse.gov&amp;quot;,&lt;br /&gt;
    subject : &amp;quot;I love beagleboard!&amp;quot;,&lt;br /&gt;
    body: &amp;quot;Hello beagle world.&amp;quot;,&lt;br /&gt;
}, &lt;br /&gt;
&lt;br /&gt;
function(err, result) {&lt;br /&gt;
    if(err) {&lt;br /&gt;
	console.log(err);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* However, the configuration on our beagle has some problem. The server has no response to mailer's request. We've tried telnet localhost 587, and connection can be connected. This means the 587 port is already opened. Then I tried the same code under my ubuntu system, it turns out everything works fine, the caoy1@rose-hulman.edu can receive the e-mail, except some client-side warning error when running the mail.js file. I think the reason it works on ubuntu is because when installing postfix, there's an automatic configuration step, which doesn't exist on our beagle installation. So there must be some problem with the postfix configuration of beagleboard. I've tried to copy all the configuration files under /etc/postfix to our beagleboard, but there's just the same problem. If I have more time, or someone else who's interested in continuing this project, I suggest you have some research on the configuration thing. Everytime you make some config changes, just run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postfix reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to apply the change.&lt;br /&gt;
&lt;br /&gt;
5. Our next goal is to toggle LED via web page, whose control flow structure is essentially similar to the i2c communications, plus, we have already learned the way to write to the led pin via nodejs script(see note1 above).&lt;br /&gt;
* Before actually doing that, let's first organize our code in a more hierarchical and reasonable way.Thanks to Mr. Manuel Kiessling's excellent introductory tutorial &amp;quot;[http://www.nodebeginner.org The Node Beginner Book]&amp;quot;, which gives a pretty decent explanation on how a formal web server architecture should be constructed using nodejs. Basically, we should maintain an index.js that starts all of our code, have a server.js to actually create the server and listen on the port for any posts from the client side, and pass the request and response to the router.js to handle different requests. In requestHandlers.js, each function then does the real work based on the request information and execute corresponding server responses. &lt;br /&gt;
* The following is what's in index.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var server = require(&amp;quot;./server&amp;quot;);&lt;br /&gt;
var router = require(&amp;quot;./router&amp;quot;);&lt;br /&gt;
var requestHandlers = require(&amp;quot;./requestHandlers&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
var handle = {}&lt;br /&gt;
handle[&amp;quot;/&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
handle[&amp;quot;/led&amp;quot;] = requestHandlers.led;&lt;br /&gt;
handle[&amp;quot;/i2c&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
&lt;br /&gt;
server.start(router.route, handle);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* And we abstract the server.js to be a general form so it is independent of what will actually be done at the server, such details is left for requestHandlers.js to accomplish:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
var url = require(&amp;quot;url&amp;quot;);&lt;br /&gt;
var sys = require('sys'); &lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
var events = require('events');&lt;br /&gt;
&lt;br /&gt;
function start(route, handle) {&lt;br /&gt;
	function onRequest(request, response){&lt;br /&gt;
      var pathname = url.parse(request.url).pathname;&lt;br /&gt;
      route(handle, pathname, response, request);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  http.createServer(onRequest).listen(3001);&lt;br /&gt;
  console.log(&amp;quot;Server has started.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.start = start;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* router.js gets the request's pathname and call different functions according to different request url:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function route(handle, pathname, response, request) {&lt;br /&gt;
  console.log(&amp;quot;About to route a request for &amp;quot; + pathname);&lt;br /&gt;
  if (typeof handle[pathname] === 'function') {&lt;br /&gt;
    handle[pathname](response, request);&lt;br /&gt;
  } else {&lt;br /&gt;
    console.log(&amp;quot;No request handler found for &amp;quot; + pathname);&lt;br /&gt;
    response.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    response.write(&amp;quot;404 Not found&amp;quot;);&lt;br /&gt;
    response.end();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.route = route;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* In requestHandlers.js, we need two functions, one for handle i2c request, another for led toggling request:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function i2c(response, request) {&lt;br /&gt;
  var uri = url.parse(request.url).pathname;&lt;br /&gt;
  ...//same as described above, including calling loadHTMLFile function that's also in requestHandlers.js&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  ...//details in below&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. Now it's time for us to think about how to toggle LED via web page. Turns out it's very similar to how i2c works. However, this time we need to not only parse the uri of the request, but also get the posted data from the request, parse them and write them into the appropriate file system. The event-driven nodejs utilizes &amp;quot;addListener&amp;quot; function to achieve the task, with parameter &amp;quot;data&amp;quot; to receive the data and &amp;quot;end&amp;quot; to handle and process them. The data received(in type of string) should be converted to object class by the &amp;quot;querystring&amp;quot; module. &lt;br /&gt;
On the client side, we use exclusive radio button to allow user to choose the toggle mode of LED:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/led&amp;quot; method=&amp;quot;post&amp;quot; size=&amp;quot;30&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;nand-disk&amp;quot; &amp;gt;nand-disk&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;mmc0&amp;quot; /&amp;gt;mmc0&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;heartbeat&amp;quot; &amp;gt;heartbeat&lt;br /&gt;
            &amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;mode&amp;quot; value=&amp;quot;none&amp;quot; &amp;gt;none&lt;br /&gt;
            &amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Select&amp;quot;  onclick=&amp;quot;xmlhttpPost()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The corresponding javascript just submits this form to /led, which then be handled by router to execute led() function:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function xmlhttpPost() {&lt;br /&gt;
documents.forms[1].submit();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The following is the server side function code in requestHandlers.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var qs = require('querystring');&lt;br /&gt;
var url = require('url');&lt;br /&gt;
var sys = require('sys');&lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  var postData = &amp;quot;&amp;quot;;&lt;br /&gt;
   var pathname = url.parse(request.url).pathname;&lt;br /&gt;
   console.log(&amp;quot;Request for &amp;quot; + pathname + &amp;quot; received.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    request.setEncoding(&amp;quot;utf8&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    request.addListener(&amp;quot;data&amp;quot;, function(postDataChunk) {&lt;br /&gt;
      postData += postDataChunk;&lt;br /&gt;
      console.log(&amp;quot;Received POST data chunk '&amp;quot;+&lt;br /&gt;
      postDataChunk + &amp;quot;'.&amp;quot;);&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    request.addListener(&amp;quot;end&amp;quot;, function() {&lt;br /&gt;
      var ledtype = qs.parse(postData);&lt;br /&gt;
          console.log(ledtype.mode);&lt;br /&gt;
          fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, ledtype.mode);&lt;br /&gt;
    });&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Another thing to notice is, in order for this requestHandler for led.js not to jump to a brand new web page but stay on the current one, the normal &amp;quot;request.end()&amp;quot; code, which indicates the completion of an intact .js page, should be left out.&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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-19T06:20:16Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. We also tried to make our web server send automatic email when temperature goes too high. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
The automatic email sender is not working correctly. More work needs to be done to set a proper configuration to the SMTP server 'postfix'.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install mailer module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install mailer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install SMTP server postfix&lt;br /&gt;
Go to [http://postfix.energybeam.com/source/index.html] download the source of postfix, then unzip the .gz file, then run 'make', then run &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sh postfix-install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
To build a web server, we need, in essence, both client side and server side scripts. Client side scripts mainly just involve ordinary javascripts that can be embedded in HTML file; while at the server-side, we adopt the emerging node.js, which is a really simple server side script that accomplishes equivalent tasks like ASP, PHP will do, but with even simpler implementation details.&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts. The following code snippet can accomplish this (borrowed and modified based on Jadon's code):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function loadHTMLFile(uri, res, temp) {&lt;br /&gt;
 var filename = path.join(process.cwd(), uri);&lt;br /&gt;
 path.exists(&lt;br /&gt;
  filename,&lt;br /&gt;
  function(exists) {&lt;br /&gt;
   if(!exists) {&lt;br /&gt;
    res.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    res.write(&amp;quot;404 Not Found\n&amp;quot;);&lt;br /&gt;
    res.end();&lt;br /&gt;
    return;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fs.readFile(&lt;br /&gt;
    filename,&lt;br /&gt;
    encoding='utf8',&lt;br /&gt;
    function(err, file) {&lt;br /&gt;
     if(err) {&lt;br /&gt;
      res.writeHead(500, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
      res.write(err + &amp;quot;\n&amp;quot;);&lt;br /&gt;
      res.end();&lt;br /&gt;
      return;&lt;br /&gt;
     }&lt;br /&gt;
     res.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/html&amp;quot;});&lt;br /&gt;
     var str = (&amp;quot;&amp;quot; + file).replace(&amp;quot;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;quot;, temp);&lt;br /&gt;
     res.write(str);&lt;br /&gt;
     res.end();&lt;br /&gt;
    }&lt;br /&gt;
   );&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And outside the above function, the main routine, we have similar code as listed in 3, but insert the function call:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				loadHTMLFile('/index.html', response, stdout);&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes. Here is the simple client script for accomplishing this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
setInterval(&amp;quot;document.forms[0].submit()&amp;quot;,5000);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Welcome to the world of Node.js&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here is the demo of the weather station.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Current temperature:&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;temperature output&amp;quot;&amp;gt;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/test.js&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;get temperature&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Now we are trying to do something fancy! We want to send the user an automatic warning email when the temperature is too high. Here's the Javascript code using node.js mailer module. This code use SMTP server to send email to the destination.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var email = require('mailer');&lt;br /&gt;
&lt;br /&gt;
email.SMTP = {&lt;br /&gt;
    host: 'smtp.gmail.com',&lt;br /&gt;
    port: 587,&lt;br /&gt;
    ssl: false,&lt;br /&gt;
    use_authentication: false,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
email.send({&lt;br /&gt;
    to : &amp;quot;caoy1@rose-hulman.edu&amp;quot;,&lt;br /&gt;
    from : &amp;quot;obama@whitehouse.gov&amp;quot;,&lt;br /&gt;
    subject : &amp;quot;I love beagleboard!&amp;quot;,&lt;br /&gt;
    body: &amp;quot;Hello beagle world.&amp;quot;,&lt;br /&gt;
}, &lt;br /&gt;
&lt;br /&gt;
function(err, result) {&lt;br /&gt;
    if(err) {&lt;br /&gt;
	console.log(err);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* However, the configuration on our beagle has some problem. The server has no response to mailer's request. We've tried telnet localhost 587, and connection can be connected. This means the 587 port is already opened. Then I tried the same code under my ubuntu system, it turns out everything works fine, the caoy1@rose-hulman.edu can receive the e-mail, except some client-side warning error when running the mail.js file. I think the reason it works on ubuntu is because when installing postfix, there's an automatic configuration step, which doesn't exist on our beagle installation. So there must be some problem with the postfix configuration of beagleboard. I've tried to copy all the configuration files under /etc/postfix to our beagleboard, but there's just the same problem. If I have more time, or someone else who's interested in continuing this project, I suggest you have some research on the configuration thing. Everytime you make some config changes, just run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postfix reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to apply the change.&lt;br /&gt;
&lt;br /&gt;
5. Our next goal is to toggle LED via web page, whose control flow structure is essentially similar to the i2c communications, plus, we have already learned the way to write to the led pin via nodejs script(see note1 above).&lt;br /&gt;
* Before actually doing that, let's first organize our code in a more hierarchical and reasonable way.Thanks to Mr. Manuel Kiessling's excellent introductory tutorial &amp;quot;[http://www.nodebeginner.org The Node Beginner Book]&amp;quot;, which gives a pretty decent explanation on how a formal web server architecture should be constructed using nodejs. Basically, we should maintain an index.js that starts all of our code, have a server.js to actually create the server and listen on the port for any posts from the client side, and pass the request and response to the router.js to handle different requests. In requestHandlers.js, each function then does the real work based on the request information and execute corresponding server responses. &lt;br /&gt;
* The following is what's in index.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var server = require(&amp;quot;./server&amp;quot;);&lt;br /&gt;
var router = require(&amp;quot;./router&amp;quot;);&lt;br /&gt;
var requestHandlers = require(&amp;quot;./requestHandlers&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
var handle = {}&lt;br /&gt;
handle[&amp;quot;/&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
handle[&amp;quot;/led&amp;quot;] = requestHandlers.led;&lt;br /&gt;
handle[&amp;quot;/i2c&amp;quot;] = requestHandlers.i2c;&lt;br /&gt;
&lt;br /&gt;
server.start(router.route, handle);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* And we abstract the server.js to be a general form so it is independent of what will actually be done at the server, such details is left for requestHandlers.js to accomplish:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
var url = require(&amp;quot;url&amp;quot;);&lt;br /&gt;
var sys = require('sys'); &lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
var events = require('events');&lt;br /&gt;
&lt;br /&gt;
function start(route, handle) {&lt;br /&gt;
	function onRequest(request, response){&lt;br /&gt;
      var pathname = url.parse(request.url).pathname;&lt;br /&gt;
      route(handle, pathname, response, request);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  http.createServer(onRequest).listen(3001);&lt;br /&gt;
  console.log(&amp;quot;Server has started.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.start = start;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* router.js gets the request's pathname and call different functions according to different request url:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function route(handle, pathname, response, request) {&lt;br /&gt;
  console.log(&amp;quot;About to route a request for &amp;quot; + pathname);&lt;br /&gt;
  if (typeof handle[pathname] === 'function') {&lt;br /&gt;
    handle[pathname](response, request);&lt;br /&gt;
  } else {&lt;br /&gt;
    console.log(&amp;quot;No request handler found for &amp;quot; + pathname);&lt;br /&gt;
    response.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    response.write(&amp;quot;404 Not found&amp;quot;);&lt;br /&gt;
    response.end();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
exports.route = route;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* In requestHandlers.js, we need two functions, one for handle i2c request, another for led toggling request:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var qs = require('querystring');&lt;br /&gt;
var url = require('url');&lt;br /&gt;
var sys = require('sys');&lt;br /&gt;
var fs = require('fs');&lt;br /&gt;
var path = require('path');&lt;br /&gt;
&lt;br /&gt;
  function i2c(response, request) {&lt;br /&gt;
  var uri = url.parse(request.url).pathname;&lt;br /&gt;
  ...//same as described above, including calling loadHTMLFile function that's also in requestHandlers.js&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
function led(response, request) {&lt;br /&gt;
  ...//details in below&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. Now it's time for us to think about how to toggle LED via web page.&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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-19T05:26:23Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. We also tried to make our web server send automatic email when temperature goes too high. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
The automatic email sender is not working correctly. More work needs to be done to set a proper configuration to the SMTP server 'postfix'.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install mailer module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install mailer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install SMTP server postfix&lt;br /&gt;
Go to [http://postfix.energybeam.com/source/index.html] download the source of postfix, then unzip the .gz file, then run 'make', then run &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sh postfix-install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
To build a web server, we need, in essence, both client side and server side scripts. Client side scripts mainly just involve ordinary javascripts that can be embedded in HTML file; while at the server-side, we adopt the emerging node.js, which is a really simple server side script that accomplishes equivalent tasks like ASP, PHP will do, but with even simpler implementation details.&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts. The following code snippet can accomplish this (borrowed and modified based on Jadon's code):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function loadHTMLFile(uri, res, temp) {&lt;br /&gt;
 var filename = path.join(process.cwd(), uri);&lt;br /&gt;
 path.exists(&lt;br /&gt;
  filename,&lt;br /&gt;
  function(exists) {&lt;br /&gt;
   if(!exists) {&lt;br /&gt;
    res.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    res.write(&amp;quot;404 Not Found\n&amp;quot;);&lt;br /&gt;
    res.end();&lt;br /&gt;
    return;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fs.readFile(&lt;br /&gt;
    filename,&lt;br /&gt;
    encoding='utf8',&lt;br /&gt;
    function(err, file) {&lt;br /&gt;
     if(err) {&lt;br /&gt;
      res.writeHead(500, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
      res.write(err + &amp;quot;\n&amp;quot;);&lt;br /&gt;
      res.end();&lt;br /&gt;
      return;&lt;br /&gt;
     }&lt;br /&gt;
     res.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/html&amp;quot;});&lt;br /&gt;
     var str = (&amp;quot;&amp;quot; + file).replace(&amp;quot;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;quot;, temp);&lt;br /&gt;
     res.write(str);&lt;br /&gt;
     res.end();&lt;br /&gt;
    }&lt;br /&gt;
   );&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And outside the above function, the main routine, we have similar code as listed in 3, but insert the function call:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				loadHTMLFile('/index.html', response, stdout);&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes. Here is the simple client script for accomplishing this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
setInterval(&amp;quot;document.forms[0].submit()&amp;quot;,5000);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Welcome to the world of Node.js&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here is the demo of the weather station.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Current temperature:&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;temperature output&amp;quot;&amp;gt;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/test.js&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;get temperature&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Now we are trying to do something fancy! We want to send the user an automatic warning email when the temperature is too high. Here's the Javascript code using node.js mailer module. This code use SMTP server to send email to the destination.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var email = require('mailer');&lt;br /&gt;
&lt;br /&gt;
email.SMTP = {&lt;br /&gt;
    host: 'smtp.gmail.com',&lt;br /&gt;
    port: 587,&lt;br /&gt;
    ssl: false,&lt;br /&gt;
    use_authentication: false,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
email.send({&lt;br /&gt;
    to : &amp;quot;caoy1@rose-hulman.edu&amp;quot;,&lt;br /&gt;
    from : &amp;quot;obama@whitehouse.gov&amp;quot;,&lt;br /&gt;
    subject : &amp;quot;I love beagleboard!&amp;quot;,&lt;br /&gt;
    body: &amp;quot;Hello beagle world.&amp;quot;,&lt;br /&gt;
}, &lt;br /&gt;
&lt;br /&gt;
function(err, result) {&lt;br /&gt;
    if(err) {&lt;br /&gt;
	console.log(err);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* However, the configuration on our beagle has some problem. The server has no response to mailer's request. We've tried telnet localhost 587, and connection can be connected. This means the 587 port is already opened. Then I tried the same code under my ubuntu system, it turns out everything works fine, the caoy1@rose-hulman.edu can receive the e-mail, except some client-side warning error when running the mail.js file. I think the reason it works on ubuntu is because when installing postfix, there's an automatic configuration step, which doesn't exist on our beagle installation. So there must be some problem with the postfix configuration of beagleboard. I've tried to copy all the configuration files under /etc/postfix to our beagleboard, but there's just the same problem. If I have more time, or someone else who's interested in continuing this project, I suggest you have some research on the configuration thing. Everytime you make some config changes, just run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postfix reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to apply the change.&lt;br /&gt;
&lt;br /&gt;
5. Our next goal is to toggle LED via web page, whose control flow structure is essentially similar to the i2c communications, plus, we have already learned the way to write to the led pin via nodejs script(see note1 above).&lt;br /&gt;
* Before actually doing that, let's first organize our code in a more hierarchical and reasonable way.Thanks to Mr. Manuel Kiessling's excellent introductory tutorial &amp;quot;[http://www.nodebeginner.org The Node Beginner Book]&amp;quot;&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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-17T22:25:44Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
To build a web server, we need, in essence, both client side and server side scripts. Client side scripts mainly just involve ordinary javascripts that can be embedded in HTML file; while at the server-side, we adopt the emerging node.js, which is a really simple server side script that accomplishes equivalent tasks like ASP, PHP will do, but with even simpler implementation details.&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts. The following code snippet can accomplish this (borrowed and modified based on Jadon's code):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function loadHTMLFile(uri, res, temp) {&lt;br /&gt;
 var filename = path.join(process.cwd(), uri);&lt;br /&gt;
 path.exists(&lt;br /&gt;
  filename,&lt;br /&gt;
  function(exists) {&lt;br /&gt;
   if(!exists) {&lt;br /&gt;
    res.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    res.write(&amp;quot;404 Not Found\n&amp;quot;);&lt;br /&gt;
    res.end();&lt;br /&gt;
    return;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fs.readFile(&lt;br /&gt;
    filename,&lt;br /&gt;
    encoding='utf8',&lt;br /&gt;
    function(err, file) {&lt;br /&gt;
     if(err) {&lt;br /&gt;
      res.writeHead(500, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
      res.write(err + &amp;quot;\n&amp;quot;);&lt;br /&gt;
      res.end();&lt;br /&gt;
      return;&lt;br /&gt;
     }&lt;br /&gt;
     res.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/html&amp;quot;});&lt;br /&gt;
     var str = (&amp;quot;&amp;quot; + file).replace(&amp;quot;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;quot;, temp);&lt;br /&gt;
     res.write(str);&lt;br /&gt;
     res.end();&lt;br /&gt;
    }&lt;br /&gt;
   );&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And outside the above function, the main routine, we have similar code as listed in 3, but insert the function call:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				loadHTMLFile('/index.html', response, stdout);&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes. Here is the simple client script for accomplishing this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
setInterval(&amp;quot;document.forms[0].submit()&amp;quot;,5000);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Welcome to the world of Node.js&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here is the demo of the weather station.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Current temperature:&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;temperature output&amp;quot;&amp;gt;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/test.js&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;get temperature&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== 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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-17T22:19:37Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts. The following code snippet can accomplish this (borrowed and modified based on Jadon's code):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function loadHTMLFile(uri, res, temp) {&lt;br /&gt;
 var filename = path.join(process.cwd(), uri);&lt;br /&gt;
 path.exists(&lt;br /&gt;
  filename,&lt;br /&gt;
  function(exists) {&lt;br /&gt;
   if(!exists) {&lt;br /&gt;
    res.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    res.write(&amp;quot;404 Not Found\n&amp;quot;);&lt;br /&gt;
    res.end();&lt;br /&gt;
    return;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fs.readFile(&lt;br /&gt;
    filename,&lt;br /&gt;
    encoding='utf8',&lt;br /&gt;
    function(err, file) {&lt;br /&gt;
     if(err) {&lt;br /&gt;
      res.writeHead(500, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
      res.write(err + &amp;quot;\n&amp;quot;);&lt;br /&gt;
      res.end();&lt;br /&gt;
      return;&lt;br /&gt;
     }&lt;br /&gt;
     res.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/html&amp;quot;});&lt;br /&gt;
     var str = (&amp;quot;&amp;quot; + file).replace(&amp;quot;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;quot;, temp);&lt;br /&gt;
     res.write(str);&lt;br /&gt;
     res.end();&lt;br /&gt;
    }&lt;br /&gt;
   );&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And outside the above function, the main routine, we have similar code as listed in 3, but insert the function call:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				loadHTMLFile('/index.html', response, stdout);&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes. Here is the simple client script for accomplishing this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
setInterval(&amp;quot;document.forms[0].submit()&amp;quot;,5000);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Welcome to the world of Node.js&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here is the demo of the weather station.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Current temperature:&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;temperature output&amp;quot;&amp;gt;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/test.js&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;get temperature&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== 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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-17T22:18:52Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts. The following code snippet can accomplish this (borrowed and modified based on Jadon's code):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function loadHTMLFile(uri, res, temp) {&lt;br /&gt;
 var filename = path.join(process.cwd(), uri);&lt;br /&gt;
 path.exists(&lt;br /&gt;
  filename,&lt;br /&gt;
  function(exists) {&lt;br /&gt;
   if(!exists) {&lt;br /&gt;
    res.writeHead(404, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
    res.write(&amp;quot;404 Not Found\n&amp;quot;);&lt;br /&gt;
    res.end();&lt;br /&gt;
    return;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   fs.readFile(&lt;br /&gt;
    filename,&lt;br /&gt;
    encoding='utf8',&lt;br /&gt;
    function(err, file) {&lt;br /&gt;
     if(err) {&lt;br /&gt;
      res.writeHead(500, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
      res.write(err + &amp;quot;\n&amp;quot;);&lt;br /&gt;
      res.end();&lt;br /&gt;
      return;&lt;br /&gt;
     }&lt;br /&gt;
     res.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/html&amp;quot;});&lt;br /&gt;
     var str = (&amp;quot;&amp;quot; + file).replace(&amp;quot;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;quot;, temp);&lt;br /&gt;
     res.write(str);&lt;br /&gt;
     res.end();&lt;br /&gt;
    }&lt;br /&gt;
   );&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And outside the above function, the main routine, we have similar code as listed in 3, but insert the function call:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				loadHTMLFile('/index.html', response, stdout);&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes. Here is the simple client script for accomplishing this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
setInterval(&amp;quot;document.forms[0].submit()&amp;quot;,5000);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Welcome to the world of Node.js&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here is the demo of the weather station.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Current temperature:&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;temperature output&amp;quot;&amp;gt;&amp;lt;!--%OUTPUT%--&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;form action = &amp;quot;/test.js&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;get temperature&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== 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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-17T22:09:50Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard. There are a lot of things we can do on the nodejs web server, but we try to make it related to our beagleboard hardware interface. &lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access the I2C information. In the I2C exercises, from the C code provided in exercise 5, we can think of the following two options:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...including rewriting the union structures like i2c_smbus_write_byte() and i2c_smbus_read_byte(), which requires far more knowledge in understanding how to translate the underlying hardware detail into upper-level script languages...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file directly inside nodjs script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... turns out this does not work for some reason.&lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts.&lt;br /&gt;
&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes.&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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-17T22:00:08Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
1. Here's our [https://github.com/ github] path that includes everything useful to our project: [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
&lt;br /&gt;
2. Additional packages installed via '''opkg''':&lt;br /&gt;
&lt;br /&gt;
* install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
1. We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Even though we can access to the gpio in the above way, we still need to find someway to access to the I2C information. In the I2C exercises, in the C code provided in exercise 5, we still need to find some way in our javaScript instead of using i2c_smbus_write_byte() and i2c_smbus_read_byte(). Now there are two options for us:&lt;br /&gt;
&lt;br /&gt;
a) To translate tons of the C codes into JavaScript...&lt;br /&gt;
&lt;br /&gt;
b) Try to run the ./myi2c excutable file inside script...&lt;br /&gt;
&lt;br /&gt;
* It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this... &lt;br /&gt;
&lt;br /&gt;
* At last we successfully excute the ./myi2c file inside our javascript using the following code, the big idea is create another child process to handle it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var exec  = require('child_process').exec,&lt;br /&gt;
    child;&lt;br /&gt;
child = exec('./myi2c',&lt;br /&gt;
  function (error, stdout, stderr) {&lt;br /&gt;
    console.log('stdout:', stdout);&lt;br /&gt;
    console.log('stderr:', stderr);&lt;br /&gt;
    if (error !== null) {&lt;br /&gt;
      console.log('exec error:', error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the terminal will show the temperature. &lt;br /&gt;
&lt;br /&gt;
3. Now we are going to working on how to show this temperature information on the website so that we can visit it from any place!!!&lt;br /&gt;
&lt;br /&gt;
* I've successfully done it!!! The pics are already uploaded to the github. Check the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var fs = require(&amp;quot;fs&amp;quot;);&lt;br /&gt;
var http = require(&amp;quot;http&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
	http.createServer(function(request, response) {&lt;br /&gt;
&lt;br /&gt;
		response.writeHead(200, {&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;});&lt;br /&gt;
		var exec = require('child_process').exec, child;&lt;br /&gt;
		child = exec('./myi2c',&lt;br /&gt;
	    		function (error, stdout, stderr) {&lt;br /&gt;
				response.write(stdout);&lt;br /&gt;
				console.log('stdout:', stdout);&lt;br /&gt;
				console.log('stderr:', stderr);&lt;br /&gt;
				response.end();&lt;br /&gt;
				if(error != null) {&lt;br /&gt;
					console.log('exec error:', error);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		);&lt;br /&gt;
	}).listen(8888);&lt;br /&gt;
} catch(ex3) {&lt;br /&gt;
	console.log(&amp;quot;sb&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. The next thing we will do is to refresh the website every other time...&lt;br /&gt;
&lt;br /&gt;
* We are now able to load html file inside nodejs scripts so that we can put normal HTML stuff inside the web page and load it from server scripts.&lt;br /&gt;
&lt;br /&gt;
* Now we can update the temperature information on the website, both triggered by a button on the page, and by just automatically refreshing the temperature value whenever the temperature changes.&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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-13T17:34:17Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Our project aims to implement the emerging nodejs technique (the server side javascript) as a lightweight web server on the beagleboard and accomplish a series of remote monitoring and control of hardware pins like gpio/led/i2c on the beagleboard.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
&lt;br /&gt;
0. install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
* We've already successfully using JavaScript read and write data to the linux gpio file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/leds/beagleboard::usr0/trigger&amp;quot;, &amp;quot;heartbeat&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fs.writeFileSync(&amp;quot;/sys/class/gpio/export&amp;quot;, &amp;quot;&amp;quot;+5);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&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;
*Even though we can access to the gpio in the above way, we still need to find someway to access to the I2C information. In the I2C exercises, in the C code provided in exercise 5, we still need to find some way in our javaScript instead of using i2c_smbus_write_byte() and i2c_smbus_read_byte(). Now there are two options for us:&lt;br /&gt;
&lt;br /&gt;
* To translate tons of the C codes into JavaScript...&lt;br /&gt;
* Try to run the ./myi2c excutable file inside script...&lt;br /&gt;
&lt;br /&gt;
It seems that the second way is easier... We've already found a ActiveXObject.run method... We're working on this...&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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project:_Node.js_Weather_Station</id>
		<title>ECE497 Project: Node.js Weather Station</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project:_Node.js_Weather_Station"/>
				<updated>2012-02-12T02:39:31Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Caogecym | Yuming Cao]], [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/caoy1/Project https://github.com/caoy1/Project].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
&lt;br /&gt;
0. install nodejs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opkg update&lt;br /&gt;
opkg install nodejs&lt;br /&gt;
opkg install nodejs-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. install node package manager&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
curl http://npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. install socket.io module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install socket.io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. install binary module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install binary&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
* Here's the guideline to install Cloud9 easily: [https://github.com/jadonk/cloud9/blob/master/README.md]&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;
Consider including 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;
* Here's the code of how node.js will interact with beagleboard hardware&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var myStream = fs.createReadStream(&lt;br /&gt;
  '/dev/input/event2',&lt;br /&gt;
  {&lt;br /&gt;
   'bufferSize': 16&lt;br /&gt;
  }&lt;br /&gt;
 );&lt;br /&gt;
 myStream.addListener('data', myListener);&lt;br /&gt;
 myStream.addListener('error', function(error) {&lt;br /&gt;
  sys.puts(&amp;quot;Read error: &amp;quot; + error);&lt;br /&gt;
 });&lt;br /&gt;
&amp;lt;/pre&amp;gt;&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;
*Even though we can access to the gpio in the above way, we still need to find someway to access to the I2C information. In the I2C exercises, we just use the I2C tool, which is not enough for our project...&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.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/EBC_Exercise_22_Cross-Compiling</id>
		<title>EBC Exercise 22 Cross-Compiling</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/EBC_Exercise_22_Cross-Compiling"/>
				<updated>2012-01-20T01:06:10Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category: BeagleBoard]]&lt;br /&gt;
&lt;br /&gt;
This class is about developing software for embedded Linux. So far we have been doing all of our development on the Beagle. This works well for small (and not so small) programs. However, we are now moving into kernel development and that's best done on a more powerful host computer. [[EBC_Exercise_01_Using_bitbake_for_Kernel_and_U-boot | Here]] you learned how to download and install the cross-compilers and the source for kernel and u-boot. Now we'll use those tools.&lt;br /&gt;
&lt;br /&gt;
First we'll check everything by compiling the Hello World program, then we'll try the kernel and u-boot.&lt;br /&gt;
&lt;br /&gt;
== Cross-compiling Hello World ==&lt;br /&gt;
&lt;br /&gt;
Listing 2-4 on page 29 of the text is an embedded version of Hello World. If you've set up your git repository you will find it in '''helloWorld.c''' when you do a''' git pull'''.  Compile and run it on your host to be sure it works.&lt;br /&gt;
&lt;br /&gt;
 host$ '''gcc helloWorld.c'''&lt;br /&gt;
 host$ '''./a.out'''&lt;br /&gt;
 Hello, World! Main is executing at 0x400524&lt;br /&gt;
 This address (0x7fff8260bdf8) is in our stack frame&lt;br /&gt;
 This address (0x601038) is in our bss section&lt;br /&gt;
 This address (0x601020) is in our data section&lt;br /&gt;
&lt;br /&gt;
Now that you know it's working, let's cross compile it. First set the paths to find the cross-compilers. Put the following in a file, call it ~/.oe/'''crossCompileEnv.sh'''. Make sure the path is correct for your system. This is for a 32-bit linux. &lt;br /&gt;
&lt;br /&gt;
 # add cross tools to your path&lt;br /&gt;
 export ARM_TOOLCHAIN_PATH=~/BeagleBoard/oe/build/tmp-angstrom_2010_x-eglibc/sysroots/i686-linux/usr/bin/armv7a-angstrom-linux-gnueabi&lt;br /&gt;
 PATH=$PATH:$ARM_TOOLCHAIN_PATH/..&lt;br /&gt;
 PATH=$ARM_TOOLCHAIN_PATH:$PATH  &lt;br /&gt;
 export ARCH=arm&lt;br /&gt;
 export CROSS_COMPILE=arm-angstrom-linux-gnueabi-&lt;br /&gt;
&lt;br /&gt;
Here it is for 64-bit&lt;br /&gt;
&lt;br /&gt;
 # add cross tools to your path&lt;br /&gt;
 export ARM_TOOLCHAIN_PATH=~/BeagleBoard/oe/build/tmp-angstrom_2010_x-eglibc/sysroots/x86_64-linux/usr/bin/armv7a-angstrom-linux-gnueabi&lt;br /&gt;
 PATH=$PATH:$ARM_TOOLCHAIN_PATH/..&lt;br /&gt;
 PATH=$ARM_TOOLCHAIN_PATH:$PATH  &lt;br /&gt;
 export ARCH=arm&lt;br /&gt;
 export CROSS_COMPILE=arm-angstrom-linux-gnueabi-&lt;br /&gt;
&lt;br /&gt;
Now ''source'' the file and compile again. (Note: you only have to source once per terminal session.)&lt;br /&gt;
 host$ '''source ~/.oe/crossCompileEnv.sh'''&lt;br /&gt;
 host$ '''${CROSS_COMPILE}gcc helloWorld.c'''&lt;br /&gt;
 host$ '''file a.out'''&lt;br /&gt;
 a.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped&lt;br /&gt;
&lt;br /&gt;
The '''file''' command tells what's in the file.  In this case we have an ARM executable.  Success!  Now copy to your Beagle and run&lt;br /&gt;
&lt;br /&gt;
 host$ '''scp a.out root@beagle:.'''&lt;br /&gt;
 host$ '''ssh root@beagle ./a.out'''&lt;br /&gt;
 Hello, World! Main is executing at 0x8374&lt;br /&gt;
 This address (0xbeb32d4c) is in our stack frame&lt;br /&gt;
 This address (0x10650) is in our bss section&lt;br /&gt;
 This address (0x10648) is in our data section&lt;br /&gt;
&lt;br /&gt;
The '''scp''' copies a.out to the beagle and the '''ssh''' runs the a.out on the beagle. Notice the address are very different from the host version.&lt;br /&gt;
&lt;br /&gt;
== Finding the Kernel and Installing It ==&lt;br /&gt;
&lt;br /&gt;
After doing [[EBC_Exercise_01_Using_bitbake_for_Kernel_and_U-boot#Finding_the_Correct_Kernel | this]] exercise you have a Beagle kernel on your host computer. Let's see if it works.&lt;br /&gt;
&lt;br /&gt;
Once compiled the kernel is put in a file called '''uImage'''.  You may have seen it in the FAT partition on your SD card.  Let's find it on your host. One way to find it is&lt;br /&gt;
&lt;br /&gt;
 host$ '''cd ~/BeagleBoard/oe'''&lt;br /&gt;
 host$ '''find . -name &amp;quot;*uImage*&amp;quot; | grep 2.6.32 | grep boot'''&lt;br /&gt;
&lt;br /&gt;
We are looking for uImage, but we only want the 2.6.32 version.  The last grep file the file in the '''boot''' directory. Several lines are printed, but the one I'm interested in is:&lt;br /&gt;
 ''./build/tmp-angstrom_2010_x-eglibc/work/beagleboard-angstrom-linux-gnueabi/linux-omap-psp-2.6.32-r110b+gitr5fc29e7b2a76a64a739f857858ef0b98294aa155/git''/arch/arm/boot/uImage&lt;br /&gt;
&lt;br /&gt;
The first part of the path (in italics) is the path to the kernel.  Check it out.&lt;br /&gt;
&lt;br /&gt;
 host$ '''cd build/tmp-angstrom_2010_x-eglibc/work/beagleboard-angstrom-linux-gnueabi/linux-omap-psp-2.6.32-r110b+gitr5fc29e7b2a76a64a739f857858ef0b98294aa155/git'''&lt;br /&gt;
 host$ '''ls -F'''&lt;br /&gt;
 arch/           drivers/   Kbuild       modules.order   samples/    usr/&lt;br /&gt;
 block/          firmware/  kernel/      Module.symvers  scripts/    virt/&lt;br /&gt;
 COPYING         fs/        lib/         net/            security/   vmlinux*&lt;br /&gt;
 CREDITS         include/   MAINTAINERS  patches/        sound/      vmlinux.o&lt;br /&gt;
 crypto/         init/      Makefile     README          System.map&lt;br /&gt;
 Documentation/  ipc/       mm/          REPORTING-BUGS  tools/&lt;br /&gt;
&lt;br /&gt;
We'll be learning what's in many of these over the next couple of weeks.  Remember this location.  Let's find uImage.&lt;br /&gt;
&lt;br /&gt;
 host$ '''cd arch/arm/boot; ls -shF'''&lt;br /&gt;
 total 13M&lt;br /&gt;
 4.0K bootp/       6.3M Image*      4.0K Makefile  3.0M zImage*&lt;br /&gt;
 4.0K compressed/  4.0K install.sh  3.0M uImage&lt;br /&gt;
 host$ '''ls -l uImage'''&lt;br /&gt;
 -rw-r--r-- 1 beagle beagle 3144300 2011-12-08 01:02 uImage&lt;br /&gt;
&lt;br /&gt;
It should have the date that you did the bitbake.  Let's see if it runs on the Beagle&lt;br /&gt;
 host$ '''scp uImage root@beagle:.'''&lt;br /&gt;
 host$ '''ssh root@beagle'''&lt;br /&gt;
 beagle$ '''cd /boot; ls -F'''&lt;br /&gt;
 total 18M&lt;br /&gt;
 4.0K MLO@&lt;br /&gt;
 372K Module.symvers-2.6.32&lt;br /&gt;
 1.4M System.map-2.6.32&lt;br /&gt;
  80K config-2.6.32&lt;br /&gt;
 4.0K u-boot.bin@&lt;br /&gt;
    0 uImage@&lt;br /&gt;
 3.1M uImage-2.6.32&lt;br /&gt;
 8.9M vmlinux-2.6.32&lt;br /&gt;
 beagle$ '''ls -l uImage'''&lt;br /&gt;
 lrwxrwxrwx 1 www-data www-data 13 May 12  2011 uImage -&amp;gt; uImage-2.6.32&lt;br /&gt;
&lt;br /&gt;
So the uImage that is there is a symbolic link to '''uImage-2.6.32'''.  Let's save the working uImage in a difference file and copy our new uImage in.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''mv uImage-2.6.32 uImage-2.6.32.orig'''&lt;br /&gt;
 beagle$ '''mv ~/uImage uImage-2.6.32'''&lt;br /&gt;
&lt;br /&gt;
And then reboot.&lt;br /&gt;
 beagle$ '''shutdown -r now'''&lt;br /&gt;
&lt;br /&gt;
After a couple of minutes your should be back and running again.  Check and see if you are really running the new kernel.&lt;br /&gt;
 beagle$ '''uname -a'''&lt;br /&gt;
 Linux beagleboard 2.6.32 #3 PREEMPT Thu Dec 8 01:02:13 EST 2011 armv7l GNU/Linux&lt;br /&gt;
&lt;br /&gt;
It worked! That's the date I compiled mine on.&lt;br /&gt;
&lt;br /&gt;
== Installing a New U-boot ==&lt;br /&gt;
&lt;br /&gt;
While we're at it, let's install a new U-boot.  Note:  The new U-boot isn't working for me.&lt;br /&gt;
&lt;br /&gt;
 host$ '''cd ~/BeagleBoard/oe/build/tmp-angstrom_2010_x-eglibc/work/beagleboard-angstrom-linux-gnueabi/'''&lt;br /&gt;
 host$ '''ls -F'''&lt;br /&gt;
 linux-3.0.9-r110a/&lt;br /&gt;
 linux-omap-psp-2.6.32-r110b+gitr5fc29e7b2a76a64a739f857858ef0b98294aa155/&lt;br /&gt;
 shadow-4.1.4.3-r5/&lt;br /&gt;
 u-boot-2011.09-r4/&lt;br /&gt;
&lt;br /&gt;
There's the U-boot directory.&lt;br /&gt;
&lt;br /&gt;
 host$ cd u-boot-2011.09-r4/git/; ls -F&lt;br /&gt;
 api/        COPYING    fs/          mkconfig*     post/            tools/&lt;br /&gt;
 arch/       CREDITS    include/     mmc_spl/      README           u-boot*&lt;br /&gt;
 board/      disk/      lib/         nand_spl/     rules.mk         '''u-boot.bin'''&lt;br /&gt;
 boards.cfg  doc/       MAINTAINERS  net/          snapshot.commit  u-boot.lds&lt;br /&gt;
 common/     drivers/   MAKEALL*     onenand_ipl/  spl/             u-boot.map&lt;br /&gt;
 config.mk   examples/  Makefile     patches/      System.map       u-boot.srec&lt;br /&gt;
&lt;br /&gt;
The file we want is right on the top level.&lt;br /&gt;
&lt;br /&gt;
 host$ '''scp u-boot.bin root@beagle:.'''&lt;br /&gt;
 host$ '''ssh -X root@beagle'''&lt;br /&gt;
 beagle$ '''cd /media/mmcblk0p1/; ls -F'''&lt;br /&gt;
MLO*         u-boot.bin.broken*  uEnv.txt*&lt;br /&gt;
U-BOOT.BIN*  UIMAGE*             uEnv/&lt;br /&gt;
&lt;br /&gt;
Here we've changed to the FAT partition which is where u-boot lives.  Back it up and install the new one.&lt;br /&gt;
&lt;br /&gt;
 beagle$ '''mv U-BOOT-BIN u-boot-bin.orig'''&lt;br /&gt;
 beagle$ '''mv ~/.u-boot-bin .'''&lt;br /&gt;
 beagle$ '''shutdown -r now'''&lt;br /&gt;
&lt;br /&gt;
You should now see the new u-boot running.  However I was unable to get the 2.6.32 kernel to boot.&lt;br /&gt;
&lt;br /&gt;
== Compile via make ==&lt;br /&gt;
&lt;br /&gt;
When you use bitbake it sets up all the paths to use the correct cross compilers.  You can also build the kernel or u-boot by using '''make''' if you set the paths like we did above.  &lt;br /&gt;
&lt;br /&gt;
If you haven't already, ''source'' the file and ''cd'' to the kernel directory and try a ''make''.&lt;br /&gt;
&lt;br /&gt;
 host$ '''source ~/.oe/crossCompileEnv.sh'''&lt;br /&gt;
 host$ '''cd ~/BeagleBoard/oe/build/tmp-angstrom_2010_x-eglibc/work/beagleboard-angstrom-linux-gnueabi/linux-omap-psp-2.6.32-r110b+gitr5fc29e7b2a76a64a739f857858ef0b98294aa155/git'''&lt;br /&gt;
 host$ '''make xconfig'''&lt;br /&gt;
&lt;br /&gt;
([[EBC Exercise 13 Configuring the Kernel]] has details on configuring the kernel.)&lt;br /&gt;
&lt;br /&gt;
To make the kernel run&lt;br /&gt;
&lt;br /&gt;
 host$ '''make uImage'''&lt;br /&gt;
&lt;br /&gt;
Now, follow the instructions above to install your freshly compiled kernel.&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Project_Ideas</id>
		<title>ECE497 Project Ideas</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Project_Ideas"/>
				<updated>2011-12-06T22:01:09Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: /* Mini Project Ideas */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:BeagleBoard]]&lt;br /&gt;
&lt;br /&gt;
We have both mini projects and projects in ECE497.  &lt;br /&gt;
&lt;br /&gt;
'''Mini projects''' involved finding something interested in the Beagle world and installing it to your beagle and demoing it to the class.  You would also create a wiki page documenting what you did to get it installed.  Often you may find multiple efforts do to something, for example there are a few efforts to port Android on the Beagle.  Your task is to figure out which one should be used.  Generally mini projects won't require you to write new code; however they are the background work that may lead to a full project.  You should do a couple mini projects for the class.  Generally they are done alone, but working in pairs is OK. These will be about 1/3 of your grade and should be done in the first 5 weeks or so.&lt;br /&gt;
&lt;br /&gt;
Only one '''full project''' is done for the class and it's done with a team of 3 or 4.  These projects can take a mini project (or a whole new idea) and add to it.  The goal is to have your work contribute to the open source world. Any code is generated will be kept on [https://github.com/ github] and a [http://bitbake.berlios.de/manual/ bitbake receipt] will be created to automatically download and create the object files.&lt;br /&gt;
&lt;br /&gt;
What follows are&lt;br /&gt;
&lt;br /&gt;
; Places to look for project ideas: Feel free to add your own suggestions.&lt;br /&gt;
; Mini Project ideas: Add your own suggestions, and do some of them.  Mark the ones you've done.&lt;br /&gt;
; Full Project ideas: ditto.&lt;br /&gt;
&lt;br /&gt;
== Sources for Project Ideas ==&lt;br /&gt;
&lt;br /&gt;
Here are some links where you'll find ideas for your project.&lt;br /&gt;
* [http://wiki.omap.com/index.php/ETechDays_Community_Lightning_Talks ETechDays Community Lightning Talks], this is a one-day web-based conference where many project ideas are presented.  One of our 2009-2010 senior design projects was found here.&lt;br /&gt;
* [http://beagleboard.org/project Official list of Beagle Projects], there are many Beagle specific projects listed here.  Many are inactive.  ''List your project here once it running.''&lt;br /&gt;
* [http://www.youtube.com/watch?v=Mk1xjbA-ISE Augmented Reality Project], here's an idea that I think we can do on the Beagle.  Rather than using augmented reality glasses, I'd suggest we use a [http://focus.ti.com/dlpdmd/docs/dlpdiscovery.tsp?sectionId=60&amp;amp;tabId=2235 TI DLP pico projector]. [http://www.hitlabnz.org/wiki/EmbeddedAR Here's] AR running on the Beagle. &lt;br /&gt;
* [http://code.google.com/p/0xdroid/ Android], this is one of a couple of efforts to port [http://source.android.com/ Google's Android OS] to the Beagle.&lt;br /&gt;
* [[BeagleBoard/Ideas-2009]] Google summer code ideas 2009.&lt;br /&gt;
&lt;br /&gt;
== Mini Project Ideas ==&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Suggestor&lt;br /&gt;
! Implementor&lt;br /&gt;
! Description&lt;br /&gt;
! Link&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Work up an example of controlling the PWM registers from the shell.&lt;br /&gt;
| [http://esdw.wordpress.com/2010/03/25/a-useful-tool-devmem2/ PWM via the shell]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Weather Station&lt;br /&gt;
| [http://dominion.thruhere.net/koen/cms/using-the-beaglebone-as-a-weatherstation Ultrasonic weather]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Interface the BeagleBoard with an SRF08 Ultrasonic Ranger over I2C&lt;br /&gt;
| [http://yetanotherhackersblog.wordpress.com/2011/04/07/interfacing-the-beagleboard-with-an-srf08-ultrasonic-ranger-over-i2c Ultrasonic Ranger]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Compile the PowerVR examples&lt;br /&gt;
| [http://www.imgtec.com/powervr/insider/sdkdownloads/index.asp PowerVR Insider SDK Downloads]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Work up some GStreamer PS EYE Demos&lt;br /&gt;
| [http://www.electronsonradio.com/2011/06/playstation-eye-gstreamer-examples GStreamer PS EYE Demos] and [http://www.ridgerun.com/blog/?p=224 RidgeRun]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| Douglas Selby&lt;br /&gt;
| Get TI' embedded speech recognizer installed and demo the examples.&lt;br /&gt;
| [https://gforge.ti.com/gf/project/tiesr TI Embedded Speech Recognizer]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Demo last year's TI speech project.  I have a microphone amplifier and mike you can use.&lt;br /&gt;
| [[ECE597 Project pyWikiReader]]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| Stephen Mayhew&lt;br /&gt;
| Find who is doing what with Kinect on the Beagle and install and run it.&lt;br /&gt;
| [http://www.google.com/webhp?rlz=1C1GPCK_enUS392US392&amp;amp;sourceid=chrome-instant&amp;amp;ie=UTF-8&amp;amp;ion=1#hl=en&amp;amp;sugexp=ldymls&amp;amp;xhr=t&amp;amp;q=beagleboard+kinect&amp;amp;cp=0&amp;amp;qe=YmVhZ2xlYm9hcmQga2lu&amp;amp;qesig=9qrD0rFfjWfujRRGmkB_Bw&amp;amp;pkc=AFgZ2tn-cylx0f71PasgBKOazjBQY3VK712RWQ7DueEjQNAdbOHr6BCgUd9xdyXyPe8TWErkesrQ246vygwImnAS5mIzCG2-5g&amp;amp;pf=p&amp;amp;sclient=psy&amp;amp;rlz=1C1GPCK_enUS392US392&amp;amp;site=webhp&amp;amp;source=hp&amp;amp;aq=0&amp;amp;aqi=&amp;amp;aql=&amp;amp;oq=beagleboard+kin&amp;amp;pbx=1&amp;amp;bav=on.2,or.&amp;amp;fp=3e817b7ec5d13467&amp;amp;ion=1 Google - beagleboard kinect]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| I have several [http://en.wikipedia.org/wiki/PlayStation_Eye Sony PlayStation Eye web cams] and I have examples of how to pull video from them via V4L2 ([[ECE497 DaVinci Workshop Labs]]).  The Eye also has a 4 microphone array.  I don't know how to get audio from it.  Figure out how.  This may expand to a full project if there is no solution out there.&lt;br /&gt;
| [http://www.google.com/webhp?rlz=1C1GPCK_enUS392US392&amp;amp;sourceid=chrome-instant&amp;amp;ie=UTF-8&amp;amp;ion=1#hl=en&amp;amp;sugexp=ldymls&amp;amp;xhr=t&amp;amp;q=beagleboard+playstation+eye+microphone+array&amp;amp;cp=0&amp;amp;qe=YmVhZ2xlYm9hcmQgcGxheXN0YXRpb24gZXllIG1pY3JvcGhvbmUgYXJyYXk&amp;amp;qesig=Sdh5Ru_jodwYydoeTls1GA&amp;amp;pkc=AFgZ2tmwB41tQwF7XwrJPqFnf0NRO911bMCrbnU1HR9Vm6-Pg0sH8LvbJZsKwjKRUpoin4cZlwLIngZw8OC7dyanjcJCG4N_kg&amp;amp;pf=p&amp;amp;sclient=psy&amp;amp;rlz=1C1GPCK_enUS392US392&amp;amp;site=webhp&amp;amp;aq=f&amp;amp;aqi=&amp;amp;aql=&amp;amp;oq=beagleboard+playstation+eye+microphone+array&amp;amp;pbx=1&amp;amp;bav=on.2,or.&amp;amp;fp=3e817b7ec5d13467&amp;amp;ion=1 Google - beagleboard playstation eye microphone array]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Find some examples of how to use '''cmem'''. CMEM is an API and library for managing one or more blocks of physically contiguous memory. It also provides address translation services (e.g. virtual to physical translation) and user-mode cache management APIs. It's used for managing the shared memory between the ARM and the DSP on the processor.  I've been unable to find examples of how to use it.&lt;br /&gt;
| [http://processors.wiki.ti.com/index.php/CMEM_Overview CMEM Overview]&lt;br /&gt;
|-&lt;br /&gt;
| Mike Lester&lt;br /&gt;
| &lt;br /&gt;
| Connect to your beagleboard using ethernet over USB. This allows your beagleboard to share the host computer's internet connection and allow you to connect via VNC/ssh without the need for an external router/switch. This should make development much easier. &lt;br /&gt;
| [[BeagleBoardBeginners#Connect_with_your_beagleboard_using_VNC_and_ethernet_over_USB | VNC]]&lt;br /&gt;
|-&lt;br /&gt;
| Brian Hulette&lt;br /&gt;
| &lt;br /&gt;
| Experiment with audio synthesis and/or sampling/processing.  You could either synthesize and play a few tones to generate a song, or have the Beagle sample an audio signal then process and output it to create a sort of effects pedal. &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| David McGinnis&lt;br /&gt;
| David McGinnis&lt;br /&gt;
| Look into connecting the beagleboard to a phone or headphones using bluetooth. This could involve either outputting audio and taking in audio from a bluetooth headset, allowing you to have audio I/O with the beagleboard, or could involve connecting with phones automatically as they come into range of the beagleboard, allowing for an automatic attendence registration system, among other things.&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| David Bliss&lt;br /&gt;
| David Bliss&lt;br /&gt;
| Get a video stream from a PS Eye, and identify the relevant device files.&lt;br /&gt;
| [http://en.wikipedia.org/wiki/PlayStation_Eye#cite_note-Linux_support-32 PlayStation_Eye#cite_note-Linux_support-32]&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| William Gerth&lt;br /&gt;
| William Gerth&lt;br /&gt;
| Explore the possibility of implementing OpenAOS on the Beagle, to make a portable media player and etc.&lt;br /&gt;
| http://www.openaos.org/&lt;br /&gt;
|-&lt;br /&gt;
| Joel Carlson&lt;br /&gt;
|&lt;br /&gt;
| Lacking a serial port and don't have a USB-serial converter?  Why not find a way to make the BeagleBoard boot over a USB console connection?&lt;br /&gt;
| [http://itgen.blogspot.com/2011/03/beagleboard-xm-u-boot-without-serial.html BeagleBoard XM U-boot without Serial]&lt;br /&gt;
|-&lt;br /&gt;
| Joel Carlson&lt;br /&gt;
| Joel Carlson&lt;br /&gt;
| Depending on what one is working on, it might be useful to mount the BeagleBoard root filesystem over NFS.  The link to the right does that using a USB-Ethernet connection, but one that just runs over an Ethernet cable would be nice.&lt;br /&gt;
| [http://elinux.org/Mount_BeagleBoard_Root_Filesystem_over_NFS_via_USB Mount BeagleBoard Root Filesystem over NFS via USB]&lt;br /&gt;
Here's an example of mounting dfs/afs on the Beagle&lt;br /&gt;
&lt;br /&gt;
[[ECE497 Mounting dfs/afs in Linux]]&lt;br /&gt;
|-&lt;br /&gt;
| Lei Liu&lt;br /&gt;
| Lei Liu&lt;br /&gt;
| Build communication with FPGA via USB port.&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Aaron Bamberger&lt;br /&gt;
| Aaron Bamberger&lt;br /&gt;
| Play around with the BeagleBoard's various SPI and I2C ports, and get it to talk to some simple SPI and I2C peripherals, such as a 7-Segment display driver or small LCD panel&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Jay Dial&lt;br /&gt;
| Jay Dial&lt;br /&gt;
| Look into the parallel computing possibilities of the BeagleBoard. See how difficult it would be to get two BeagleBoards to communicate properly for parallel computing.&lt;br /&gt;
| [http://antipastohw.blogspot.com/2010/09/how-to-make-beagleboard-elastic-r.html How to make a BeagleBoard Elastic R Beowulf Cluster]&lt;br /&gt;
|-&lt;br /&gt;
| Randy Billingsley&lt;br /&gt;
| Randy Billingsley&lt;br /&gt;
| Configure wlan on the beagle board using a wireless usb adapter&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Mike Fuson&lt;br /&gt;
| Mike Fuson&lt;br /&gt;
| Get XBMC working on the beagle.&lt;br /&gt;
| [http://elinux.org/BeagleBoard/GSoC/2010_Projects/XBMC XBMC wiki page]&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Sam Allen&lt;br /&gt;
|&lt;br /&gt;
| Port Android to beagle&lt;br /&gt;
| It's done.  Check out [http://code.google.com/p/rowboat/ this].&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Change the splash screen to a Rose logo when the Beagle starts up&lt;br /&gt;
| [http://blog.bizmobiletech.com/?p=253&amp;amp;utm_source=feedburner&amp;amp;utm_medium=twitter&amp;amp;utm_campaign=Feed%3A+BeagleBoard+%28BeagleBoard.org%29 How to Change Angstrom Boot logo in beagleboard]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| Ziyi Zhang&lt;br /&gt;
| Do remote debugging with Eclipse.  My page needs updating.&lt;br /&gt;
| [[ECE497 Installing the Eclipse IDE]]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
|&lt;br /&gt;
| Investigate Eigen. Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms. Explicit vectorization is performed for SSE 2/3/4, ARM NEON, and AltiVec instruction sets, with graceful fallback to non-vectorized code. This means it should run fast on the Beagle.  How fast does it run?  Has anyone used it on the Beagle?&lt;br /&gt;
| [http://eigen.tuxfamily.org/index.php?title=Main_Page eigen.tuxfamily.org]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Find what libraries are available for the DSP side of the DM 3730 and write some examples that use them.&lt;br /&gt;
| [http://focus.ti.com/docs/toolsw/folders/print/sprc265.html C64x+ DSP Library (DSPLIB)] &lt;br /&gt;
[http://focus.ti.com/docs/toolsw/folders/print/sprc092.html DSPLIB] &lt;br /&gt;
[http://focus.ti.com/docs/toolsw/folders/print/sprc094.html IMGLIB]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Convert the OSS labs to use the new ALSA drivers&lt;br /&gt;
| [http://www.alsa-project.org/main/index.php/Tutorials_and_Presentations ALSA Tutorials]&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| &lt;br /&gt;
| Dig into the DSS drivers.  The OMAP display subsystem supports rotation and mirroring, but the '''mirror''' and '''rotate''' files in '''/sys/devices/platform/omapdss/display''' ''X'' don't work.  Find the code that implements them see if you can figure out what's wrong.&lt;br /&gt;
| [http://elinux.org/BeagleBoardFAQ#.22DSS2.22_display_driver_for_.3E.3D_2.6.29 dss2]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Full Projects ==&lt;br /&gt;
&lt;br /&gt;
=== Winter 2011-2012 ===&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Team&amp;amp;nbsp;Members&lt;br /&gt;
! Project Title&lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| [http://e2e.ti.com/blogs_/b/dlp_mems_blog/archive/2011/05/13/3d-structured-light-using-dlp-technology.aspx 3D Structured Light using DLP® Technology]&lt;br /&gt;
| Create 3D maps using a DLP pico and the Beagle.&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| [http://m.matrixsynth.com/2011/06/beagleboard-synth-proof-of-concept.htm Beagle Midi]&lt;br /&gt;
| Make the Beagle synthesize midi files.&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| [http://www.sakoman.com/OMAP/an-overiew-of-omap3-power-management-with-2639-pm.html Beagle Power Management]&lt;br /&gt;
| Work up some power management demos.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 2011 ===&lt;br /&gt;
Edit this page to add projects you would like to do.  If you aren't in the class, add ideas you would like to see done by class members.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Team&amp;amp;nbsp;Members&lt;br /&gt;
! Project Title&lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| [https://gforge.ti.com/gf/project/tiesr TI Embedded Speech Recognizer]&lt;br /&gt;
| Port TI's fixed-point speech recognizer to the DSP.  It currently runs on the ARM.&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| Kinect&lt;br /&gt;
| [http://hackaday.com/2010/11/15/rendering-a-3d-environment-from-kinect-video/ Here] and [http://gamerfront.net/2010/12/with-a-second-kinect-you-can-map-out-your-bedroom-in-3d/4644 here] are some interesting things people are doing with Kinects.  Maybe we could port it to the Beagle.&lt;br /&gt;
|-&lt;br /&gt;
| Mike Lester&lt;br /&gt;
| Accelerometer-based auto-leveled projection&lt;br /&gt;
| Several projects have been started to add [http://matthsu-abacus.blogspot.com/2009/11/build-3-axis-accelerometer-on.html  accelerometer support] to the BeagleBoard. This project would involve getting an accelerometer installed and working, perhaps using a [http://elinux.org/BeagleBoard_Trainer trainer board], as well the [http://focus.ti.com/general/docs/gencontent.tsp?contentId=52770 TI Pico Projector]. The orientation data from the accelerometer would be used to rotate, skew, keystone the projected image in order to keep it level and normalized.&lt;br /&gt;
|-&lt;br /&gt;
| Aaron Bamberger&lt;br /&gt;
| Kinect Based 3d Scanner&lt;br /&gt;
| Build some sort of motorized gantry that allows the Kinect to be rotated around (and possibly from top to bottom) of an arbitrary object.  The motors would be controlled using the BeagleBoard's I2C or SPI interfaces.  Use libfreenect to capture depth information from every side of the object as the Kinect rotates around the object.  Use this data and OpenGL to build a 3d model of the scanned object&lt;br /&gt;
|-&lt;br /&gt;
| Mark A. Yoder&lt;br /&gt;
| Port winDSK6 to the Beagle&lt;br /&gt;
| [http://www.ece.wisc.edu/~morrow/software/ winDSK6] is a Windows program that talks to a TI 'C6711 DSK and performs many interesting audio effects.  This project would implement the code running on the Windows side on the ARM.  The ARM could capture a frame of audio and send it to the DSP for processing.  The ARM could then send the processed audio to the speakers.  [http://processors.wiki.ti.com/index.php/C6Run c6run] would be used to interact with the DSP.  &lt;br /&gt;
|-&lt;br /&gt;
| David Bliss&lt;br /&gt;
| Automated Die Tester&lt;br /&gt;
| Make a device that can roll a die, and keep statistics on how random the die is. The build can either be very complex, or very simple, depending on how you define &amp;quot;rolling a die&amp;quot;. The software doesn't necessarily have to know what the numbers mean, it just has to be able to uniquely identify the sides.&lt;br /&gt;
|-&lt;br /&gt;
| Stephen Mayhew&lt;br /&gt;
| Set-Playing System&lt;br /&gt;
| Set is a relatively simple card game that lends itself nicely to image recognition and computer play. The layout is not very structured, and the game play is pretty simple. This project would incorporate image recognition, projection of possible moves (using the pico projector), and maybe even speech synthesis, and recognition. For example, if someone didn't know how to play Set, then the board could take them through a tutorial, asking questions of the user as it went along (&amp;quot;If I have these 2 cards, what 3rd card would make a set?&amp;quot;). This would make for an interesting demo at conferences. &lt;br /&gt;
|-&lt;br /&gt;
| Michael Fuson  &lt;br /&gt;
Jay Dial&lt;br /&gt;
| Spectrum Analyzer&lt;br /&gt;
|Create a real-time audio Spectrum analyzer on the BeagleBoard. [http://elinux.org/ECE497_Project_Spectrum_Analyzer Project Page]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 2010 ===&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Team&amp;amp;nbsp;Members&lt;br /&gt;
! Project Title&lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
| Yannick Polius&lt;br /&gt;
| [[ECE597 Project pyWikiReader | pyWikiReader]]&lt;br /&gt;
| This project is mostly software, with the hardware element being the use of the dsp. The idea is to tie together three technologies: speech recognition, speech synthesis, and internet access in order to create an interface capable of orating information to the user based on a vocal command. The implementation I have in mind is to use the Pocket Sphinx speech recognition engine to first understand what the user wants through speech, such as &amp;quot;Rose-Hulman&amp;quot;. Once the speech is translated, the software can execute a Wikipedia search to pull said item's page. Most of the important info is contained within the introductory paragraph, so the software will take only that chunk and feed it into the Flite speech synthesis engine. The end result is a simple machine with &amp;quot;mother box&amp;quot; like usability, that is, no interaction besides what is natural to the user (speaking) should be necessary to retrieve the information.&lt;br /&gt;
|-&lt;br /&gt;
| Paul Morrison &amp;lt;br&amp;gt; Steven Stark&lt;br /&gt;
| [[ECE597 3D Chess | 3D Chess with Networking]]&lt;br /&gt;
| This project would simulate a hand-held chess game, and the game would allow two player games using two beagleboards over a network connection.  The graphics would use the beagle's PowerVR SGX for hardware accelerated graphics by using OpenGL.  In addition to 3D graphics and networking, a third portion of the project would be to optimize the boot time because a chess computer should start up quickly.&lt;br /&gt;
|-&lt;br /&gt;
| Tom Most &amp;lt;br&amp;gt; David Baty &amp;lt;br&amp;gt; Mark Jacobson&lt;br /&gt;
| [[ECE597: Sumo Robot|Sumo Robot]]&lt;br /&gt;
| The goal of this project is to create a robot capable of competing in the 3.0 kg weight class of a sumo competition ([http://www.youtube.com/watch?v=V3OR_sHrOJM an example]).  This would have minor hardware and electronics elements, but would focus on communication with sensors using the BeagleBoard and the Linux kernel.  At minimum, this involves sensors to detect the edge of the ring and the opposing robot.  This would likely be implemented using Sharp IR rangefinders, a ultrasonic rangefinders, and ideally a camera.  [http://circ.mtco.com/competitions/2010/rules/sumo Sumo rules].&lt;br /&gt;
|-&lt;br /&gt;
|Brian Embry &amp;lt;br&amp;gt; Jessica Lipscomb &amp;lt;br&amp;gt; Paul Banister&lt;br /&gt;
| [[ECE597 Network based MP3 player]]&lt;br /&gt;
| Network based mp3 player.  The Beagle will be programmed using a custom, protocol for transferring files from a network based server (x86 pc) to a Beagle.  Speakers will be attached to the Beagle, where the file will be played back.  Possible extensions are a LCD for displaying id3 tag information, and buttons for user interaction (next track, previous track, etc.) on the GPIO interface.&lt;br /&gt;
|-&lt;br /&gt;
|[[user:routhcr | Chris Routh]] &amp;lt;br&amp;gt; [[user:collinjc | J. Cody Collins]] &amp;lt;br&amp;gt; [[user:jacksogc | Greg Jackson]] [[user:Xinkeqiong | Keqiong Xin]]&lt;br /&gt;
| [[ECE597: Auto HUD]]&lt;br /&gt;
| Use the beagle board to run image recognition on a camera feed located inside a car, and then signaling to the driver via a pico projector various objects of interest.&lt;br /&gt;
|-&lt;br /&gt;
| Adam Jesionowski&amp;lt;br&amp;gt;Qiang Jiang&lt;br /&gt;
| [[ECE597_Adding_Sense_to_Beagle|Adding Sense to Beagle]] (See [[BeagleBoard/GSoC/Ideas]])&lt;br /&gt;
| Sensory aware applications are becoming more mainstream with the release of the Apple iPhone. This project would combine both HW and SW to add sensory awareness to beagle. First, additional modules such as GPS, 3-axis accelerometers, Gyroscopes, Temperature Sensors, Humidity Sensors, Pressure Sensors, etc, would be added to beagle to compliment the microphone input in order to allow sensing of the real world environment. Then SW APIs would need to be layered on top to allow easy access to the sensory data for use by applications. &lt;br /&gt;
|-&lt;br /&gt;
| Mitch Garvin &amp;lt;br&amp;gt; Matt Luke &amp;lt;br&amp;gt; Elliot Simon &amp;lt;br&amp;gt; Jian Li&lt;br /&gt;
| [[ECE597 Interactive Pong|Interactive Pong]]&lt;br /&gt;
| Run classic pong, projecting the screen and using a camera to track user's hands for input.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/EBC_Exercise_07_Notes_on_Installing_Ubuntu_in_VMware_Player</id>
		<title>EBC Exercise 07 Notes on Installing Ubuntu in VMware Player</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/EBC_Exercise_07_Notes_on_Installing_Ubuntu_in_VMware_Player"/>
				<updated>2011-11-29T01:25:52Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Note: I haven't updated this for 2011.&lt;br /&gt;
&lt;br /&gt;
It's pretty much agreed that if you are going to develop for embedded Linux, you should do it in Linux.  The problem is many have some form of Windows OS installed.  Here are step by step instructions on how to install a virtual machine running Ubuntu Linux on your Windows box.&lt;br /&gt;
&lt;br /&gt;
== Configuring VMware Player ==&lt;br /&gt;
&lt;br /&gt;
First we'll set up the virtual hard drive, then we'll get the virtual machine software.  The hard drive is set up using some third party software.&lt;br /&gt;
#Go to [http://sourceforge.net/projects/vmmanager here] and get '''VMmanager''',&lt;br /&gt;
#install and run it.&lt;br /&gt;
#Select &amp;quot;Creat a new virtual machine&amp;quot;&lt;br /&gt;
#Select Operating System:  Linux&lt;br /&gt;
#Below Select:  Ubuntu Linux&lt;br /&gt;
#Project name:  Ubuntu 9.10&lt;br /&gt;
#Tab RAM:   1024M  (Make this as big as possible, but no more than 1/2 your laptop's RAM)&lt;br /&gt;
#Tab Hard Disk: Unselect &amp;quot;Allocate all disk space now&amp;quot;  We'll make the hard drive bigger in a moment.  This is working around a small bug that requires all the disk space to be present when you create the machine, even if you don't allocate it all at the beginning.&lt;br /&gt;
#Keep Selected &amp;quot;Split into 2GB files&amp;quot;&lt;br /&gt;
#Tab Ethernet:  Ethernet 0, NAT, Ethernet 1 Bridged&lt;br /&gt;
#Tab Adapters: Select USB, COM1 COM2 and Sound Adapter&lt;br /&gt;
#Tab Finish:  Click &amp;quot;Ok&amp;quot; pick a file name.  It should quickly say it is finished.&lt;br /&gt;
#Quit VMmagager&lt;br /&gt;
Here are videos for [http://www.rose-hulman.edu/~yoder/eLinux/videos/Install_VMmanager.swf installing] and [http://www.rose-hulman.edu/~yoder/eLinux/videos/Run_VMmanager.swf running] VMmanager.&lt;br /&gt;
 &lt;br /&gt;
# Restart VMmanager&lt;br /&gt;
# Select &amp;quot;Modify an existing virtual machine&amp;quot;&lt;br /&gt;
# Select the machine you just saved.&lt;br /&gt;
# Tab Hard Drive&lt;br /&gt;
# Select &amp;quot;Unlock&amp;quot;&lt;br /&gt;
# Enter ''40960''&lt;br /&gt;
# Tab Finish, if it says &amp;quot;the size of the hard disk is too large&amp;quot; and indicates the maximum hard disk you can have is 8 GB, go to 'vmmanager.ini' file and change the paramter 'maxHDsize' defined within it. You may change this parameter within the range from 100 MB up to 972800 MB. &lt;br /&gt;
&lt;br /&gt;
# Click &amp;quot;Ok&amp;quot;.  It should quickly say it is finished.&lt;br /&gt;
Here is a video of [http://www.rose-hulman.edu/~yoder/eLinux/videos/Run_VMmanager2.swf running]] VMmanager the second time.&lt;br /&gt;
&lt;br /&gt;
== Installing VMware Player ==&lt;br /&gt;
&lt;br /&gt;
Now we can get the VMware player and install it.&lt;br /&gt;
# Get the  [http://www.vmware.com/download/player/download.html VMware player]. I got version 2.5.3 for Windows 32-bit and 64-bit (.exe).&lt;br /&gt;
# Install it&lt;br /&gt;
&lt;br /&gt;
== Getting Ubuntu and installing it ==&lt;br /&gt;
&lt;br /&gt;
Note:  At the time I'm editing these I can't get to either the lug site or the csse ftp site.&lt;br /&gt;
--may&lt;br /&gt;
&lt;br /&gt;
==== Manually Installing with ISO ====&lt;br /&gt;
Next get the Ubunutu image and install it in the machine.  I'm using 10.4 LTS since it's required by some of the TI tools.&lt;br /&gt;
&lt;br /&gt;
#You can get the Ubuntu iso image [http://www.ubuntu.com/ here]; however it's faster for Rose students to get a copy locally from [http://lug.rose-hulman.edu/mirror/ubuntu-releases/ lug] or [ftp://ftp.csse.rose-hulman.edu/ubuntu-releases/ csse].  If you aren't sure which iso to get, look for '''ubuntu-9.10-desktop-i386.iso'''.&lt;br /&gt;
#Click on the vm you created above (*.vmx). The VMware Player should start.&lt;br /&gt;
#Click on the CD icon on the bottom right.&lt;br /&gt;
#Select Disconnect.&lt;br /&gt;
#Click on the CD icon again and select &amp;quot;Connect to disk image file (iso):&amp;quot;&lt;br /&gt;
#Select the Ubuntu '''iso''' file you downloaded.&lt;br /&gt;
#On the top left the window select the menu '''VMware Player:Troubleshoot:Reset'''. The VMware Player should find the iso image and start the Unbuntu install.&lt;br /&gt;
#Select: Load Ubuntu&lt;br /&gt;
[http://www.rose-hulman.edu/~yoder/eLinux/videos/Install_Ubuntu.swf Here]is a 3 minute demo.&lt;br /&gt;
&lt;br /&gt;
Hint 1:  You may have to hit ctrl-G to get the VM to listen to your keyboard.&lt;br /&gt;
&lt;br /&gt;
Hint 2:  It won't see your mouse at first, so use the keyboard.&lt;br /&gt;
&lt;br /&gt;
Hint 3:  Ctrl-Alt will release the mouse for outside the VM.&lt;br /&gt;
&lt;br /&gt;
#Answer questions for your location.&lt;br /&gt;
#Select &amp;quot;Erase and use the entire disk&amp;quot;&lt;br /&gt;
#Answer the rest of the questions.&lt;br /&gt;
#Select install and wait a while.  My install took about half an hour.&lt;br /&gt;
#Restart the system when asked to.  You may be asked about ejecting the CD-ROM.  I clicked '''No'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#Once Ubuntu is running you can right-click on the CD-ROM image and unmount it.&lt;br /&gt;
#Go to the CD-ROM icon on the bottom right and disconnect from the iso image.&lt;br /&gt;
#The Update Manager may appear.  Go ahead and have it update everything. It took 15 minutes on my system.&lt;br /&gt;
&lt;br /&gt;
==== Downloading VMWare Appliance ====&lt;br /&gt;
{{caution}} If you have downloaded the Ubuntu disk and installed it, these directions do not apply to you.&lt;br /&gt;
&lt;br /&gt;
VMPlanet provides premade virtual hard disks that can simply be imported into vmware player.  This will simply save the install, but probably will use more internet bandwidth then downloading and installing the iso.&lt;br /&gt;
&lt;br /&gt;
See [http://vmplanet.net/node/106 VMPlanet Ubuntu 9.10]&lt;br /&gt;
&lt;br /&gt;
== Installing VMWare Tools ==&lt;br /&gt;
Now that you have your Ubuntu image loaded and updated, it is important to install VMWare Tools.  This will allow for much more natural mouse synchronization, speed improvements, and copy/paste support between host and guest OS's.&lt;br /&gt;
&lt;br /&gt;
*If you are running the VMWare Appliance, this may not be necessary.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu wiki has by far the best directions on how to do this&lt;br /&gt;
[https://help.ubuntu.com/community/VMware/Tools Ubuntu VMWare Tools]&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_Editing_a_Wiki</id>
		<title>ECE497 Editing a Wiki</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_Editing_a_Wiki"/>
				<updated>2011-11-24T18:28:04Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Here is a wiki you can practice editing.  Before you can edit it you will have to create an login.  Pick something that will make it easy for me to identify you as part of my class.  Then just add your name and date on the end of the table.&lt;br /&gt;
&lt;br /&gt;
You can get help here: [[Help:Contents]].&lt;br /&gt;
&lt;br /&gt;
If you need help with syntax check out the [[Editing Quickstart Guide|eLinux guide]] or the [http://en.wikipedia.org/wiki/Wikipedia:Cheatsheet Wikipedia Cheetsheet].&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
! Name&lt;br /&gt;
! Date&lt;br /&gt;
|-&lt;br /&gt;
| [[user:Yoder | Mark A. Yoder]]&lt;br /&gt;
| 21-Nov-2011&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| [[user:Yuming | Yuming Cao]]&lt;br /&gt;
| 21-Nov-2011&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| [[user:Yuhasmj | Michael Yuhas]]&lt;br /&gt;
| 21-Nov-2011&lt;br /&gt;
|-&lt;br /&gt;
| [[user:Yifei | Yifei Li]]&lt;br /&gt;
| 22-Nov-2011&lt;br /&gt;
|-&lt;br /&gt;
| [[user:Ziyi Zhang | Ziyi Zhang]]&lt;br /&gt;
| 24-Nov-2011&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</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>2011-11-21T22:07:09Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Please edit this page and add your user name, alphabetically by last name, to this list.&lt;br /&gt;
&lt;br /&gt;
Take a look at what you and others have contributed.&lt;br /&gt;
&lt;br /&gt;
# [[Special:Contributions/YourUserName| YourName]]&lt;br /&gt;
# [[Special:Contributions/Yoder | Mark A. Yoder]]&lt;br /&gt;
# [[Special:Contributions/Yuming | Yuming Cao]]&lt;br /&gt;
# [[Special:Contributions/Ziyi Zhang | Ziyi Zhang]]&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</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>2011-11-21T22:06:41Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
&lt;br /&gt;
Please edit this page and add your user name, alphabetically by last name, to this list.&lt;br /&gt;
&lt;br /&gt;
Take a look at what you and others have contributed.&lt;br /&gt;
&lt;br /&gt;
# [[Special:Contributions/YourUserName| YourName]]&lt;br /&gt;
# [[Special:Contributions/Yoder | Mark A. Yoder]]&lt;br /&gt;
# [[Special:Contributions/Yuming | Yuming Cao]]&lt;br /&gt;
# [[Special:Contributions/Ziyi | Ziyi Zhang]]&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ziyi_Zhang</id>
		<title>User:Ziyi Zhang</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ziyi_Zhang"/>
				<updated>2011-11-21T22:03:49Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ziyi Zhang&lt;br /&gt;
&lt;br /&gt;
Master in Electrical and Computer Engineering&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hi,everyone! &lt;br /&gt;
&lt;br /&gt;
This is Ziyi(Ziggy) Zhang from this course. &lt;br /&gt;
&lt;br /&gt;
Look forward to getting to learn interesting stuff and having fun in this class!&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;
&lt;br /&gt;
[[Category:ECE497]]&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ziyi_Zhang</id>
		<title>User:Ziyi Zhang</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ziyi_Zhang"/>
				<updated>2011-11-21T22:01:19Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ziyi Zhang&lt;br /&gt;
&lt;br /&gt;
Master in Electrical and Computer Engineering&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hi,everyone! &lt;br /&gt;
&lt;br /&gt;
This is Ziyi(Ziggy) Zhang from this course. &lt;br /&gt;
&lt;br /&gt;
Look forward to getting to learn interesting stuff and having fun in this class!&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;
&lt;br /&gt;
&lt;br /&gt;
[[:ECE497]]&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ziyi_Zhang</id>
		<title>User:Ziyi Zhang</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ziyi_Zhang"/>
				<updated>2011-11-21T21:58:42Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ziyi Zhang&lt;br /&gt;
&lt;br /&gt;
Master in Electrical and Computer Engineering&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hi,everyone! &lt;br /&gt;
&lt;br /&gt;
This is Ziyi(Ziggy) Zhang from this course. &lt;br /&gt;
&lt;br /&gt;
Look forward to getting to learn interesting stuff and having fun in this class!&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;
&lt;br /&gt;
&lt;br /&gt;
[[:Category: ECE497]]&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ziyi_Zhang</id>
		<title>User:Ziyi Zhang</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ziyi_Zhang"/>
				<updated>2011-11-21T21:57:56Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ziyi Zhang&lt;br /&gt;
&lt;br /&gt;
Master in Electrical and Computer Engineering&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hi,everyone! &lt;br /&gt;
&lt;br /&gt;
This is Ziyi(Ziggy) Zhang from this course. &lt;br /&gt;
&lt;br /&gt;
Look forward to getting to learn interesting stuff and having fun in this class!&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;
&lt;br /&gt;
&lt;br /&gt;
[[:Category:ECE497]]&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ziyi_Zhang</id>
		<title>User:Ziyi Zhang</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ziyi_Zhang"/>
				<updated>2011-11-21T21:57:09Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ziyi Zhang&lt;br /&gt;
&lt;br /&gt;
Master in Electrical and Computer Engineering&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hi,everyone! &lt;br /&gt;
&lt;br /&gt;
This is Ziyi(Ziggy) Zhang from this course. &lt;br /&gt;
&lt;br /&gt;
Look forward to getting to learn interesting stuff and having fun in this class!&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;
&lt;br /&gt;
&lt;br /&gt;
Category: ECE497&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ziyi_Zhang</id>
		<title>User:Ziyi Zhang</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ziyi_Zhang"/>
				<updated>2011-11-21T21:52:24Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ziyi Zhang&lt;br /&gt;
&lt;br /&gt;
Master in Electrical and Computer Engineering&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hi,everyone! &lt;br /&gt;
&lt;br /&gt;
This is Ziyi(Ziggy) Zhang from this course. &lt;br /&gt;
&lt;br /&gt;
Look forward to getting to learn interesting stuff and having fun in this class!&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ziyi_Zhang</id>
		<title>User:Ziyi Zhang</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ziyi_Zhang"/>
				<updated>2011-11-21T21:50:26Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: Undo revision 76370 by Ziyi Zhang (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ziyi Zhang&lt;br /&gt;
&lt;br /&gt;
Master in Electrical and Computer Engineering&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ziyi_Zhang</id>
		<title>User:Ziyi Zhang</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ziyi_Zhang"/>
				<updated>2011-11-21T21:50:11Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ziyi_Zhang</id>
		<title>User:Ziyi Zhang</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ziyi_Zhang"/>
				<updated>2011-11-21T21:48:43Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ziyi Zhang&lt;br /&gt;
&lt;br /&gt;
Master in Electrical and Computer Engineering&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Ziyi_Zhang</id>
		<title>User:Ziyi Zhang</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Ziyi_Zhang"/>
				<updated>2011-11-21T21:41:40Z</updated>
		
		<summary type="html">&lt;p&gt;Ziyi Zhang: Created page with &amp;quot;Hi,everyone! This is Ziyi(Ziggy) Zhang from this course. Look forward to getting to learn interesting stuff and having fun in this class!&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi,everyone! This is Ziyi(Ziggy) Zhang from this course. Look forward to getting to learn interesting stuff and having fun in this class!&lt;/div&gt;</summary>
		<author><name>Ziyi Zhang</name></author>	</entry>

	</feed>