Skip to content

BeagleBoard GSoC'18: Fixing Bugs in BoneScript and Improving BeagleBone User Interface

Vaishnav M A edited this page Aug 14, 2018 · 9 revisions

This is a Google Summer of Code 2018 project under BeagleBoard.org Foundation aimed at :

  1. Fixing Bugs in BoneScript reported at beagleboard/bonescript/issues
  2. Improving the Bone101 BeagleBone User Interface

Project Details

Code : BoneScript , BeagleBone-UI (Live Preview)
Mentors : Jason Kridner, Anuj Deshpande, Michael Welling
GSoC Project Page : https://summerofcode.withgoogle.com/dashboard/project/6558422816784384/overview/
Project Final Video : https://youtu.be/94XxXs0rb7E
Project Intro Video : https://www.youtube.com/watch?v=ZKOccMBiL5s

Introduction

BoneScript is an existing Node.js library specifically optimized for the Beagle family of boards and featuring familiar Arduino function calls, exported to the browser.The primary aim of this project is to solve most of the open issues reported and add new features which will improve the user experience. The issues reported at beagleboard/bonescript/issues have been categorized into :

Project Status

Feature Requests Suggestions/Improvements Bugs/Compatibility Issues
#00ff00 C Module Support #00ff00 module.exports instead of exports #00ff00 PWM UDEV delays
#00ff00 Interchanging Analog/Digital Functions #7f8287 Explicit Sync/Async Functions #00ff00 Spikes in PWM Output
#f7ff28 HCSR04 Sensor Support #00ff00 Node-Style Callbacks #00ff00 Pin Mux Error
#00ff00 Remote BoneScript Upload #00ff00 Callback Documentation #00ff00 Handle debugfs not mounted
#f7ff28 Support for Snappy Ubuntu Core #7f8287 Use npm module forever to autoload #7f8287 SerialParsers Issue
#00ff00 Smooth PWM Output #7f8287 I2C Functions #00ff00 AnalogWrite Error
#00ff00 BeagleBlue Servo, IMU, BMP Support #00ff00 TypeScript Definitions #7f8287 Unable to unload conflicting slot
#7f8287 Blank EEPROM before writing #7f8287 Inverted PWM Polarity
#7f8287 Stepper Motors #7f8287 Failed to find devicetree fragment bspwm
#00ff00 Fixed & Merged #f7ff28 Partially Fixed / Not Merged #7f8287 Not Fixed

BeagleBone User Interface (BBUI) is a browser based interactive User Interface that allows a user to interact with a BeagleBone board with minimal to no coding experience, the BBUI features a drag and drop interface that allows a user to communicate to the board and use the ADC pins, digital (Inputs, Outputs, PWMs) pins, and the user LEDs on the board, the BBUI development was started from Jason Kridner's BBUI rewrite and from this GSoC '16 Project.

BeagleBone User Interface

Trying Out the Project

BoneScript

To try out the changes included in latest BoneScript beta release(only a subset of changes), perform :

    sudo npm install --unsafe-perm -g bonescript@beta

To try out the entire set of changes made, perform :

    sudo npm install --unsafe-perm -g vaishnav98/bonescript#gsoc18

BeagleBone-UI

To try out the live demo , head over to BeagleBone UI

To Serve the Project locally,

     git clone https://github.com/vaishnav98/bone101
     cd bone101
     jekyll serve

Navigate to the BeagleBone-UI from the bone101 landing page

Fixing Bugs in BoneScript

BoneScript library even though being widely used by BeagleBone users has some bugs and unfinished features.The primary aim of this project was to solve most of the open issues reported and add more features which will improve the User Experience.The approach followed for solving the issues are briefly described under the following topics(title for each issue links to the corresponding issue reported & the solution links to the corresponding merged pull request/commit).

Feature Requests

