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
Mex$631.99 Mex$902.99
Full star icon Full star icon Full star icon Full star icon Full star icon 5 (3 Ratings)
eBook Dec 2015 366 pages 1st Edition
eBook
Mex$631.99 Mex$902.99
Paperback
Mex$1128.99
Subscription
Free Trial
Arrow left icon
Profile Icon Ruediger Follmann Profile Icon Tony Zhang
Arrow right icon
Mex$631.99 Mex$902.99
Full star icon Full star icon Full star icon Full star icon Full star icon 5 (3 Ratings)
eBook Dec 2015 366 pages 1st Edition
eBook
Mex$631.99 Mex$902.99
Paperback
Mex$1128.99
Subscription
Free Trial
eBook
Mex$631.99 Mex$902.99
Paperback
Mex$1128.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

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 : 9781782175674
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Dec 31, 2015
Length: 366 pages
Edition : 1st
Language : English
ISBN-13 : 9781782175674
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 Mex$85 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 Mex$85 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Mex$ 2,934.97
Banana Pro Blueprints
Mex$1128.99
Learning Linux Shell Scripting
Mex$1128.99
Banana Pi Cookbook
Mex$676.99
Total Mex$ 2,934.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

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.