Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Banana Pro Blueprints
Banana Pro Blueprints

Banana Pro Blueprints: Leverage the capability of Banana Pi with exciting real-world projects

Arrow left icon
Profile Icon Ruediger Follmann Profile Icon Tony Zhang
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Full star icon 5 (3 Ratings)
Paperback Dec 2015 366 pages 1st Edition
eBook
$29.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Ruediger Follmann Profile Icon Tony Zhang
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Full star icon 5 (3 Ratings)
Paperback Dec 2015 366 pages 1st Edition
eBook
$29.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$29.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Banana Pro Blueprints

Chapter 2. Programming Languages

This chapter deals with programming languages. A single chapter, of course, cannot replace complete books that are dedicated to certain programming languages. However, when compiling or executing programs from the Internet, basic knowledge of programming languages may help to debug functionality and finally get things working as expected.

In this chapter, some basic principles, such as remote connections and editors, are explained. Afterwards, you will learn something about shell programming. This programming will be required later, for example, within Chapter 5, A Multimedia Center.

Python is a scripting language, which is interpreted on the fly. You will learn the basics of Python and a data visualization example is also provided.

Most program sources from the Internet are C/C++ programs. You will learn the basics of C using the GNU C-compiler, makefiles, and a debugger.

Another section deals with Scratch. Scratch is a graphical programming language...

Basic principles

The first section of this chapter deals with basic principles that are required for programming. A programmer is not always sitting in front of Banana Pro. Remote connections to Banana Pro will allow remote programming. Furthermore, another section in this chapter will describe principal programming tools, such as editors, compilers, or debuggers.

Remote connections

This section explains the first possible remote connections to Banana Pro, such as ssh or remote desktop. These tools allow the development of programs without sitting in front of Banana Pro.

Secure Shell

