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
$54.99
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
$54.99
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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
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
Estimated delivery fee Deliver to Ecuador

Standard delivery 10 - 13 business days

$19.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Ecuador

Standard delivery 10 - 13 business days

$19.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

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 Pro Blueprints
$54.99
Learning Linux Shell Scripting
$54.99
Banana Pi Cookbook
$32.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 the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela