Book Image

Programming the BeagleBone

By : Yogesh Chavan, Amit Pandurang Karpe
Book Image

Programming the BeagleBone

By: Yogesh Chavan, Amit Pandurang Karpe

Overview of this book

The whole world is moving from desktop computers to smartphones and embedded systems. We are moving towards utilizing Internet of Things (IoT). An exponential rise in the demand for embedded systems and programming in the last few years is driving programmers to use embedded development boards such as Beaglebone. BeagleBone is an ultra-small, cost-effective computer that comes with a powerful hardware. It runs a full-fledged Debian Linux OS and provides numerous electronics solutions. BeagleBone is open source and comes with an Ethernet port, which allows you to deploy IoT projects without any additions to the board. It provides plenty of GPIO, Anlaog pins, and UART, I2C, SPI pins which makes it the right choice to perform electronics projects. This gives you all the benefits of Linux kernel such as multitasking, multiusers, and extensive device driver support. This allows you to do programming in many languages including high-level languages such as JavaScript and Python. This book aims to exploit the hardware and software capabilities of BeagleBone to create real-life electronics and IoT applications quickly. It is divided into two parts. The first part covers JavaScript programs. The second part provides electronics projects and IoT applications in Python. First, you will learn to use BeagleBone as tool to write useful applications on embedded systems. Starting with the basics needed to set up BeagleBone and the Cloud9 IDE, this book covers interfacing with various electronics components via simple programs. The electronics theory related to these components is then explained in depth before you use them in a program. Finally, the book helps you create some real-life IoT applications.
Table of Contents (21 chapters)
Programming the BeagleBone
Credits
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
BeagleBone Capes
Index

Cloud9 IDE


Cloud9 IDE runs on port number 3000 on BeagleBone. The Setting up BeagleBone section covered many ways to connect to BeagleBone and open Cloud9 IDE. After connecting to BeagleBone and opening Cloud9 via any one of these ways, we are ready to explore BeagleBone's default programming IDE.

Cloud9 is a web-based IDE to develop primarily JavaScript and Node.js applications. It also supports many other programming languages including PHP, Java, Python and Ruby. Cloud9 runs on the web which means it works inside a browser. There is no difference if you are using Windows, Linux or MAC OS on your PC or even from your smartphone. If you are using a supported Firefox or Chrome browser on a remote PC/smartphone, you can run Cloud9 and do programming on BeagleBone. Cloud9 allows many developers to code simultaneously on single project through the web. It supports instant deployment to many well-known cloud platforms like Microsoft Azure, Google App Engine and OpenShift. It is open source software and maintained by a company called Cloud9 IDE, Inc. You can get the source code here: https://github.com/c9/core:

Cloud9 is made up of multiple child windows inside. In the leftmost windows you can select a project related window among Workspace or Navigate or Commands. The Workspace window has a tree view that expands and collapses project files. You can add new, rename and delete project files from this window. At the bottom, there is a console window to display program output, compilation errors, and console.log() messages. When you run any program, you get output printed in this window. You can add a new JavaScript immediate tab in this window. It is useful to evaluate expressions, execute statements and print variables values. You can also add a bash shell in this window tab. You can run commands directly on BeagleBone from here. At the right, there is a place for toolbars. Debugger and Outline toolbars take place in this area. Expand the debugger toolbar when you want to debug a program line by line. The middle empty part is the code editor area. Here actual code gets written. It has very small pane area at the left side. It shows line numbers and breakpoints, errors, and warning signs corresponding to that line. Cloud9 supports multiple tabs to edit many files simultaneously. It provides code completion features for snippets and identifiers. It has rich debugging features like setting breakpoints and step into/step over. It provides dragging and dropping of files from computer to code area. This way, you can add new ready-made code to your project. There are many customization options available with a menu bar at the uppermost side.

We are going to use Cloud9 for all BoneScript programs. There are some ready-made files with code in the demo directory. But they need some hardware setup. So, we will skip them. The best way to get help is to visit the bone101 page or http://beagleboard.org/Support/BoneScript/.