A Secure Shell (SSH) login allows the remote login to Banana Pro from any other computer. For Windows operating systems, Putty can be used for remote connections (http://www.putty.org). For a Linux operating system, remote connections to Banana Pro can be initiated using this command:

ssh user@ip-address -pport

Replace ip-address with the IP address or hostname of your Banana Pro and port with the port number that...

Shell programming

A Linux shell is a command line interpreter that provides a user interface for a system itself. It can be used to install programs (apt-get install) or even for some programming, including conditions, logic, or loops. Linux provides many different shells. Very often, the Bourne shell is used, which was developed in the 70s by Stephen R. Bourne. This shell provides input and output redirection, pipes, background processes, and much more. For all Linux systems, a Bourne-compatible shell in the /bin/sh directory is available.

Checking the Banana Pro temperature

Let's start our first shell program using these steps:

  1. Edit a file called temperature and place the following content in it:
    #!/bin/sh
    cat /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input
    
  2. Save the file afterwards and make it executable:
    chmod 775 temperature
    
  3. Execute this file by typing this:
    ./temperature
    

My output shows 36200, which is the Banana Pro temperature multiplied by 1,000. The first line of the...

Python

"Python is a programming language that lets you work quickly and integrate systems more effectively."

- Python website (http://www.python.org)

It is true that nearly no other interpreter language is as popular as Python. Additionally, there are a bunch of add-ons for Python that are available, ranging from a simple web server to complex graphics libraries. In this section, the reader will learn some basics of Python. We will use Python in order to program GPIO pins. We will look at a more complex example that will deal with graphical output in a window.

The basics

Before Python can be used, Python itself and the associated developer packages need to be installed:

sudo apt-get install python python-dev

For my examples, I've used 2.7.x version of Python. Python 3.x is not needed in order to execute the examples.

Since Python is an interpreter, there are two possibilities of executing a Hello world! program. The first option is to invoke Python in a terminal by typing python...

C/C++

Most Banana Pro programs found on the Internet are C/C++ programs. The main reasons for this are speed critical applications: interpreters, such as Python, are much slower compared to compiled programs such as C/C++ ones. In this section, we will have a closer look at the Linux C/C++ compiler called GNU Compiler Collection (GCC). GCC includes frontends for both the C and C++ compiler as well as libraries for these languages. We install the C and C++ compiler with the following command:

sudo apt-get install gcc g++ make

Additionally, we install make, a utility that helps the compiling and linking of C/C++ files. We again start with a very simply "Hello world!" example, which we call hello.c:

nano hello.c

We can then add the following content:

#include <stdio.h>

int main(void)
{
    puts("Hello world!");
    return 0;
}

In the preceding example, we include standard input/output headers (stdio.h). The main entry point of the program has no arguments (void) and...

Scratch

Scratch is a programming language for children and teenagers. Graphical boxes have replaced all programming elements within this language. The language itself was invented and developed at MIT. The name is related to a scratching technique from turntables (mixing sounds). Scratch programs are event-driven with objects called sprites. Sprites can be either drawn or imported from external sources such as webcams.

Scratch can be used from a web interface. In addition to this, there is an Integrated Development Environment (IDE) available, which can be installed on Banana Pro using this command:

sudo apt-get install scratch

On many distributions, Scratch is already preinstalled.

Scratch

Figure 13

Typing the scratch command will start Scratch, as shown in the preceding screenshot. The IDE is split into three different parts: the left-hand side column contains all programming elements, the middle area can be used to place the programming elements in order to program functionality, and the right...

New kernels

All Banana Pro operating systems have a kernel installed. Depending on OS functionality, such as multimedia or GPIO usage, different kernels may be used. Usually, kernel sources are not installed. However, in some cases, kernel sources need to be modified in order to add certain functionality to the OS. Even if others provide additional functionality to kernels on GitHub, users need to compile these changes and install a new kernel version. This section provides all the required principals: kernel sources are downloaded from GitHub and then configured and compiled. Finally, the new kernel will be installed. In Chapter 4, An Arcade Cabinet, we will add some additional functionality to the LeMaker's LeMedia kernel, which is required in order to run Video Disk Recorder (VDR) smoothly.

All Allwinner A20 kernels (such as the ones used for Banana Pro) are based on kernel version 3.4.x. The subversion x is 106 at the time of writing this book. Initial kernel versions, such as...

Summary

In this chapter, we learned how to remote connect to Banana Pro in order to program an embedded board. Different kinds of IDEs have been introduced to you. In most cases, a terminal and vi editor will do the job. You have now learned the basics of shell programming, C/C++, Python, and Scratch.

Examples have been provided dealing with Banana Pro onboard LEDs and GPIOs. Last but not least, you have also learned how to compile, install, and booted your own kernel.

The next chapter deals with wire projects. You will learn how Banana Pro can be used as a hotspot, or provide an AirPlay server for wireless audio transmission. Moreover, we will take a look at databases that host web pages.

Left arrow icon Right arrow icon

Key benefits

  • • Delve into the expanse of Banana Pi’s self-managing functionalities and develop real-world projects
  • • Gain hands-on experience of developing various wireless, multimedia, robotic, and sensor-based applications with Banana Pi
  • • Develop your applications using Banana Pi through a project-based approach

Description

This book follows a tactical plan that will guide you through the implementation of Banana Pro and its configurations. You will then learn the various programming languages used with Banana Pi with the help of examples. In no time at all, you’ll be working on a wireless project that implements AirPlay servers, hotspots, and so on. Following this, you’ll develop a retro-style arcade kiosk game. Then we’ll move on to explore the multimedia features of Banana Pro by designing and building an enclosure for it. After this, you’ll learn to build a remote-controlled smart car and we’ll examine how to control a robotic arm. The book will conclude with the creation of a home sensor system that has the ability to expand or shrink to suit any home.

Who is this book for?

This book is designed for those who are interested in exploring the capabilities of Banana Pro. Basic know-how of Linux and embedded systems would be an added advantage.

What you will learn

  • • Remotely connect to Banana Pro and program the embedded board
  • • Use Banana Pro as a hotspot or provide an AirPlay server for wireless audio transmission
  • • Find out about the different programming languages that can be used with Banana Pro
  • • Build and program your own multimedia centre in order to watch television and movies
  • • Connect peripherals such as a camera, LCD, or hard disk to Banana Pro
  • • Manage and regulate your Linux system with Banana Pro
  • • Stream music wirelessly from your mobile phone to Banana Pro

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 31, 2015
Length: 366 pages
Edition : 1st
Language : English
ISBN-13 : 9781783552382
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Dec 31, 2015
Length: 366 pages
Edition : 1st
Language : English
ISBN-13 : 9781783552382
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 142.97
Banana Pi Cookbook
$32.99
Learning Linux Shell Scripting
$54.99
Banana Pro Blueprints
$54.99
Total $ 142.97 Stars icon
Banner background image

Table of Contents

9 Chapters
1. Introduction to Banana Pro Chevron down icon Chevron up icon
2. Programming Languages Chevron down icon Chevron up icon
3. Wireless Projects Chevron down icon Chevron up icon
4. An Arcade Cabinet Chevron down icon Chevron up icon
5. A Multimedia Center Chevron down icon Chevron up icon
6. Remote Controlling a Smart Monitor Car Chevron down icon Chevron up icon
7. A Laser Engraver Chevron down icon Chevron up icon
8. Scratch – Building a Smart House Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(3 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Gregg Marshall Jan 09, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have to admit I wasn't paying attention when I bought this book during the Packt sale. I had gotten a Chinese clone of a Raspberry Pi called an Orange Pi. It's close enough to the Raspberry that many/most things work the same way. I figured this would be like that. The Banana Pro is pretty different with built in WiFi and better hardware interfaces for hacking. That being said, I figured I'd at least flip through the book. I was really impressed with the clarity of the explanations. After 3 or 4 introductory chapters about the hardware and tools to be using, the remaining chapters are projects from start to finish, including packaging. Some were clearly not interesting, a retro gaming console isn't my thing, but the rest were valuable and the explanations were sufficient to adapt for the hardware I have. Then I got to chapter 7 and floored. It is all about building a laser cutter. I just got a Chinese cutter that is amazing and disappointing at the same time. The hardware is amazing, the documentation, software and most of all the support sucks. So finding there might be alternatives could turn that lemon into lemonade. Just seeing how they approach the project would make this book invaluable. Each of the chapters is pretty comprehensive given that probably each of the chapters could be a whole book on its own.
Amazon Verified review Amazon
matthew williams Feb 10, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I was given a copy of this book for review purposes. What follows are my personal thoughts on this book.From start to finish this book is really useful to someone new to Linux and SBC's, if you are an experienced Linux the initial chapters won't be as useful but still a good refresher.What really set this book apart from others is the projects in this book. From purely software based projects to a combination of software and hardware this book will help guide new users to getting a project running from start to finish. It does a great job of walking through an entire project.The chapter I was most surprised by was chapter 7 a laser engraver. PacktPub has once again gone above and beyond my expectations by including this chapter and doing a fantastic job helping to navigate threw the process of setting this up.
Amazon Verified review Amazon
GreenBeanieGuy Jan 06, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The Banana Pro is an outstanding fork of the Raspberry Pi. Sort of an RPi on steroids. It's more geared toward those who are familiar with an Arduino-type board, in that it more extensive hardware interface capabilities (SATA, three types of video output, TTL headers, an IR receiver, an electret microphone, USB 2.0 OTG, et al.) beyond the 40-pin GPIO (with all the usual embedded systems protocols) the Raspberry Pi has. There's also an on-board WiPi for 802.11 connectivity.This board is better for those with experience in hardware interfacing. While the book meticulously documents and illustrates projects many of the projects will use techniques more familiar to an engineer than a hobbyist. One of the strengths of this book is that it does go into detail on how to use the interfaces, as well as a pretty complete set of specs. I'm an engineer, and I still appreciate guidelines on how to power up a new system without letting the magic smoke out.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.