When you browse a website, you are requesting the contents of the web page from or use the calculating capabilities of a server somewhere. That server is almost always a Linux machine and server-side scripts like PHP, Python and Node.Js are used to “talk” to these servers.
The Beaglebone Black also acts as a “local” server with an IP address of 192.168.7.2. We can also use PHP, Python, etc to communicate with it and use its features. In this tutorial, we will be using Node.Js as a server-side script, particularly a library called “Bonescript”.
The Cloud9 IDE
The Angstrom distribution includes several examples which can be viewed on the "demo" folder. On the "Project Files" window, open the demo folder and choose blinkled.js. This is a script that blinks the USR3 LED and any LED connected to P8_13. Click the "run" button to execute this code. You can also click on the arrow button to choose the active file (if you have multiple files open). You can hit the "stop" button anytime, btw.
There is also a folder named "autorun". Scripts in this folder will continuously execute without the use of the "run" button.
If you are familiar with bash, you can also issue bash commands on the terminal on the bottom part.
The Bonescript is a node.js library for embedded Linux created by Jason Kridner. Here's a neat slideshow from beagleboard.org:
- serialOpen(port, options, [callback])
- serialWrite(port, data, [callback])
- i2cOpen(port, address, options, [callback])
- i2cWriteByte(port, byte, [callback])
- i2cReadByte(port, [callback])
- ... and many more
I will cover these functions on my coming tutorials. You can aslo check out the bonescript repository for updates.
Next up, we'll look at that LED blinking code.