GithubHelp home page GithubHelp logo

buu-huu / bbb-gpioctl Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 50 KB

Command-line interface for controlling GPIOs on the BeagleBone Black

License: MIT License

Rust 99.25% Shell 0.75%
beaglebone-black beaglebone gpios command-line interface cli rust

bbb-gpioctl's Introduction

BeagleBone Black GPIO Control

The gpioctl interface provides an easy way to communicate with the BeagleBone Blacks GPIO pins.

In /sys/class/gpio/ you can find folders for GPIOs on the BBB. This program gives an easy command line interface for controling the GPIOs, instead of reading and writing to these files directly.

How it works

Pretty easy: You could just open a GPIO folder, for example /sys/class/gpio/gpio7. In that folder, you find a few files. E.g.:

  • direction
  • value

These files are special files. You can read from them or simply write to some of them to change and read values or directions. GPIOCTL provides an easy command line interface to handle all the (complex) stuff in the background for you. Examples:

  • Check, if the GPIO is available for the desired operations on the BBB
  • Export and unexport the GPIO before accessing it
  • Plausibility checks (e.g. setting a value while the direction is set to "in" makes no sense)

All these features make life easier when working with the GPIOs of the BBB. It's planned, to implement additional helpful modes such as PWM output in GPIOCTL.

Usage

Call the program by typing gpioctl in the console.

$ gpioctl [gpio] [mode] [function] [value]

The argument value only needs to be used when using the function set.

Mode Function Explanation
direction get Returns the current direction of the GPIO (in/out)
set Sets the direction of the GPIO (in/out)
value get Returns the current value of the GPIO (0/1)
set Sets the value of the GPIO (0/1), GPIO direction must be in
label get Returns the label of the GPIO

Requirements

There are no requirements for GPIOCTL on the BeagleBone Black.

Building

Make sure, you install the gcc ARM compiler and linker first:

$ sudo apt install gcc-arm-linux-gnueabihf

You'll also need the corresponding Rust Crate:

$ rustup target add armv7-unknown-linux-musleabihf

Before building the program, export the following variable:

$ export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-gcc

Finally, build the executable:

$ cargo build --release --target armv7-unknown-linux-musleabihf

The executable program is located in target/armv7-unknown-linux-musleabihf/release

Creating Debian Package

To create the Debian Package, install cargo deb and binutils-arm-linux-gnueabi:

$ cargo install cargo-deb
$ sudo apt install binutils-arm-linux-gnueabi

You also need to modify your ~/.cargo/config file. Add the following lines to the file:

[target.armv7-unknown-linux-musleabihf]
strip = { path = "arm-linux-gnueabihf-strip" }

That will point the strip command to the previously installed "stripper" for ARM binaries.

Building the Debian Package is done by the following command by specifying target:

$ cargo deb --target armv7-unknown-linux-musleabihf

The package will be located under target/armv7-unknown-linux-musleabihf/debian.

Installation

Install the Debian Package on the BeagleBone Black with

$ sudo dpkg -i <package-name>

where package-name is the name of the previously built .deb file. Alternatively, you can install a pre-built release from this repository.

GPIOs

List all available GPIOs via

$ gpioctl list

Currently, not all GPIOs are available. In future, we want to provide access to all GPIOs on the BeagleBone Black.

bbb-gpioctl's People

Contributors

buu-huu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

bbb-gpioctl's Issues

Create Silent Mode

Silent Mode, that only outputs error messages. Information messages get suppressed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.