These are issues that deal with requests to add some additional features to BoneScript which improves the usability of the library. These issues come under this category :-

  • Add C Module Support - This issue relates with adding support for C Modules that are compiled on the target without writing separate bindings for each function.
    Solution - External C module support was achieved in BoneScript using ffi library , the documentation for the newly exposed functions and some examples are available here (also see here)
  • Interchanging Analog and Digital Functions - This issue relates to adding features that make the user possible to use digital write/read functions on PWM/Analog pins and similarly analog read/write on digital pins.
    Solution (also #162) - The solution was implemented as described in the issue itself:
digitalRead on AIN: if value > 0.5 then return HIGH, otherwise return LOW
analogRead on DIN: return 0 or 1 depending on digital state
digitalWrite on PWM: set duty cycle to 0 or 1
analogWrite on DOUT: if value > 0.5 then set to HIGH, otherwise set to LOW
  • HCSR04 UltraSound Sensor Support - This issue deals with adding support for HCSR04 UltraSound Sensor in BoneScript.
    Solution - The issue was not completely solved as a working PRU firmware for acquiring HCSR04 sensor readings could not be found, however a general PRU firmware Loading support for BoneScript was added, the documentation for the newly exposed functions and examples are available here.

  • Remote BoneScript Upload - This issue deals with adding support for remotely uploading BoneScript code to the board in a secure manner.
    Solution - The Remote Script upload solution was implemented making use of the already existing BoneScript RPC Server, also a socket.io middleware based hash challenge authentication was implemented for a secure solution.The secure server can be started by creating a configuration file at the path /etc/default/bonescript with the following contents :

{
 "hash": true,
 "passphrase":"9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05"(replace with your password hash SHA256),
 "port": 8000 ,
 "directory": "/usr/share/bone101"
 }
(or)
{
 "hash": false,
 "passphrase":"testpassword"(replace with your password),
 "port": 8000 ,
 "directory": "/usr/share/bone101"
 }

An example for making remote BoneScript calls and starting the secure server is demonstrated here

  • Support for Snappy Ubuntu Core - This issue relates to providing steps for installing BoneScript on Snappy Ubuntu Core and providing instructions for creating BoneScript projects as Snap Packages.
    Solution - Steps for installing BoneScript and creating BoneScript Snaps on Snappy Ubuntu core were provided and tested on these images for the BeagleBone ( Ubuntu Core 16 , Ubuntu 18.04 ROS Image )

  • Smooth PWM Output - This issue relates to fixing the slight disturbances in PWM output(sudden zero duty cycle writes) that occurs while sweeping PWM frequencies.
    Solution - The disturbances in PWM Output was fixed and a demonstration video for the PWM output before and after the changes is available here

  • BeagleBone Blue Servo, IMU, BMP Support - This issue relates to adding support for using BeagleBone Blue I/O through BoneScript.
    Solution - Support for BeagleBone Blue Servos, IMU and BMP was implemented in BoneScript after fixing the build issues and adding the additional bindings to node-roboticscape . A video demonstrating the new features is available here

Suggestions/Improvements

These are issues that deal with suggestion/improvements tp the library. These issues come under this category :-

  • module.exports instead of exports - This issue deals with replacing the use of exports alias in BoneScript with module.exports
    Solution - Replaced the use of exports with module.exports as suggested in the issue.

  • Node-style Callbacks - This issue deals with supporting Node-Style Error first callbacks in BoneScript instead of the old style single object callbacks.
    Solution - Added support for Node-Style error first callbacks and also retained backward compatibility for old-style callbacks by choosing the callback type based on callback.length property.

  • Callback Documentation - This issue deals with standardizing the BoneScript callback functions and adding proper documentation for the callbacks.
    Solution - After adding the support for Node-Style Callbacks, the bone101 BoneScript Documentation was modified to include a detailed documentation of the supported new style callbacks.

  • TypeScript Definition - This issue deals with adding TypeScript definitions for BoneScript methods.
    Solution - Starting from the TypeScript definitions written by the issue reporter, some modifications were made and the definitions were bundled with BoneScript.

Bugs/Compatibility Issues

  • PWM UDEV delays - This issue deals with PWM failing in User mode due to delay in setting up permissions by Udev .
    Solution - Using async.js methods the corresponding file with permission issue was accessed continously until no EACCES error was thrown, the solution works well after an average of five repeated access on the file.

  • Spikes in PWM Output - This issue deals with the occurrence of random spikes in PWM output when writing zero duty cycle PWM to a pin.
    Solution - when writing zero duty/frequency PWM to a pin, the output of the pin was disabled so as to suppress any occurrence of spikes in output.The spikes in PWM Output was fixed and a demonstration video for the PWM output before and after the changes is available here

  • PinMux Errors - This issue deals with some errors in PinMux defintions of a pin(P8_40) in BoneScript.
    Solution - The errors in the pinmux defintions for the pin was corrected after cross-checking with the AM3358 Manual.

  • Handle case when debugfs not mounted - This issue deals with getPinMode() failing to fetch mux details when debugfs is not mounted.
    Solution - The issue was fixed by executing the corresponding mount command on getPinMode() call, if debugfs was not already mounted.

  • Analogwrite Error - This issue partially relates to analogWrite() failling due to Udev delays issue and was fixed when the Udev issue was fixed.

Improving BeagleBone User Interface

BeagleBone User Interface is a browser based interactive interface that helps users to interact with a BeagleBone with minimal to no coding experience.The BBUI features a drag and drop interface that helps the user to play with the ADC pins, digital (inputs, outputs, pwms) pins, and the user LEDs on the board, it also features a Graph drawing interface that plots the live status of the pins.Currently the BeagleBone UI Supports BeagleBone Black, BeagleBone Blue, PocketBeagle, BeagleBone Green and PocketBeagle with BaconBits Cape.A demonstration video of the BeagleBone User Interface is available here

bbui
See BBUI Code Documentation here

PocketBeagle Support

The BeagleBone User Interface currently supports the ADC pins, digital (inputs, outputs, pwms) pins, and the user LEDs on the PocketBeagle board: pbui

BaconBits Support

The BeagleBone User Interface currently supports the RGB LED and Thumbwheel(other than the above listed PocketBeagle Support) on a PocketBeagle board with Baconbits Cape: bacon

BeagleBone Blue Support

The BeagleBone User Interface currently supports the user LEDs, Servos, Motors on the BeagleBone Blue board: blue

Conclusion

I would like to thank all the Mentors and Org Admins under BeagleBoard.org Foundation, specially Jason Kridner for the continued support and guidance to improve the project.This project has been a wonderful learning experience for me, some of the goals of the project has not been achieved completely and i hope to contribute to achieve those goals and also work on the main stretch goal of the project (improving Blockly BoneScript) after GSoC.Also would like to thank Google for putting up such a wonderful opportunity for students.

Additional Details