LXJ 246
LXJ 246
NETWORK
SECURITY
and SSH
What You
Need to Know
Since 1994: The Original Magazine of the Linux Community OCTOBER 2014 | ISSUE 246 | www.linuxjournal.com
EMBEDDED
HOW-TO:
Sump Pump
Monitor with
+
Interview
Raspberry Pi with the
and Python Creators
of the
“Hello
AN World
Program”
INDEPTH
LOOK Advanced
at the U-Boot Vim Macro
Environment Techniques
Anatomy
)HDWXUHG
'RZQORDG
Achieving
Enterprise Class zStax StorCore 104
Storage in the
Cloud with
Software
'HÀQHG6WRUDJH
7DONZLWKDQH[SHUWWRGD\_ZZZVLOLFRQPHFKDQLFVFRP]VWD[
EMBEDDED
FEATURES
56 Raspi-Sump
Put a Raspberry Pi
with Raspbian Linux
to work and protect
your basement
against flooding.
Al Audet
68 U-Boot
Environment
Variables
Everything you need
to know about the
U-Boot environment.
Sachin Verma
82 Accessing
the IO Ports
of the
BeagleBone
Black with
Python
With the BeagleBone
Black, you can
command all your
electronic gear with
a few lines of Python.
Samuel Bucquet
38 Dave Taylor’s
Work the Shell
Picking Out the Nouns 22
42 Kyle Rankin’s
Hack and / ZĂƐƉŝͲ^ƵŵƉtŝƌŝŶŐŝĂŐƌĂŵ
ZĂƐƉďĞƌƌLJWŝDŽĚĞů ,Ͳ^ZϬϰhůƚƌĂƐŽŶŝĐ^ĞŶƐŽƌ
Return of the Mac
46 Shawn Powers’
The Open-Source Classroom s
ĐŚŽƚŽŐƉŝŽϮϳ ϰϳϬZKŚŵZĞƐŝƐƚŽƌ
ON THE COVER
5L[^VYR:LJ\YP[`HUK::/·>OH[@V\5LLK[V2UV^W
/V^;V!:\TW7\TW4VUP[VY^P[O9HZWILYY`7PHUK7`[OVUW
(U0UKLW[O3VVRH[[OL<)VV[,U]PYVUTLU[(UH[VT`W
0U[LY]PL^^P[O[OL*YLH[VYZVM[OL¸/LSSV>VYSK7YVNYHT¹W
(K]HUJLK=PT4HJYV;LJOUPX\LZW
<ZL[OL)LHNSL)VUL)SHJR[V*VTTHUK@V\Y,SLJ[YVUPJ.LHYW
82
LINUX JOURNAL (ISSN 1075-3583) is published monthly by Belltown Media, Inc., 2121 Sage Road, Ste. 395, Houston, TX 77056 USA. Subscription rate is $29.50/year. Subscriptions start with the next issue.
Contributing Editors
)BRAHIM (ADDAD s 2OBERT ,OVE s :ACK "ROWN s $AVE 0HILLIPS s -ARCO &IORETTI s ,UDOVIC -ARCOTTE
0AUL "ARRY s 0AUL -C+ENNEY s $AVE 4AYLOR s $IRK %LMENDORF s *USTIN 2YAN s !DAM -ONSEN
Advertising
E-MAIL: [email protected]
URL: www.linuxjournal.com/advertising
PHONE: +1 713-344-1956 ext. 2
Subscriptions
E-MAIL: [email protected]
URL: www.linuxjournal.com/subscribe
MAIL: PO Box 980985, Houston, TX 77098 USA
Go to http://drupalize.me and
get Drupalized today!
Linux Inside!
L
inux inside, Linux inside, every for programmers and neophytes like
single one of us has Linux myself. Now we get a glimpse at some
inside! (Sung to the tune of the books he uses for learning
of “Devil Inside” by INXS—you’re himself. Whether you want advice on
welcome for the ear worm, I can’t get language books, database books or
it out of my head either.) even some information on freelancing,
In the world of embedded systems, Reuven shares his stash. If you’re
systems-on-chip and single-purpose looking for your next book to read
hardware solutions, it’s easier to list (after this issue of Linux Journal, of
the products that don’t have Linux as course), check out his column.
their operating system! This month, we Dave Taylor begins a new adventure,
focus on putting Linux into tiny places, this time attempting to parse the
and that means everything from the written word and grammar with
tiniest “Android Wear” watch to the scripts. It’s always fascinating to see
ubiquitous Raspberry Pi. As Linux users, tasks that are simple for humans
we’ve been sneaking open source into attempted by programs and logic.
server rooms for decades. Now we get Dave’s column is more than just
to sneak it in everywhere! instructive, it will force you to think as
This issue starts with Reuven M. well! Speaking of thinking, the title of
Lerner discussing the books he’s Kyle Rankin’s column this month will
embedded into his bookshelf this year. make you think hard. “Return of the
Month after month, Reuven gives us Mac” seems like the exact opposite
incredible tips, techniques and training of what Kyle would write about. And,
of course, he doesn’t talk about an
VIDEO: Apple product. I won’t give it away,
V
of Apple—in fact, quite the opposite. and teaches how to customize the
I put on my grey hat this month and information passed on at boot.
talk a little bit about SSH. “Hacking” is Finally, Samuel Bucquet gives a crash
a word that is used to describe far too course in accessing the BeagleBone
many things, most of which I think are Black’s I/O ports via Python. Although
more accurately described as, “Using the Raspberry Pi and BeagleBone
Things Like They Were Made To Be Black are both excellent platforms for
Used”, but that’s not as catchy for a embedded projects, the BBB’s sheer
movie title. Firewalls are important number of I/O options make it incredible
security tools for any network, but for projects with a large number of
it’s important to realize that firewalls sensor needs. With Samuel’s help, you
can’t be your only defense against can access those ports with the friendly
access. This month I show you why. Do and familiar Python language.
I “hack” the firewall? I don’t think so, The Embedded issue of Linux
but for someone unfamiliar with SSH Journal always makes me want to
tunneling, it sure looks like it. build something. Now that BirdCam
Al Audet shows how to embed Linux is off-line (the battery in my old
into a hole in the ground this month. Android phone blew up—it was ugly),
More specifically, he explains how he maybe it’s time to start over from
uses a Raspberry Pi device to monitor scratch. I’m sure there are some great
the sump hole in his basement to weatherproof IP cameras out there I
avoid flooding. Sump pumps are could use to get better shots of the
amazing devices—until they’re not. winter birds. Either way, this is a great
Al shares not only his method, but issue, and we had a great time putting
also his scripts for controlling a sensor together for you. Whether you want
that warns him if the water level rises tech tips, programming ideas or just
too much. It’s the perfect example of my silly insight on the best new apps
solving difficult problems with Linux. for your phone, the October issue of
Sachin Verma goes even deeper (pun Linux Journal aims to please! Q
intended) and shows how to deal
with the bootloader on embedded Shawn Powers is the Associate Editor for Linux Journal .
Linux systems. U-Boot is commonly He’s also the Gadget Guy for LinuxJournal.com, and he has
used in such environments, and along an interesting collection of vintage Garfield coffee mugs.
with booting the kernel, you can Don’t let his silly hairdo fool you, he’s a pretty ordinary guy
pass environment variables as well. and can be reached via e-mail at [email protected].
Sachin walks through the boot process Or, swing by the #linuxjournal IRC channel on Freenode.net.
options, but they are pretty much a if [ $(( ${YEAR} % 4 )) -eq 0 ] && [ $(( ${YEAR} % 100 )) -ne 0 ]
echo 'Leap'
The best deal I have for Linux Journal Dave Taylor replies: There are
directly is https://www.pubservice.com/ lots of ways to calculate it, for
Subnew2page.aspx?PC=LJ&PK=M48RENN. sure. I like my latest: just type
date -d 12/31/YEAR +%j , and
I hope that helps. Sorry that see if it’s 365 or 366.
it’s more complicated than we
would like, but once iTunes and Counting Days
Android closed their subscription Dave Taylor’s Work the Shell column is
environments, it became impossible one of my favorites in Linux Journal.
to extract those orders and However, while reading the August
automatically add them to our database 2014 issue, I thought “don’t re-invent
so readers can receive every format we the wheel.” In astronomy, getting the
have.—Mark Irgang, Publisher time interval (in days and fractions
thereof) between any dates is a daily a bit anxious with such complicated
bread and butter issue. The solution formulae in the mix.
is the Julian Date, a consecutive
count of days from centuries ago into Thanks for pointing that out. Good stuff!
the future. It is a relatively simple
algorithm, although not intuitive. See, Norbert responds: Thanks for
for example, http://aa.usno.navy.mil/ responding to my earlier e-mail. Those
faq/docs/JD_Formula.php. constants are determined to “make
it work”, accounting for the fact that
Yes, the algorithm is originally different months have a different num-
coded up in FORTRAN (what else ber of days (even going over centuries)
was there in the science world and so on. It is hard to understand the
some decades ago), and we still algorithm; however, the result is a fast,
use it. A conversion to a shell accurate algorithm. Testing was done
script or any other programming on sample data, and after verification,
language should be easy. no further tests are needed as part of
—Norbert Zacharias the algorithm. Of course, one needs to
be very careful when cutting/pasting
Dave Taylor responds: Holy cow, lines in order not to screw it up.
that’s awesome stuff, Norbert! I
haven’t dabbled in FORTRAN since the PS. We still code in FORTRAN partly
job I had while I was an undergrad because we inherited a large body of
at UCSD back in the early 1980s. As code in our area of research and partly
it happens, I really enjoyed FORTRAN because the code is really easy to write
and enjoyed reading the code too. and efficient—it pays off when dealing
with billions of star positions. It even
How that formula works, however, is a still can be done on a modern laptop!
bit puzzling to me, as there are some
rather mysterious constants that don’t Suggestion
seem like they should work. Still, it’d I am working for a telecom vendor
be easy enough to recode as a shell on OSS products. Lately, I’ve been
script—in fact, the FORTRAN code working on NFV-related meetings
is almost workable as is with just a and workgroups. There is a lot
few tweaks. My only comment: the going with NFV all around telco
lack of error checking makes me get operators, and almost all will run
Those are the biggest players around. subscription inquiries can be done instantly
on-line: http://www.linuxjournal.com/subs.
E-mail us at [email protected] or reach
us via postal mail at Linux Journal, PO Box
You are the Linux magazine, yet I see almost 980985, Houston, TX 77098 USA. Please
remember to include your complete name
nothing on these issues. This disappoints me. and address when contacting us.
Personally, I would like to see not only NASA’s ACCESSING THE DIGITAL ARCHIVE:
open-source tools, but also such big enterprise Your monthly download notifications
will have links to the various formats
issues on open source and Linux. Linux is a serious and to the digital archive. To access the
digital archive at any time, log in at
thing that runs the Internet and many serious http://www.linuxjournal.com/digital.
applications on the enterprise level. I would like to LETTERS TO THE EDITOR: We welcome your
letters and encourage you to submit them
see these improvements in your magazine. at http://www.linuxjournal.com/contact or
We look for content that interests our users, WRITING FOR US: We always are looking
for contributed articles, tutorials and
along with new technology we think deserves to real-world stories for the magazine.
An author’s guide, a list of topics and
be noted. Getting feedback like yours is the best due dates can be found on-line:
http://www.linuxjournal.com/author.
way for us to know what readers want, so we’ll
keep our eyes open. Thanks!—Shawn Powers FREE e-NEWSLETTERS: Linux Journal
editors publish newsletters on both
a weekly and monthly basis. Receive
late-breaking news, technical tips and
tricks, an inside look at upcoming issues
and links to in-depth stories featured on
http://www.linuxjournal.com. Subscribe
WRITE LJ A LETTER for free today: http://www.linuxjournal.com/
send us your comments and feedback via ADVERTISING: Linux Journal is a great
resource for readers and advertisers alike.
http://www.linuxjournal.com/contact. Request a media kit, view our current
editorial calendar and advertising due dates,
or learn more about other advertising
and marketing opportunities by visiting
PHOTO OF THE MONTH us on-line: http://ww.linuxjournal.com/
advertising. Contact us directly for further
Remember, send your Linux-related photos to information: [email protected] or
[email protected]! +1 713-344-1956 ext. 2.
diff -u
WHAT’S NEW IN KERNEL DEVELOPMENT
Kernel configuration has become driver name which arch it’s for (lately
more and more complex through the the majority are for ARM), but that isn’t
years with the proliferation of new really a great way to handle things.”
drivers, new hardware and specific There was some resistance to the
behaviors that might be needed for idea. Greg Kroah-Hartman, in
particular uses. It has reached about particular, suggested that there were
3,000 config options, and that existing alternatives. For example,
number will only increase. he said users simply could compile
Jean Delvare recently pointed out everything as modules. Then, they’d be
that a lot of those config options were loaded into the system only as needed.
relevant only to particular hardware, But, neither Jean nor Josh liked that
and yet the config system presented suggestion. Jean said that in the old
them to users who didn’t have that days it was fine to build everything
hardware. This seemed like a bug to as a module, but nowadays there
him, and he suggested that maintainers were just too many modules, and that
begin requiring proper hardware “Saying ’m’ to everything increases
dependencies for all config options. build times beyond reason. You also
He acknowledged this would be hit build failures you shouldn’t have
a big task—especially for existing to care about, depmod takes forever,
drivers. But creating the requirement updates are slow as hell. This is the
for new drivers would at least get the problem I am trying to solve.”
ball rolling, and older drivers could Greg didn’t see how build times
follow along more gradually. could be a problem. Building the kernel
Josh Boyer agreed with all this. on his laptop, he said, took about
From his work on the Fedora project, 20 minutes—with all 3,000 modules
he had to deal with the config system compiled in. If that wasn’t good
intensively, and he found it difficult. He enough, he suggested upgrading the
said, “I’ve gotten to the point where hardware to get a faster build time.
I can somewhat guess based on the But, Jean said this wasn’t a practical
solution for some cases. He said, “We the discussion, but it does seem
have 34 kernel flavors for openSUSE as though there’s a vast mountain
13.1, for example. And, every commit of configuration options that are
potentially triggers a rebuild of the becoming more and more difficult to
whole set, to catch regressions as fast deal with. Eventually, I think some
as possible. So every module we build, form of clean hardware dependencies
for no good reason, gets built a hundred will end up being implemented, along
times each day.” He added that it would the lines of Jean’s suggestion.
cost a lot of money to upgrade the With all the new devices coming
hardware underneath that build system. out on the market, there’s a big
Greg said he understood the issue, desire to get Linux running properly
but that fixing the config system was on all of them. Things like Intel’s
just a hard problem to solve. It boiled Quark system use only a few MB of
down to enforcing better habits on RAM and have other tight hardware
everyone producing patches. He said, requirements. Shrinking Linux down to
“If you see new drivers show up that you the right size poses a challenge.
don’t know where they work on, ask the Andi Kleen recently pointed out,
developers and make up patches.” He “One problem on these small systems is
added, “Perhaps a few developers could the size of the network stack. Currently
be auditing the new Kconfig items of enabling IPv4 costs about 400k.” He
every kernel around -rc3 time frame to wanted to give users the option to
ensure that they don’t do stuff like this.” prune down the Linux networking
Jean said that -rc3 would be too stack to only the bare essentials and
late, because “all kernel developers get it down to 100K per application—
and distributions have already moved competitive with Adam Dunkel’s LwIP
to the new kernel so they have already (Lightweight IP) project.
answered the n/m/y question for all Andi posted some patches to
new entries.” He added, “It’s the create three available options for the
reviewer’s job to refuse new drivers networking stack: a full system with
with bad Kconfig descriptions in the all current features, a partial system
first place. This must happen as early that supported regular users but
as possible in the chain.” not servers or a minimal networking
No clear decision came out of system for the special userland on
EdgeRouter Lite
In the
September
2014 issue, I
mentioned my
new router,
and I got a
lot of e-mail
messages
asking about
how well it
works. I can say without hesitation Q Advanced configuration possible.
it’s the nicest router I’ve ever owned.
And, it was less than $100! Q Price!
The EdgeRouter Lite is a business-
class router based on the open-source I’ll admit, setting up the EdgeRouter
Vyatta system. It has been forked, Lite was a pain in the rear end. The
and as it matures, it will become less basics can be done via the Web
and less like the original Vyatta code, INTERFACE BUT IF YOU WANT ANY 1/3 FOR
but for the present, it works much your connection, it will be a learning
the same. I purchased the EdgeRouter experience trying to figure out the
because my old ATOM-based ClearOS Vyatta command and code (and
router/firewall couldn’t keep up with concepts!) for doing so. It took me
the traffic from my home network. My three or four hours to get the setup
favorite features include: that I’m happy with, and since then, I
haven’t touched it—at all. It works so
Q Three GigE ports, each fast, I never notice it, and it’s been rock-
routable separately. solid since day one. If you’re looking
for an advanced router, but don’t want
Q A claimed one million packets to break the bank, the EdgeRouter Lite
per second throughput. might be exactly what you’re need. Be
warned, however, its setup is not for the
Q Wire-speed routing. faint of heart.—SHAWN POWERS
Sometimes, when the clock hits Web site showing off the best ones.
3:00am, and you’ve been in the
server room since 9 o’clock the Q cowsay: install this program, and
previous day, you start to get a little the cow will say whatever you ask
batty. That’s the only explanation it to. (Bonus: there’s a GUI version
I have for programs like cowsay in of cowsay too, called xcowsay!)
Linux. Still, I’m glad they’re there,
because life wouldn’t be nearly as Q sl: this is a program I like to install,
fun without them. Here’s a quick list because it makes fun of you when
of silly Linux programs off the top of you accidentally type sl instead
my head. I’d love to hear about more, of ls —a steam locomotive chugs
so please, send me your crazy Linux across the screen. (It also shows up
Easter eggs, and I’ll follow up on the if you press caps lock, and type LS !)
Figure 1. When Gpredict first starts, you get an initial module called Amateur.
command. When it opens, you should which contains a map view, a polar
see the main window, with a sample view and a single satellite view. For
layout given by the module named some of these views, you may notice
“Amateur” (Figure 1). a small down-arrow in one of the
In the rest of this article, I take a top corners. Clicking this icon gives
look at all the various possible layouts you an appropriate drop-down list
and show just how much information of options. For example, clicking the
is available to you. down-arrow in the map view gives you
The core concept in Gpredict is a list of items, such as detaching the
that of the module. You can think module or configuring it (Figure 2).
of modules as documents in a word The map view offers a map of the
processor. They are containers you can Earth, with a series of satellites and
use to hold a number of other layout their footprints on the Earth. When
objects that display satellite information you hover over one of the satellites,
in a number of different ways. you will see an information box
When you first start Gpredict, you with the satellite’s detailed location.
get the default Amateur module, The single satellite view provides
Figure 3. You can set the configuration details for the map view here.
even more detail about one specific clicking the down-arrow and selecting
satellite. You can select which satellite configuration (Figure 3).
is being displayed by clicking on the You can add another ground
down-arrow in the view. The polar station by clicking the plus sign.
view provides an overhead look, This will pop up a details window
located at the ground station. where you can enter a name and the
In the Amateur module, you get location data for your ground station
one ground station called “sample”. (Figure 4). For the location, you can
You can add more ground stations by enter the latitude and longitude
manually, or if you live in a major module. It might make the display a tad
city, you can select it from a global crowded, but it still should work.
list of locations. I should take a step back at this
One other item you will notice when point and describe some other
you have the configuration window configuration options available.
open is that you can select which The first option to look at is the
satellites are displayed. This list is rather menu item EditAUpdate TLE. This
large, but there is nothing stopping option lets you update the Keplerian
you from adding all of them to your elements for the satellites. You can
Figure 5. The preferences window lets you change all sorts of options.
Figure 6. You can control radios and antenna rotators that are defined in Gpredict.
The modules section lets you change select the custom layout, you define
configuration options used in the display what it will look like by entering the
of the Gpredict modules. You can change layout code. See the user manual for
things like the refresh rate for the displays details on how to define a code to
or what map to use as the background create the layout you want.
for the map view. You also can select Gpredict also has the ability to
what type of layout you want for a control radios and rotators. The key to
particular module. When you select a this is the hamlib library. By using this
new layout, you will see a preview of library, Gpredict can handle Doppler
what it will look like in the preferences tuning of radios and tracking of
window. There are nine different antenna rotators. When you want to
pre-generated layouts available, or you connect hardware to your computer,
can create a custom layout. When you you should verify that hamlib can talk
to it successfully. Once you have made pulling up the radio control window,
sure everything is working correctly, which you access by clicking the down-
you can set up Gpredict to talk to arrow in the map view and selecting
your hardware. This is handled in the Radio Control (Figure 6). You can see
interfaces section of the preferences the details of the downlink and uplink,
window. There are two tabs, one for as well as information about targets.
radios and one for rotators. Since Now that you know how to get
hamlib communicates over network satellite information for what is moving
protocols, the radio or rotator doesn’t above your head, you should be able
even need to be connected to the same to go outside and do some actual
machine. You can define one of these observations and see all of the man-
pieces of hardware with a hostname, made objects travelling around. It
a port and the communication can be inspiring to see how much we
details. Once you have the hardware already do in space, and how much
configured, you can control it by more we could be doing.—JOEY BERNARD
LINUX JOURNAL
now available
for the iPad and
iPhone at the
App Store.
linuxjournal.com/ios
For more information about advertising opportunities within Linux Journal iPhone, iPad and
Android apps, contact John Grogan at +1-713-344-1956 x2 or [email protected].
Non-Linux FOSS:
Remember Burning ISOs?
I was chatting with a Windows-
using friend recently, and he
wanted to try Linux on one of
his older computers. I always like
those sorts of conversations, and
so I kept chatting, walking him
through setting up Unetbootin
to create a USB installer and so
on and so on. Unfortunately,
he wasn’t able to get the USB
drive to boot. Since we were
half a country apart, I couldn’t
troubleshoot locally, so we moved
on to burning a CD/DVD.
My first instinct was to have
him download the incredible
InfraRecorder. Unfortunately,
there seems to be a malware- Image courtesy of http://www.visualpharm.com.
infected version of InfraRecorder
going around, and of course, about the malware masquerading as
that’s the download link he found. open-source software. Remember to
So, be sure to send folks directly send people directly to the Web site
to http://infrarecorder.org rather than having them “google”
to download it. for it. The open-source InfraRecorder
Alternatively, I’m a big fan of the is at http://infrarecorder.org,
free-but-not-free program ImgBurn and the freeware ImgBurn is at
as well. It’s not open source, but it http://www.imgburn.com. Once
is freeware, and it has a very simple they switch to Linux, everything
interface. Either way you go, be sure they need will be an apt-get or
to warn potential Linux converts yum away! —SHAWN POWERS
Roundup
Reuven gives his annual rundown of great books on
programming languages, databases and analytics,
freelancing and more.
and Lutz has done us all a good service increase performance: benchmarking
by providing such information. and profiling (to understand where the
This is not a book about learning problem is); NumPy’s arrays (which are
Python, but rather it’s meant to be a faster, if more limited, than Python’s
reference and in-depth description of built-in lists); Cython (which translates
how the language works. And at that, Python code into C); and finally,
it succeeds. At the same time, I feel like multiprocessing. The book is relatively
the book is far too large (at more than short (at 108 pages), but it does provide
1,600 pages), 400 pages of which are some of the most common techniques
spent describing TkInter, a GUI toolkit for increasing program speed. At the
that is included with Python, is easy same time, I think that some more
to use and is cross-platform. But, it’s basic techniques, such as not using +=
also extremely ugly and not particularly to iteratively build strings, would have
popular, in my experience. If you’re a added something to the book.
Python programmer though, you’ll likely The hottest language continues to
want to have this book on your shelf. be JavaScript, if for no other reason
When I’m teaching Python than the very large number of people
programming classes, my students who have access to browsers, be it
often ask me how they can boost on their computers or their mobile
the performance of their code. devices. JavaScript’s huge community
True, I think that Python, like many has been pushing forward with a
other high-level languages, stresses variety of techniques and libraries that
programmer efficiency over language make development easier. Moreover,
efficiency. And of course, we know JavaScript is now popular beyond the
that worrying about performance too browser, in such places as node.js,
early in a project is asking for trouble. a server-side framework that uses
At the same time, once our program is asynchronous JavaScript.
working, we definitely want to increase It is this first topic that Async
its speed. Python High-Performance JavaScript, written by Trevor Burnham
Programming, written by Gabriele and published by the Pragmatic
Lanaro and published by Packt Programmers (ISBN 978-1-937785-27-7),
Press (ISBN 978-1-78328-845-8), addresses. Part of the difficulty that
aims to solve some of these issues. people have when working with
The book concentrates on a small JavaScript is its asynchronous nature.
number of areas that can be used to You often set up a function to be
system, which would make life so much data” increasingly is applied to such
easier. He was right, although he was programs, and a number of books have
recommending a system that preceded been written in the past few years that
Git known as Arch, which I don’t attempt to help newcomers to the field.
believe is used any longer. In some cases, you don’t need to
I frequently teach courses in the use collect or analyze the data yourself.
of Git, and I’ve found that the problem Rather, you can get by just using the
for most users is not the commands, APIs that various systems have provided.
but rather the understanding of what This is particularly the case with social
Git does (and doesn’t do) and how networks, which collect enormous
the various objects work together. In quantities of information about their
particular, an understanding of what members and the connections between
a commit is, and how branches, tags, them. Mining the Social Web, by
blobs and trees fit into this commit- Matthew A. Russell, was released in its
centric view of the world, is the biggest second edition (ISBN 9781449367619),
obstacle to working with Git. and it describes many ways in which
So, I was happy to see the Git you can access and analyze different
Pocket Guide, written by Richard E. social networks. I’ve played with
Silverman and published by O’Reilly such APIs in the past, so I wasn’t
(ISBN 9781449325862). Yes, this book new to their use in my applications,
will help you use Git better, and it will but this book described a number
remind you of many of the commands. of uses I didn’t think of, with lots of
But more significant, the Git Pocket clear example code that illuminated
Guide introduces you to the objects the points.
Git uses and describes how they work For those who want to analyze large
together to provide a robust and data sets more directly, Doing Data
efficient version-control system. Science, by Cathy O’Neil and Rachel
Schutt and published by O’Reilly
Databases and Analysis (ISBN 9781449358655), is a dense,
The growth of the Web has led not but interesting, introduction to the
only to a growing need for people techniques that are collectively known
who can create Web applications, but as “Data Science”. The authors give
also for those who can store, retrieve a whirlwind tour of the math and
and analyze the data generated by algorithms used in such analysis and
those applications. The term “big also the types of conclusions you
the Nouns
Dreamer—a dream interpretation program, as a shell script...
well, sort of.
Mad Libs for dreams? That’s First, We’ll Kill All the Nouns
certainly a curious idea, particularly I was going to grab the comprehensive
given how seemingly random and dictionary from Princeton University’s
alternative uses and so forth. The end ´tr '[A-Z]' '[a-z]' | tr ' ' '\n')
it generates too many false hits. So # is the word a noun? Let's look!
INSTEAD $ESI 1UINTANS HAS A SIMPLE WORD if [ ! -z "$(grep -E "^${word}$" $nounlist)" ] ; then
only list you can grab for our purpose nouns="$nouns $word"
here: http://www.desiquintans.com/ fi
downloads/nounlist.txt. done
matching the noun “acoustic” for read input # let's read another line from the user...
of the line, and $ is the end of the line— echo "Okay. To confirm, your dream was about:"
do
input=""; nouns="" echo "Are you ready to do some free association? Let's begin..."
do
echo "Welcome to Dreamer. To start, please describe in a echo "What comes to mind when I say $word?"
It’s really broken into simple Are you ready to do some free association? Let's begin...
functional blocks: first prompting What comes to mind when I say tree?
users to share their dream, then What comes to mind when I say house?
breaking down the prose into What comes to mind when I say middle?
individual words and comparing What comes to mind when I say forest?
them to the noun list and finally What comes to mind when I say owl?
(albeit not yet in its final form), What comes to mind when I say cold?
Dave Taylor has been hacking shell scripts for more than 30 years.
Okay. To confirm, your dream was about: Really. He’s the author of the popular Wicked Cool Shell Scripts
and can be found on Twitter as @DaveTaylor and more generally
I was sitting in a tree house in the middle of an ancient at his tech site http://www.AskDaveTaylor.com.
forest and an owl was staring at me. It asked "who?" and
the Mac
Save yourself keystrokes by building a library of vim macros
to automate mundane text-editing tasks.
often use macros in myself. Because ; BIND data file for example.com
files, they may not all have the same $TTL 15m
would be qtgg/TTL <Enter> wcw10m to the top of the file. Next I type
<Esc> q. Once I record the macro, I type /^ns1 <Enter> to move to the line
u to undo my changes, and then test that configures the name servers.
the macro by typing @t. At this point, there are a few ways I
For macro s, I type qs to enter could edit these lines. My preference
macro mode and assign the macro is to type /IN A <Enter> 2w , which
to the s key. Then I type gg again will move my cursor to the beginning
to anchor to the top of the file. of the IP. Then I type c$10.1.0.250
Next I type /SOA <Enter> to move <Esc> to edit to the end of the line
to the SOA line. Then I type /root and exit insert mode.
<Enter> to move to the beginning Since ns2 is so similar to ns1, I can
of root.example.com, and then just type yyp <Ctrl-a> $ <Ctrl-a> to
type cwdnsadmin <Esc> to change copy and paste ns1, increment ns1 to
that word to dnsadmin and exit be ns2, then move to the end of the
insert mode. Next I type ^j to move line and increment the IP. Next I need
the cursor to the beginning of to find the existing ns2 line and delete
the following line. Finally, I type w it with /^ns2 <Enter> dd . Finally, I
<Ctrl-a> to move forward to the serial can type q to save the macro. The
number and increment it, and then complete macro is qngg/^ns1 <Enter>
q to exit macro mode. The complete /IN A <Enter> 2wc$10.1.0.250
set of macro keystrokes becomes <Esc> yyp <Ctrl-a> $ <Ctrl-a> /^ns2
qsgg/SOA <Enter> /root <Enter> <Enter> ddq . Although this seems like
cwdnsadmin <Esc> ^jw <Ctrl-a> q . a lot of text, it will save a ton of work
And again, I save the macro and use u when you have to repeat the steps on
to undo the change and replay it with multiple files.
@s to make sure it does what I expect. For the final macro w, I type qw
For macro n, I type qn to enter to enter macro mode assigned to
macro mode and assign the macro to the w key, and then type G to move
the n key. Then I type gg to anchor to the bottom of the file this time.
Then I type /^worker <Enter> N to file, I can just type @c to perform the
search for the next worker (which complete list of steps.
will wrap around to the top, then N Now besides saving a few
will move back to the last worker in keystrokes, there are other good
the file). Finally, I type yyp to copy reasons to nest macros in this way.
and paste the line, then <Ctrl-a> Because I saved each logical step
$ <Ctrl-a> to increment both the as its own macro, I can tweak or
worker hostname and the IP. Finally, modify any of the above macros
I type q to exit macro mode. The independently, save the new macro
complete macro is then qwG/^worker to the same key, and all of the other
<Enter> Nyyp <Ctrl-a> $ <Ctrl-a> q. macros, including the final combo
Like the others, I test it out with @w macro can stay the same.
a couple times, and use u to undo Let’s say that after I recorded all of
all the changes in between until I am these macros, I realized I got the IP
satisfied that it works. address for the name servers wrong.
Now that I have all of these All I would have to do is record a
macros recorded, I could just open new macro assigned to the same n
each file and type @t to update key, and once I was done, I still could
the TTL, @s to edit the contact use @c to make the complete set of
information and serial, @n to update changes to a file.
the name servers, and type 50@w to I hope you find these examples
add 50 more workers. useful, and that the next time you
Because I’m going to perform have to perform a series of mundane
these same steps on a number of edits to many text files, you’ll save
files, I might as well capture all those some keystrokes with vim macros. Q
commands in a new macro I’ll assign
to c. To do that, I just type qc to enter Kyle Rankin is a Sr. Systems Administrator in the San Francisco
macro mode assigned to the c key, Bay Area and the author of a number of books, including The
then type @t@s@n50@w to perform all Official Ubuntu Server Book, Knoppix Hacks and Ubuntu Hacks.
of the previously recorded macros. He is currently the president of the North Bay Linux Users’ Group.
Finally, I type q to exit macro mode.
The complete set of keystrokes is
qc@t@s@n50@wq to assign all of the Send comments or feedback via
above sets of keystrokes to a single http://www.linuxjournal.com/contact
macro. Now when I open the next or to [email protected].
We Can’t Have
Nice Things: SSH
Firewalls are great, but don’t rely on them as your only
network security!
I’ve written about SSH before— into the computer. If you’re not,
often even. But for the Linux user, however, you can use SSH to open
SSH is one of those tools that is a tunnel for you automatically. This
so incredibly flexible, everyone does require a few things:
should know and understand it
inside and out. For this article, I Q You need a server running SSH with a
decided to put on my black hat public IP address. I use my co-located
and demonstrate how convenient, Raspberry Pi in Austria, but you can
and terrifying, SSH can be. use your home connection as long
as you set up a Dynamic DNS entry
Phone Home in case your IP changes.
Most articles on SSH start
with forwarding X11 traffic or Q The firewalled network has to
demonstrating the SOCKS proxy allow outgoing SSH connections.
feature. I want to start with Most do, but if you can’t SSH out
something a little more creepy and from inside the firewall, you might
a whole lot more awesome. The have to do something creative
premise is this: you have a computer like run SSH on port 443 on your
inside a firewalled, NAT’d network, server. (That port is usually open
and you want to access it remotely. for HTTPS traffic, and since it’s
If you’re the sysadmin, you can encrypted, it’s tougher to sniff out
just forward a port on the firewall your naughty deeds.)
Q You need key pairs set up for server, I’m stuck behind a firewall.
password-less logins from the Will you listen on port 2222 for
computer inside the firewall to anyone trying to connect, and if they
your server with the public IP. do, please forward the traffic to me
(Here’s a demo I did back in 2009 on my port 22.”
on how to set up SSH key pairs: The command can get creepier
https://www.youtube.com/ too. In my example, I just forwarded
watch?v=R65HTJeObkI.) traffic to the public port 2222 to the
internal port 22 behind the firewall.
Once you have the prerequisites But if you were to change the
in place, the process is a simple command like this:
one-liner. First, the command, then
the explanation: ssh -N -R 0.0.0.0:3389:192.168.1.5:3389 user@remotehost
Figure 1. Although there’s a lot going on behind the scenes, an end user accessing
the virtual hosts on the left just sees a Web server.
Figure 2. Using SSH tunnels and sshuttle together can provide an incredibly scary level
of network access from outside the firewall.
Paul Schuytema’s
The Web Wargame Toolkit
(Mercury Learning & Information)
Paul Schuytema’s new book The Web Wargame Toolkit walks readers
through the process of crafting an old-school, turn-based wargame
in PHP utilizing the CodeIgniter application framework. More
generally, this is a soup-to-nuts how-to book for those interested in
crafting Web game applications utilizing a basic LAMP system. The
wargame project serves as an exciting context for PHP programmers looking to gain more
in-depth application coding experience. Those with an interest in game development will
learn the coding skills to support design decisions as they create the game project. The book
assumes at least a beginning level of PHP coding experience, though no previous CodeIgniter
or game development experience is required. Other features of the book-DVD set include full
database design for game data structures, a flexible game map system, a complete overview
of a simple CRUD system and complete, modifiable source code for the game.
http://www.merclearning.com
Wolfram SystemModeler
The updated Wolfram SystemModeler 4 is an easy-to-use, next-generation
modeling and simulation environment for cyber-physical systems.
SystemModeler enables users to draw on a large selection of built-in and
expandable modeling libraries to build industrial-strength, multidomain
models of a complete system. Wolfram is also well known for the
complementary Mathematica application, which provides a fully integrated
environment for analyzing, understanding and quickly iterating system
designs. The new SystemModeler 4 vastly expands support for modeling
libraries, adds standardized deployment of models to other simulation tools
and deepens integration with Mathematica. Other key new features include
a library store with verified model libraries, improved modeling features,
model creation support from Mathematica, as well as improved workflow in the integration with
Mathematica, a new documentation center and support for our beloved Linux OS.
http://www.wolfram.com
RASPI-SUMP
ZĂƐƉŝͲ^ƵŵƉtŝƌŝŶŐŝĂŐƌĂŵ
ZĂƐƉďĞƌƌLJWŝDŽĚĞů ,Ͳ^ZϬϰhůƚƌĂƐŽŶŝĐ^ĞŶƐŽƌ
s
dƌŝŐƚŽŐƉŝŽϭϳ
ĐŚŽƚŽŐƉŝŽϮϳ ϰϳϬZKŚŵZĞƐŝƐƚŽƌ
ϭ<KŚŵZĞƐŝƐƚŽƌ
'ƌŽƵŶĚ
The four pins on the sensor are A way is needed to throttle the
wired to the Raspberry Pi as follows: current to 3.3V, which won’t damage
the Pi. To protect the Pi from damage,
Q Pin 1 VCC connects to the 5V pin 2. simply insert a voltage divider on
the Echo line between the sensor
Q Pin 2 Trig connects to GPIO17 pin 11. and the Pi.
CAT5 cable. Because there are four on-line, but anything you can
connections, only four of the eight salvage from an old PC works great.
twisted wires are used. On each
end of the selected wires, I soldered Mounting
connectors that were compatible The HC-SR04 is attached to a plastic
with the sensor pins and the pins case and screwed onto a piece of
on the Pi. An old 3.5" floppy drive wood strapping. The wood strapping
power connector works great for is inserted into the sump pit facing
the sensor connection (Figure 2). I downward and is easily adjustable
used a couple two-pin PC case-fan and removable if needed. The Cat5
connectors, salvaged from an old wire is securely taped to the sump
PC, for the connections on the Pi’s pump’s ABS pipe and an open
pins. These connectors are available wall stud to prevent tangling and
Figure 3. Open
Sump Pit View
Raspi-Sump
The Raspi-Sump program currently
consists of three Python scripts. The
main script is raspisump.py. The script
is very simple and is only about 100
lines of code. The first thing it does
is set the variables of the sump pit,
like depth (72cm), critical water level
Figure 4. Finished Pit View (35cm) and GPIO pin assignments
control all sorts of equipment, like The ampersand (&) starts the script
sensors and LEDs, for example. as a background process.
You can view the GPIO code in Access to GPIO pins requires elevated
the raspisump.py script within the privileges on the Pi. To start the script
water_level() function. Similar code manually, issue the command:
is used by many other projects that
communicate with the Pi’s GPIO pins. sudo /home/pi/raspisump/raspisump.py &
Adam Lappin’s Byte Creation Blog has
a good example that helped me learn Figure 6 shows using the tail
how to use the RPi.GPIO module in command to demonstrate the
this project (see Resources). CSV file being updated in real
Raspi-Sump is started automatically time by raspisump.py.
on bootup of the Raspberry Pi by What is displayed in Figure 6 is
adding this line to /etc/rc.local right rather strange. The water depth is
before the last line exit 0 : bouncing around. You would expect
the water to be consistently higher
/home/pi/raspi-sump/raspisump.py & with each reading. The reason for
Pi renders more consistent graphs, no of PVC pipe in the sump pit and force
matter which distro you use for your the sensor to take its reading down
off-site component. the empty pipe. This will focus the
The third and final script is pulse and hide the objects in the pit
checkpid.py. Its purpose is to monitor that are causing problems.
the health of the raspisump.py process
and restart it if it is stopped. Cron Conclusion
runs the script at regular intervals and Raspi-Sump is still in the early stages
looks for one of three outcomes. If the of development. There are other
script returns 0, this indicates a failed features I would like to add, such as:
process. checkpid.py then initiates a
restart command. If the script returns Q A manual power button to start
1, the process is fine, and the script and shut down the Raspberry Pi
exits cleanly. If the number is greater gracefully without logging in.
than 1, this indicates more than one
raspisump.py process. In this instance, Q A small LCD display to show
a killall 09 raspisump.py the current water level without
directive is initiated, and the process opening the lid.
is restarted.
Q A Web-based reporting system
Other Issues with Raspi-Sump using a Python Web framework.
The HC-SR04 sensor has a fairly wide
sonar field. The user manual states Q A Web-based management
that it works best with a 30° angle. interface for Raspi-Sump on the Pi
My sump pit is a busy place. It has a (like a home router).
backup pump that sits higher than the
main pump on a 2x6 stud. Each pump Q A GSM module component to
has a float ball that bounces around use the cellular network for alerts
in the pit. This results in false readings instead of the Internet.
when the sensor picks up an object
that enters its field. This problem can Q A configuration file to store variables
be mitigated by strategically placing as opposed to within the script.
the sensor further away from these
objects. If that is not possible, you can Q Package management for
vertically insert a 3" or greater piece installation of Raspi-Sump.
Resources
Raspi-Sump Web Site: http://www.linuxnorth.org/raspi-sump
U-Boot
Environment
Variables
A close look
at the anatomy
of the
U-Boot environment.
SACHIN VERMA
So, What Is This U-Boot side shows that the variables have
Environment? been flattened and written in a
A simple answer to that question serialized form.
would be “a collection of name=value
pairs”. Here, “name” refers to the How Is the Environment Stored?
name of the environment variable U-Boot has two types of
to which you want to assign some persistent environments.
“value”. This “value” could be of any 1) Default Environment
type: string, hexadecimal, boolean and (Compiled-In, Read-Only): Every
so forth. Whatever type the value is, it U-Boot binary has a default built-in
is converted into a string before being environment of its own (Figure 2a).
stored in a linearized environment During compilation, a character array
data block. Each environment called default_environment is
variable pair (“name=value”) would embedded into the U-Boot image. This
be stored as a null-terminated character array stores the environment
string. So, the collection of many variables as a list of null-terminated
environment variables is nothing but strings with a double-null terminator.
a null-separated list with a double- The contents of this array are
null terminator. Figure 1 illustrates populated conditionally based on
how a list of strings is actually the config options selected for your
stored. The left-hand side is just a board. Environment variables that
logical representation of environment are commonly used can be enabled
variables, whereas the right-hand by defining the corresponding
Figure 3. System variables defined in your board’s config become part of the default
environment.
Figure 4. The user environment is imported into a hashtable. If the user environment is
corrupt, the default environment is imported instead.
the environment data blob. Figure from the beginning of Flash and had
10 shows my configuration file. I a size of 0x40000. The size of each
kept my environment in an SPI Flash, sector of my Flash is 0x10000. This
which appeared as /dev/mtd0 to my is all the information I needed to
kernel. My environment blob was provide in order for the environment
configured at an offset of 0x80000 manipulation utilities to work.
Resources
U-Boot Source Code: http://git.denx.de/u-boot.git
Accessing
the I/O Ports
of the
BeagleBone
Black
with Python
The BeagleBone Black is a wonderful little piece of
hardware. You could use it to send your next rocket to
Mars with just a few lines of Python.
SAMUEL BUCQUET
Q All voltage levels are 3.3V max. Application Q If voltages are generated from the
of 5V to any I/O pin will damage the VDD_5V signal, those supplies must
processor and void the warranty. not become active until after the
SYS_RESETn signal is HI.
Q Analog in voltages are 1.8V max.
Application of >1.8V to any A/D pin Q If you are applying signals from other
will damage the processor and void boards into the expansion headers,
the warranty. make sure you power up the board
after you power up the BeagleBone
Q Do not apply any voltages to any I/O pins Black or make the connections after
when the board is not powered on. power is applied on both boards.
Q Do not drive any external signals into the Q Powering the processor via its
I/O pins until after the SYS_RESETn signal I/O pins can cause damage to
is HI (3.3V). the processor.
order to enjoy more recent software. The BBB accepts booting from the
(See the Upgrading from Debian Stable internal memory, the eMMC or from
to Debian Testing sidebar.) an external SD. (See the Booting the
BBB from an SD Card sidebar.)
To test another version of the system,
Upgrading from simply download and write it on your
Debian Stable to SD. If you are satisfied with it, you have
Debian Testing the option to put it on the eMMC.
As the environment hosting our
First, update your system with apt-get BBBs is subject to strong vibrations, I
update && apt-get upgrade. chose to put my system in the eMMC
rather than on an SD.
Next, modify your /etc/apt/sources.list.d/ Flash the eMMC: In order to flash
debian.list file. Copy the lines with your new system to your eMMC,
wheezy or stable, and replace all download the flasher version from
occurrences of wheezy with jessie eLinux or the official one. Write it
on the copied lines. You can choose to your SD and boot your BBB from
testing instead of jessie if you the SD. The flashing process happens
want to keep on with the testing release automagically. You will have to wait
after jessie was made stable. less than ten minutes before the four
blue LEDs become steady, indicating
Then launch apt-get update && that the flashing is over. As the official
apt-get upgrade again, and if all firmware is much larger, the flashing
is well (it might take a long time will take a lot longer (45 minutes).
depending on your connection quality Danger: you need to power the
and the packages already installed), board with an external 5VDC power
run apt-get dist-upgrade. supply when flashing!
In order to use the armhf version,
partition and format your SD card For interfacing with a GPS with a PPS:
following the armhf site instructions
at http://www.armhf.com/boards/ # apt-get install gpsd python-gps pps-tools \
Finally, if you are isolated and date saved when the system halted.
without an RTC module, try the To DHCP or Not to DHCP: If your
fake-hwclock package from the network hosts a DHCP server, you are
Debian repositories. It will allow fine; otherwise, you can configure
your clock to restart with the last your network card “static” in order to
avoid a big DHCP timeout when you
boot your BBB with the Ethernet cable
Configuring plugged in. (See the Configuring the
Network Card Static sidebar.)
the Network Card A Life Line (Serial Debug): More
Static often than not, the boards are in a
place where we can’t have a keyboard
Edit the /etc/network/interfaces file and display attached to them. We
and change the line reading: can work remotely by SSH, but if
something goes wrong, we need to
iface eth0 inet dhcp access the serial debug interface on
the board.
to: The serial interface available
through the USB connection to the
iface eth0 inet static board is not ready when you boot
address 192.168.1.101 with U-Boot—you can’t see the kernel
netmask 255.255.255.0 starting or intervene. That’s why we
broadcast 192.168.1.255 use the serial debug provided by the
gateway 192.168.1.254 J1 connector on the board, referred to
as ttyO0 by the system.
Then restart networking with: As a side note, this serial line can
be made available via Ethernet with
/etc/init.d/networking stop a cheap RS232IP converter if remote
/etc/init.d/networking start boot monitoring is needed.
Before connecting our BBB on a
Note: if you are editing the file via SSH, PC via this serial line, we need a
you will lose your connection right now! TTLRS232 converter. See some
You should do it with a keyboard and serial debug references on
display or the serial access instead. eLinux at http://elinux.org/
Beagleboard:BeagleBone_Black_Serial.
And, make sure the kernel knows Access the Input/Output Ports
the correct console on which to The Serial Ports: As you
output its messages. In the /boot/ previously saw, the serial port
uboot/uEnv.txt file, it should read: must be accessed with a TTL/RS232
adapter. In our project, we re-used
console=ttyO0,115200n8 some old Maxim MAX3232s to
#console=tty do it, and it works, of course,
Figure 3. The Board “bbbO2” in situ with three serial ports and the serial debug
port, a temperature sensor on AIN0, a water detector on GPIO_48, a PPS input on
GPIO_49 and a POWER_RESET button.
Load the CAPE files for each UART: # dmesg |grep tty
...
The output of dmesg should show 0x481a8000 (irq = 61) is a OMAP UART4
a correct initialization:
Figure 5. Direct
Connection between
UART1 and UART4
on UART1 with screen /dev/ttyO1 check that what you type in one
115200 , split your window with a window appears in the other
Ctrl-A S, move to the next window (Figure 6).
with Ctrl-Tab, open a screen on From now on, you can use
UART4 with Ctrl-A :, then type the python-serial module to
screen /dev/ttyO4 115200 , and read and write on your serial ports,
# wget -c https://raw.github.com/RobertCNelson/\
tools/master/pkgs/dtc.sh
# chmod +x dtc.sh
# ./dtc.sh
The script will fetch the tools on-line, so if your BBB is not connected, you can compile
your dtbo file from another Linux machine.
may lack the -@ option, depending ok, found 1 source(s), now start fetching data...
The dtbo file produced will then be source 0 - assert 1391436016.956517240, sequence:\
To verify that the PPS is seen You see here a signal received at
correctly by the Linux kernel, you need 1Hz, with a timestamp jitter less
the pps-tools package installed: than 1ms.
The i2C Bus: Two i2c buses on Table 2. ds1307 Wiring on the BBB i2c_2 Bus
the BBB are available. The kernel sees
P9 ds1307
them as i2c-0 for I2C1 on P9_17(SCL)
and P9_18(SDA), and i2c-1 for I2C2 pin 1 GND
on P9_19(SCL) and P9_20(SDA). pin 5 5VCC
Add an RTC to the BBB: The pin 19 SDA
DS1307 or the DS3231 are RTC pin 20 SCL
modules with a battery keeping the
clock running when there is no power.
The ChronoDot RTC (with a ds3231) is the two 2.2k resistors (Figure 8). The
much more accurate, and the ds1307 internal resistors of the BBB i2c bus
is much less expensive. will then be used.
Wire the RTC on i2c: You can Danger: if you power the BBB over
feed the 5VDCC of the board to the USB, use P9_7 (SYS 5V) instead.
RTC module as long as you clip out Enable the New RTC: Declare the
nvram HCTOSYS_DEVICE=rtc1
#fi
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
motor with it, you then can store from smbus import SMBus
The wiring is almost identical # write to the DAC and store the value in EEPROM
# write to the DAC without storing value The vRef for the AIN is always 1.8V, so
dac.write_dac_fast(value) in order to convert our 12-bit numerical
time.sleep(0.2) value into a voltage reading, we have:
How to Read and Verify the Read AIN0 from sysfs: If the BBB
Output Voltage? The BBB has ADC kernel driver is not loaded, load
seven analog input ports named it now with:
AIN{0..6}. They are 12-bit analog
digital converters, and they accept # echo BB-ADC /sys/devices/bone_capemgr.8/slots
with two frequency/voltage converters, good RTC wired to the BBB for a
which we feed to AIN2 and AIN3 real NTP server, so choose one
(Figure 10). like the Adafruit Chronodot
The BBB as Time Server from a (http://www.adafruit.com/
GPS: What if you put together the products/255) rather than the
interface to your GPS, the NTP server simple DS1307.
of your Linux machine equipped with GPSd: Now that you know how to
an RTC and the accuracy provided handle a serial port, you can install
with the PPS signal? You can build the GPSd software. GPSd connects to
an NTP server for other CPUs in your a local GPS, as the one we wired to
network, and with good accuracy, as UART4, and serves GPS data to clients:
soon as the GPS is aligned.
Keep in mind that you need a # apt-get install gpsd python-gps gpsd-clients
listen to all network interfaces ( -G ): Python 2.7.8 (default, Jul 22 2014, 20:56:07)
START_DAEMON="true" information.
USBAUTO="false"
GPSD_SOCKET="/var/run/gpsd.sock" In [2]: gps = GPSd_client('bbb02')
print gpsdata
48.3938485,longitude=-4.505373, altitude=\
By now, your GPS is available to all 30.4, sog=0.051, cog=187.71, ept=0.005, mode=3)
OpenCPN, for example, but a rather 30.3, sog=0.067, cog=194.8, ept=0.005, mode=3)
GPS(time=u'2014-07-24T08:53:57.000Z', latitude=\
for a report with position and time fudge 127.127.22.0 flag2 0 flag3 1 refid PPS
# cd ntp-dev-4.2.7p416/ ==============================
fudge 127.127.28.0 time1 0.040 refid GPS The PRU, a Very Hot Topic
The two Programmable Realtime
# Kernel-mode PPS ref-clock for the precise seconds Units of the BBB can work
server 127.127.22.0 independently of the main CPU
Resources
You will find the source of the Python code used in this article on my GitHub account:
https://github.com/samgratte/BeagleboneBlack.
PyBBIO is a Python Library for the BBB mimicking the Arduino IO access by Alexander Hiam:
https://github.com/alexanderhiam/PyBBIO.
Of course, there is also the Python Adafruit Library, initially for the Raspberry Pi, now for
the BBB: https://github.com/adafruit/adafruit-beaglebone-io-python.
WEBCASTS
Learn the 5 Critical Success Factors to Accelerate
IT Service Delivery in a Cloud-Enabled Data Center
Today's organizations face an unparalleled rate of change. Cloud-enabled data centers are increasingly seen as a way to accelerate
IT service delivery and increase utilization of resources while reducing operating expenses. Building a cloud starts with virtualizing
your IT environment, but an end-to-end cloud orchestration solution is key to optimizing the cloud to drive real productivity gains.
> http://lnxjr.nl/IBM5factors
> http://lnxjr.nl/modsap
WHITE PAPERS
White Paper: JBoss Enterprise Application
Platform for OpenShift Enterprise
Sponsor: DLT Solutions
Red Hat’s® JBoss Enterprise Application Platform for OpenShift Enterprise offering provides IT organizations with a simple and
straightforward way to deploy and manage Java applications. This optional OpenShift Enterprise component further extends
the developer and manageability benefits inherent in JBoss Enterprise Application Platform for on-premise cloud environments.
Unlike other multi-product offerings, this is not a bundling of two separate products. JBoss Enterprise Middleware has been
hosted on the OpenShift public offering for more than 18 months. And many capabilities and features of JBoss Enterprise
Application Platform 6 and JBoss Developer Studio 5 (which is also included in this offering) are based upon that experience.
This real-world understanding of how application servers operate and function in cloud environments is now available in this
single on-premise offering, JBoss Enterprise Application Platform for OpenShift Enterprise, for enterprises looking for cloud
benefits within their own datacenters.
> http://lnxjr.nl/jbossapp
WHITE PAPERS
Linux Management with Red Hat Satellite:
Measuring Business Impact and ROI
Sponsor: Red Hat | Topic: Linux Management
Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to de-
ploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT
organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility
workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows
in importance in terms of value to the business, managing Linux environments to high standards of service quality —
availability, security, and performance — becomes an essential requirement for business success.
> http://lnxjr.nl/RHS-ROI
Benefits of an SOE:
SOE is a specification for a tested, standard selection of computer hardware, software, and their configuration for use
on computers within an organization. The modular nature of the Red Hat SOE lets you select the most appropriate
solutions to address your business' IT needs.
s 4HERE ARE MANY BENEFITS TO HAVING AN 3/% WITHIN LARGER ENVIRONMENTS SUCH AS
s 3TANDARDIZATION
> http://lnxjr.nl/RH-SOE
GNU/Linux
the Fun Way
A great “hello world” from rural Utah.
S
ometimes a gift just falls in here’s how it went.
your lap. This month, it came
in the form of an e-mail out DS: What got you going on this?
of the blue from Jared Nielsen, one
of two brothers (the other is J.R. JN: Growing up, we wanted to be
Nielsen) who created The Hello making creative media, such as
World Program, “an educational games, videos, animations, etc.,
web series making computer but in the days before the Internet,
science fun and accessible to all” training was either difficult or
(http://www.thehelloworldprogram.com). expensive to find, especially in
If it had been just that, I might not small-town Utah. We figured things
have been interested. out on our own, through trial
But when I looked at it, I saw it and error, visits to the library and
was hugely about Linux. And the countless hours watching PBS. The
human story was interesting too. Hello World Program is the show
Wrote Jared, “Working in rural Utah we wish we watched as kids.
with minimal resources, we combine
technology and craft to make DS: Do you or your brother have
educational yet entertaining videos kids yourselves?
and tutorials. Learn to code with
our cute and clever puppets.” So I JN: Neither of us have kids, but we are
said I’d like to interview them, and both kids at heart.
EmperorLinux http://www.emperorlinux.com 21
DS: Do you teach locally as well
as on-line (for example, in local Silicon Mechanics http://www.siliconmechanics.com 3