Friday, June 21, 2013

Software Development on the BeagleBone Black

My original thought was to develop on the BeagleBone Black using Python as I had done on the Raspberry Pi.   Once I started to explore the BBB I was both intrigued and worried by the idea of using Node.Js and JavaScript instead.

Intrigued because I really liked the idea of building an application with the front-end presented via a browser.   Also intrigued because of Node's reputation for performance.   A little worried because I just have not thought of JavaScript as anything more than a client-side scripting language.   Also a little worried because the foundation of Node.js lies in it's asynchronous, non-blocking, architecture.

Once I got started slinging some code I did come to the conclusion that I was right about the good things and was overly worried about the bad.   This said, the async nature of the Node.js model does give me headaches.   Below is a narrative that presents some of the key processing flow for the app that I am developing:


“The App” modules “main” and “form” integrate with the Node.js to provide a web server as described by the example on this page.  This is somewhat different than most development environments where handling of the web interface is more abstracted from the application code!
  1.  “The App” is launched at startup with main running and a “/” is fired from the browser running on the LCD display as console.
  2. “main”  is monitoring the http port and sees the “/”. It invokes form.send to put the main.html form out to the client.
  3. When the user presses the “Start” button main sees it and invokes form.receive to handle the page.  The call to form.receive is made with a callback given that receiving a form is asynchronous.
  4. form.receive does inspects the return from the client to see if the button pressed on the received page is asking for a new page (versus some other action).
  5. In this case the button press indicates that we need to start a test so the appropriate html file is sent to the client using form.send and the callback is completed after populating global.context with the name of the page sent and with the button pressed on the client.
  6. Main then receives that callback, sees that we want to start a test, loads the test module, and calls test.execute.
  7. test.execute starts running and does a setInterval to begin collecting our observations.
  8. setInterval fires as often as it can calling test.observe to do our data collection.
I will freely admit that I have not done the above in the best "Node" manner but I struggled to find some good examples from which to learn.  By good I mean, easy to understand and doing what I wanted to do!   This being to develop a pretty straight forward interactive web based application.

What I have built seems to work well but I am sure that I could have done it better!

No comments:

Post a Comment