Difference between revisions of "EBC Mini Project 04"

From eLinux.org
Jump to: navigation, search
(Added details on how it works and grading.)
m (Running the code)
Line 18: Line 18:
 
== Running the code ==
 
== Running the code ==
 
Here's how to run the demos
 
Here's how to run the demos
  beagle$ '''cd examples/node.js/realtime'''
+
  beagle$ '''cd exercises/node.js/realtime'''
 
  beagle$ '''git pull'''
 
  beagle$ '''git pull'''
 
  beagle$ '''opkg update'''
 
  beagle$ '''opkg update'''

Revision as of 15:40, 26 October 2012

thumb‎ Embedded Linux Class by Mark A. Yoder


Due: 22-Oct-2012

This mini project is a follow up on the sensor mini project.

Introduction

The goal here is to add a web-based graphical display to your sensor. In exercises/node.js/realtime you will find two examples of node.js servers that display realtime data from the beagle.

buttonBox.js, buttonBox.html
This is a bone-based example that reads a gpio port, analog in and an i2c device and displays the output in a web browser.
realtimeDemo.js, realtimeDemo.html
This is an xM-based example that reads realtime audio and displays it.

Modify one of these to work with your sensor. If you interfaced a display, modify to control your display. I'll leave it open to how you will do it.

Running the code

Here's how to run the demos

beagle$ cd exercises/node.js/realtime
beagle$ git pull
beagle$ opkg update
beagle$ opkg install nodejs  (Don't install node, it's not what you think.)

On the Bone:

beagle$ node buttonBox.js

Then point a browser to bone:8081. The default port is 8081. You can change it if you like.

On the xM;

beagle$ node realtimeDemo.js

Point to xM:8080 and play. You may have to edit the code to use the right audio device. Search for arecord.

i2c

My buttonBox.js uses a very crude approach to i2c. I just call i2cget every time I want a value. There is lots of overhead in running i2cget each time. If you are using an i2c device, modify myi2cget.c (in exercises/i2c) to return the current value from your device every time the user hits return. Use this with your version of buttonBox.js to read your i2c device.

How it works

In my code the browser does a pull at a fixed time interval. That is, the function updateTop() sends the messages ain and gpio to the server and then sets a timer (setTimeout()) to send them again later. When the server receives a message, say ain, it reads the correct I/O and sends the data back via the ain message. When the browser receives the message it stores the value in the correct place in an array and tells the plotting routine to plot it.

Now, read the above paragraph with buttonBox.html (for the browser) and buttonBox.js (for the server) in front of you. Find the functions noted above and see what you can figure out.

Here's the challenge: Modify the code to do a push. That is, have the server set a timer and at a fixed interval send the data over to the browser.

Grading

If your solution uses my 'pull' code you will get at most 7 or 8 out of 10. If you are able to modify the code to do a 'push' you can get full credit.

If you are doing i2c the way I did it, you can get 7 or 8 out of 10, but if you made the change I request above, you can get full credit (without having to do the 'push').

In either case I suggest you get the easy case working first, then do the challenge.




thumb‎ Embedded Linux Class by Mark A. Yoder