SlideShare a Scribd company logo
TinyOS programming 1st Edition Philip Levis pdf
download
https://ebookgate.com/product/tinyos-programming-1st-edition-
philip-levis/
Get Instant Ebook Downloads – Browse at https://ebookgate.com
Get Your Digital Files Instantly: PDF, ePub, MOBI and More
Quick Digital Downloads: PDF, ePub, MOBI and Other Formats
Sheep 1st Edition Philip Armstrong
https://ebookgate.com/product/sheep-1st-edition-philip-armstrong/
The Collected Poems of Philip Lamantia First Edition
Philip Lamantia
https://ebookgate.com/product/the-collected-poems-of-philip-
lamantia-first-edition-philip-lamantia/
Dear Zoe 1st Edition Edition Philip Beard
https://ebookgate.com/product/dear-zoe-1st-edition-edition-
philip-beard/
Philip Kaufman 1st Edition Edition Annette Insdorf
https://ebookgate.com/product/philip-kaufman-1st-edition-edition-
annette-insdorf/
Alec Wilder 1st Edition Edition Philip Lambert
https://ebookgate.com/product/alec-wilder-1st-edition-edition-
philip-lambert/
Valode Pistre Architects 1st Edition Philip Jodidio
https://ebookgate.com/product/valode-pistre-architects-1st-
edition-philip-jodidio/
Computer Programming 1st Edition E. Balagurusamy
https://ebookgate.com/product/computer-programming-1st-edition-e-
balagurusamy/
Carbon Programming 1st Edition Kevin Bricknell
https://ebookgate.com/product/carbon-programming-1st-edition-
kevin-bricknell/
Programming Clojure 1st Edition Stuart Halloway
https://ebookgate.com/product/programming-clojure-1st-edition-
stuart-halloway/
TinyOS programming 1st Edition Philip Levis
This page intentionally left blank
TinyOS Programming
Do you need to know how to write systems, services, and applications using the TinyOS
operating system? Learn how to write nesC code and efficient applications with this
indispensable guide to TinyOS programming.
Detailed examples show you how to write TinyOS code in full, from basic applications
right up to new low-level systems and high-performance applications. Two leading
figures in the development of TinyOS also explain the reasons behind many of the
design decisions made and explain for the first time how nesC relates to and differs
from other C dialects. Handy features such as a library of software design patterns,
programming hints and tips, end-of-chapter exercises, and an appendix summarizing
the basic application-level TinyOS APIs make this the ultimate guide to TinyOS for
embedded systems programmers, developers, designers, and graduate students.
Philip Levis is Assistant Professor of Computer Science and Electrical Engineering at
Stanford University. A Fellow of the Microsoft Research Faculty, he is also Chair of the
TinyOS Core Working Group and a Member of the TinyOS Network Protocol (net2),
Simulation (sim), and Documentation (doc) Working Groups.
David Gay joined Intel Research in Berkeley in 2001, where he has been a designer
and the principal implementer of the nesC language, the C dialect used to implement
the TinyOS sensor network operating system, and its applications. He has a diploma in
Computer Science from the Swiss Federal Institute of Technology in Lausanne and a
Ph.D. from the University of California, Berkeley.
TinyOS programming 1st Edition Philip Levis
TinyOS Programming
PHILIP LEVIS
Stanford University
and
DAVID GAY
Intel Research
CAMBRIDGE UNIVERSITY PRESS
Cambridge, New York, Melbourne, Madrid, Cape Town, Singapore, São Paulo
Cambridge University Press
The Edinburgh Building, Cambridge CB2 8RU, UK
First published in print format
ISBN-13 978-0-521-89606-1
ISBN-13 978-0-511-50730-4
© Cambridge University Press 2009
2009
Information on this title: www.cambridge.org/9780521896061
This publication is in copyright. Subject to statutory exception and to the
provision of relevant collective licensing agreements, no reproduction of any part
may take place without the written permission of Cambridge University Press.
Cambridge University Press has no responsibility for the persistence or accuracy
of urls for external or third-party internet websites referred to in this publication,
and does not guarantee that any content on such websites is, or will remain,
accurate or appropriate.
Published in the United States of America by Cambridge University Press, New York
www.cambridge.org
eBook (EBL)
paperback
Contents
List of Code examples page xi
Preface xvii
Acknowledgements xix
Programming hints, condensed xxi
Part I TinyOS and nesC 1
1 Introduction 3
1.1 Networked, embedded sensors 3
1.1.1 Anatomy of a sensor node (mote) 4
1.2 TinyOS 5
1.2.1 What TinyOS provides 6
1.3 Example application 7
1.4 Compiling and installing applications 8
1.5 The rest of this book 8
2 Names and program structure 10
2.1 Hello World! 10
2.2 Essential differences: components, interfaces, and wiring 13
2.3 Wiring and callbacks 15
2.4 Summary 16
Part II Basic programming 19
3 Components and interfaces 21
3.1 Component signatures 21
3.1.1 Visualizing components 22
3.1.2 The “as” keyword and clustering interfaces 23
3.1.3 Clustering interfaces 24
3.2 Interfaces 24
3.2.1 Generic interfaces 27
3.2.2 Bidirectional interfaces 28
vi Contents
3.3 Component implementations 29
3.3.1 Modules 30
3.3.2 A basic configuration 31
3.3.3 Module variables 32
3.3.4 Generic components 33
3.4 Split-phase interfaces 34
3.4.1 Read 36
3.4.2 Send 36
3.5 Module memory allocation, avoiding recursion, and other details 36
3.5.1 Memory ownership and split-phase calls 38
3.5.2 Constants and saving memory 41
3.5.3 Platform-independent types 42
3.5.4 Global names 44
3.5.5 nesC and the C preprocessor 46
3.5.6 C libraries 47
3.6 Exercises 48
4 Configurations and wiring 49
4.1 Configurations 50
4.1.1 The −> and <− operators 51
4.1.2 The = operator 52
4.1.3 Namespace management 53
4.1.4 Wiring rules 54
4.1.5 Wiring shortcuts 56
4.2 Building abstractions 57
4.2.1 Component naming 58
4.2.2 Component initialization 59
4.3 Component layering 60
4.3.1 Extensibility 61
4.3.2 Hardware specificity 61
4.4 Multiple wirings 63
4.4.1 Fan-in and fan-out 64
4.4.2 Uses of multiple wiring 65
4.4.3 Combine functions 66
4.5 Generics versus singletons 68
4.5.1 Generic components, revisited 68
4.5.2 Singleton components, revisited 70
4.6 Exercises 70
5 Execution model 71
5.1 Overview 71
5.2 Tasks 72
5.2.1 Task timing 74
Contents vii
5.2.2 Timing and event handlers 75
5.3 Tasks and split-phase calls 75
5.3.1 Hardware versus software 75
5.3.2 Tasks and call loops 76
5.4 Exercises 78
6 Applications 79
6.1 The basics: timing, LEDs, and booting 79
6.1.1 Deadline-based timing 81
6.1.2 Wiring AntiTheftC 83
6.2 Sensing 83
6.2.1 Simple sampling 84
6.2.2 Sensor components 85
6.2.3 Sensor values, calibration 86
6.2.4 Stream sampling 87
6.3 Single-hop networking 89
6.3.1 Sending packets 90
6.3.2 Receiving packets 93
6.3.3 Selecting a communication stack 94
6.4 Multi-hop networking: collection, dissemination, and base stations 95
6.4.1 Collection 96
6.4.2 Dissemination 97
6.4.3 Wiring collection and dissemination 97
6.4.4 Base station for collection and dissemination 98
6.5 Storage 101
6.5.1 Volumes 102
6.5.2 Configuration data 103
6.5.3 Block and Log storage 105
6.6 Exercises 111
7 Mote-PC communication 112
7.1 Basics 112
7.1.1 Serial communication stack 113
7.2 Using mig 114
7.2.1 Sending and receiving mig-generated packets 116
7.3 Using ncg 118
7.4 Packet sources 119
7.5 Example: simple reliable transmission 120
7.5.1 Reliable transmission protocol 121
7.5.2 Reliable transmission in Java 121
7.5.3 Reimplementing TestSerial 125
7.6 Exercises 125
viii Contents
Part III Advanced programming 127
8 Advanced components 129
8.1 Generic components review 129
8.2 Writing generic modules 131
8.2.1 Type arguments 132
8.2.2 Abstract data types as generics 133
8.2.3 ADTs in TinyOS 1.x 134
8.3 Parameterized interfaces 135
8.3.1 Parameterized interfaces and configurations 137
8.3.2 Parameterized interfaces and modules 139
8.3.3 Defaults 141
8.4 Attributes 142
8.5 Exercises 144
9 Advanced wiring 145
9.1 unique() and uniqueCount() 145
9.1.1 unique 146
9.1.2 uniqueCount 147
9.1.3 Example: HilTimerMilliC and VirtualizeTimerC 147
9.2 Generic configurations 150
9.2.1 TimerMilliC 150
9.2.2 CC2420SpiC 152
9.2.3 AMSenderC 156
9.2.4 BlockStorageC 160
9.3 Reusable component libraries 162
9.4 Exercises 165
10 Design patterns 166
10.1 Behavioral: Dispatcher 166
10.2 Structural: Service Instance 170
10.3 Namespace: Keyspace 174
10.4 Namespace: Keymap 177
10.5 Structural: Placeholder 180
10.6 Structural: Facade 183
10.7 Behavioral: Decorator 186
10.8 Behavioral: Adapter 189
11 Concurrency 192
11.1 Asynchronous code 192
11.1.1 The async keyword 192
11.1.2 The cost of async 193
11.1.3 Atomic statements and the atomic keyword 195
Contents ix
11.1.4 Managing state transitions 197
11.1.5 Example: CC2420ControlP 197
11.1.6 Tasks, revisited 199
11.2 Power locks 200
11.2.1 Example lock need: link-layer acknowledgements 200
11.2.2 Split-phase locks 201
11.2.3 Lock internals 202
11.2.4 Energy management 203
11.2.5 Hardware configuration 204
11.2.6 Example: MSP430 USART 204
11.2.7 Power lock library 205
11.3 Exercises 205
12 Device drivers and the hardware abstraction architecture (HAA) 206
12.1 Portability and the hardware abstraction architecture 206
12.1.1 Examples 208
12.1.2 Portability 210
12.2 Device drivers 210
12.2.1 Access control 211
12.2.2 Access control examples 212
12.2.3 Power management 215
12.2.4 Microcontroller power management 218
12.3 Fitting in to the HAA 219
13 Advanced application: SoundLocalizer 221
13.1 SoundLocalizer design 221
13.1.1 Time synchronization 222
13.1.2 Implementing SoundLocalizer in TinyOS 223
13.2 SynchronizerC 225
13.3 DetectorC 230
13.4 MicrophoneC 233
13.5 Wrap-up 237
Part IV Appendix and references 239
A TinyOS APIs 241
A.1 Booting 241
A.2 Communication 241
A.2.1 Single-hop 242
A.2.2 Multi-hop collection 243
A.2.3 Multi-hop dissemination 244
A.2.4 Binary reprogramming 245
A.3 Time 245
A.4 Sensing 245
x Contents
A.5 Storage 246
A.6 Data structures 247
A.6.1 BitVectorC 247
A.6.2 QueueC 247
A.6.3 BigQueueC 248
A.6.4 PoolC 248
A.6.5 StateC 249
A.7 Utilities 249
A.7.1 Random numbers 249
A.7.2 Leds 249
A.7.3 Cyclic redundancy checks 250
A.7.4 Printf 250
A.8 Low power 251
References 252
Index 254
Code examples
2.1 Powerup in C page 10
2.2 PowerupC module in nesC 11
2.3 Simple nesC interfaces 11
2.4 PowerupAppC configuration in nesC 12
2.5 Powerup with blinking LED in C 15
2.6 Powerup with blinking LED in nesC (slightly simplified) 15
2.7 Powerup with blinking LED configuration (slightly simplified) 16
3.1 The signature and implementation blocks 21
3.2 Signatures of PowerupC and LedsC 22
3.3 MainC’s signature 22
3.4 The LedsP module 23
3.5 PowerupC and an alternative signature 24
3.6 Interface declarations for Leds and Boot 25
3.7 The Init and Boot interfaces 25
3.8 Signatures of MainC and PowerupC 26
3.9 The Queue interface 27
3.10 Using a queue of 32-bit integers 27
3.11 Providing a 16-bit or a 32-bit queue 27
3.12 The Notify interface 28
3.13 UserButtonC 28
3.14 Simplified Timer interface showing three commands and one event 29
3.15 PowerupC module code 30
3.16 The module PowerupToggleC 30
3.17 The PowerupToggleAppC configuration 31
3.18 Example uses of the components keyword 31
3.19 The Get interface 32
3.20 A self-incrementing counter 32
3.21 Generic module SineSensorC and generic configuration TimerMilliC 33
3.22 Instantiating a generic component 34
3.23 Signature of BitVectorC 34
3.24 QueueC signature 34
3.25 The Read interface 36
3.26 The split-phase Send interface 36
3.27 The Send interface 38
xii List of code examples
3.28 The Receive interface 39
3.29 The signature of PoolC 41
3.30 CC2420 packet header 42
3.31 The dreaded “packed” attribute in the 1.x MintRoute library 43
3.32 The CC2420 header 44
3.33 TinyError.h, a typical nesC header file 45
3.34 Including a header file in a component 45
3.35 Indirectly including a header file 46
3.36 Fancy.nc: C preprocessor example 46
3.37 FancyModule.nc: C preprocessor pitfalls 47
3.38 Fancy.h: the reliable way to use C preprocessor symbols 47
3.39 Using a C library function 47
4.1 Signature of part of the CC1000 radio stack 49
4.2 The PowerupToggleAppC configuration revisited 51
4.3 C code generated from the PowerupToggleAppC configuration 51
4.4 The LedsC configuration 52
4.5 CC2420ReceiveC’s use of the as keyword 53
4.6 Naming generic component instances 54
4.7 MainC and LedsP 55
4.8 Valid alternate of PowerupToggleAppC 55
4.9 Invalid alternate of PowerupToggleAppC 55
4.10 LedsC revisited 56
4.11 BlinkC signature 56
4.12 The RandomC configuration 57
4.13 The RandomMlcgC signature 58
4.14 Seed initialization in RandomMlcgP 59
4.15 ActiveMessageC for the CC2420 61
4.16 The signature of CC2420ActiveMessageC 62
4.17 Fan-out on CC2420TransmitC’s Init 63
4.18 StdControl and SplitControl initialization interfaces 64
4.19 Why the metaphor of “wires” is only a metaphor 65
4.20 The combine function for error_t 66
4.21 Fan-out on SoftwareInit 67
4.22 Resulting code from fan-out on SoftwareInit 67
4.23 AMSenderC signature 68
4.24 RadioCountToLedsAppC 68
4.25 PoolC 69
4.26 Exposing a generic component instance as a singleton 70
5.1 The main TinyOS scheduling loop from SchedulerBasicP.nc 72
5.2 A troublesome implementation of a magnetometer sensor 76
5.3 Signal handler that can lead to an infinite loop 77
5.4 An improved implementation of FilterMagC 77
6.1 Anti-theft: simple flashing LED 80
6.2 The Leds interface 80
List of code examples xiii
6.3 The Boot interface 81
6.4 The full Timer interface 81
6.5 WarningTimer.fired with drift problem fixed 82
6.6 Anti-Theft: application-level configuration 83
6.7 The Read interface 84
6.8 Anti-theft: detecting dark conditions 84
6.9 Anti-Theft: wiring to light sensor 86
6.10 ReadStream Interface 87
6.11 Anti-theft: detecting movement 88
6.12 The AMSend interface 90
6.13 Anti-Theft: reporting theft over the radio 91
6.14 The SplitControl interface 92
6.15 The Receive interface 93
6.16 Anti-Theft: changing settings 93
6.17 Serial vs Radio-based AM components 94
6.18 The Send interface 96
6.19 Anti-Theft: reporting theft over a collection tree 96
6.20 DisseminationValue interface 97
6.21 Anti-Theft: settings via a dissemination tree 97
6.22 The StdControl interface 97
6.23 The DisseminationUpdate interface 99
6.24 AntiTheft base station code: disseminating settings 99
6.25 The RootControl interface 100
6.26 AntiTheft base station code: reporting thefts 101
6.27 AntiTheft base station wiring 101
6.28 ConfigStorageC signature 102
6.29 Mount interface for storage volumes 103
6.30 ConfigStorage interface 103
6.31 Anti-Theft: reading settings at boot time 104
6.32 Anti-Theft: saving configuration data 105
6.33 BlockStorageC signature 106
6.34 The BlockWrite interface 106
6.35 Simultaneously sampling and storing to flash
(most error checking omitted) 108
6.36 The BlockRead interface 108
6.37 LogStorageC signature 108
6.38 The LogWrite interface 109
6.39 The LogWrite interface 110
6.40 The LogRead interface 111
7.1 Serial AM Packet layout 113
7.2 TestSerial packet layout 114
7.3 Backing array methods 115
7.4 Sending packets with mig and MoteIF 117
7.5 Interface for handling received packets 117
xiv List of code examples
7.6 Receiving packets with mig and MoteIF 117
7.7 Constants and packet layout for Oscillscope application 118
7.8 Class generated by ncg 119
7.9 Simplified code to save received samples 119
7.10 Reliable transmission protocol in Java – transmission 121
7.11 Reliable transmission protocol in Java – transmission 123
7.12 A reliable TestSerial.java 125
8.1 Instantiation within a generic configuration 130
8.2 The fictional component SystemServiceVectorC 131
8.3 QueueC excerpt 131
8.4 A generic constant sensor 132
8.5 Queue interface (repeated) 133
8.6 QueueC implementation 133
8.7 Representing an ADT through an interface in TinyOS 1.x 135
8.8 Timers without parameterized interfaces 135
8.9 Timers with a single interface 136
8.10 HilTimerMilliC signature 137
8.11 ActiveMessageC signature 138
8.12 Signature of TestAMC 138
8.13 Wiring TestAMC to ActiveMessageC 138
8.14 A possible module underneath ActiveMessageC 139
8.15 Parameterized interface syntax 140
8.16 Dispatching on a parameterized interface 140
8.17 How active message implementations decide on whether
to signal to Receive or Snoop 140
8.18 Defining a parameter 141
8.19 Wiring full parameterized interface sets 141
8.20 Default events in an active message implementation 142
8.21 nesC attributes 143
9.1 Partial HilTimerMilliC signature 146
9.2 VirtualizeTimerC 148
9.3 Instantiating VirtualizeTimerC 148
9.4 VirtualizeTimerC state allocation 149
9.5 The TimerMilliC generic configuration 151
9.6 TimerMilliP auto-wires HilTimerMilliC to Main.SoftwareInit 151
9.7 The Blink application 151
9.8 The full module-to-module wiring chain in Blink (BlinkC to
VirtualizeTimerC) 152
9.9 CC2420SpiC 153
9.10 CC2420SpiP 154
9.11 CC2420SpiC mappings to CC2420SpiP 154
9.12 The strobe implementation 155
9.13 The AMSenderC generic configuration 158
9.14 AMSendQueueEntryP 159
List of code examples xv
9.15 AMQueueP 159
9.16 AMSendQueueImplP pseudocode 160
9.17 BlockStorageC 161
9.18 The full code of HilTimerMilliC 163
9.19 VirtualizeTimerC virtualizes a single timer 164
10.1 AMReceiverC 169
10.2 VirtualizeTimerC 172
10.3 Telos ActiveMessageC 181
10.4 The Matchbox facade 184
10.5 The CC2420CsmaC uses a Facade 185
10.6 AlarmToTimerC implementation 190
11.1 The Send interface 192
11.2 The Leds interface 193
11.3 Toggling a state variable 193
11.4 A call sequence that could corrupt a variable 194
11.5 State transition that is not async-safe 194
11.6 Incrementing with an atomic statement 195
11.7 Incrementing with two independent atomic statements 195
11.8 The first step of starting the CC2420 radio 198
11.9 The handler that the first step of starting the CC2420 is complete 198
11.10 The handler that the second step of starting the CC2420 is complete 198
11.11 The handler that the third step of starting the CC2420 radio is complete 199
11.12 State transition so components can send and receive packets 199
11.13 The Resource interface 201
11.14 Msp430Spi0C signature 202
11.15 Msp320Adc12ClientC signature 202
11.16 The ResourceDefaultOwner interface 203
11.17 The ResourceConfigure interface 204
12.1 ActiveMessageC signature 212
12.2 Arbitration in Stm25pSectorC 215
12.3 McuSleepC: platform-specific sleep code 218
13.1 SynchronizerC: time synchronization for SoundLocalizer 225
13.2 The Counter interface 226
13.3 DetectorC: loud sound detection for SoundLocalizer 231
13.4 The Alarm interface 231
13.5 Atm128AdcSingle: low-level single-sample ATmega128 A/D
converter interface 232
13.6 The GeneralIO digital I/O pin interface 235
13.7 The I2CPacket interface for bus masters 236
TinyOS programming 1st Edition Philip Levis
Preface
This book provides an in-depth introduction to writing nesC code for the TinyOS
2.0 operating system. While it goes into greater depth than the TinyOS tutorials on
this subject, there are several topics that are outside its scope, such as the structure
and implementation of radio stacks or existing TinyOS libraries. It focuses on how
to write nesC code, and explains the concepts and reasons behind many of the
nesC and TinyOS design decisions. If you are interested in a brief introduction to
TinyOS programming, then you should probably start with the tutorials. If you’re
interested in details on particular TinyOS subsystems you should probably consult TEPs
(TinyOSEnhancementProposals),whichdetailthecorrespondingdesignconsiderations,
interfaces, and components. Both of these can be found in the doc/html directory of
a TinyOS distribution.
While some of the contents of this book are useful for 1.x versions of TinyOS , they
do have several differences from TinyOS 2.0 which can lead to different programming
practices. If in doubt, referring to the TEP on the subject is probably the best bet, as TEPs
often discuss in detail the differences between 1.x and 2.0.
For someone who has experience with C or C++, writing simple nesC programs is
fairly straightforward: all you need to do is implement one or two modules and wire
them together. The difficulty (and intellectual challenge) comes when building larger
applications. The code inside TinyOS modules is fairly analogous to C coding, but
configurations – which stitch together components – are not.
This book is a first attempt to explain how nesC relates to and differs from other C
dialects, stepping through how the differences lead to very different coding styles and
approaches. As a starting point, this book assumes that
1. you know C, C++, or Java reasonably well, understand pointers and that
2. you have taken an undergraduate level operating systems class (or equivalent) and
know about concurrency, interrupts, and preemption.
Of course, this book is as much a description of nesC as it is an argument for a particular
way of using the language to achieve software engineering goals. In this respect, it is the
product of thousands of hours of work by many people, as they learned and explored the
use of the language. In particular, Cory Sharp, Kevin Klues, and Vlado Handziski have
always pushed the boundaries of nesC programming in order to better understand which
practices lead to the simplest, most efficient, and robust code. In particular, Chapter 10
xviii Preface
is an edited version of a paper we wrote together, while using structs as a compile-time
checking mechanism in interfaces (as Timer does) is an approach invented by Cory.
This book is divided into four parts. The first part, Chapters 1–2, gives a high-level
overviewofTinyOSandthenesClanguage.Thesecondpart,Chapters3–7goesintonesC
and TinyOS at a level sufficient for writing applications. The third part, Chapters 8–13
goes into more advanced TinyOS and nesC programming, as is sometimes needed when
writing new low-level systems or high performance applications. The book ends with
an appendix summarizing the basic application-level TinyOS APIs.
Acknowledgements
We’dliketothankseveralpeoplefortheircontributionstothisbook.FirstisMikeHorton,
of Crossbow, Inc., who first proposed writing it. Second is Pablo Guerrero, who gave
detailed comments and corrections. Third is Joe Polastre of Moteiv, who gave valuable
feedbackonhowtobetterintroducegenericcomponents.Fourth,we’dliketothankPhil’s
father, who although he doesn’t program, read the entire thing! Fifth, John Regehr, Ben
Greenstein and David Culler provided valuable feedback on this expanded edition. Last
but not least, we would like to thank the TinyOS community and its developers. Many
of the concepts in this book – power locks, tree routing, and interface type checking –
are the work and ideas of others, which we merely present.
Chapter 10 of this book is based on: Software design patterns for TinyOS, in ACM
Transactions on Embedded Computing Systems (TECS), Volume 6, Issue 4 (September
2007), ©ACM, 2007. http://doi.acm.org/10.1145/1274858.1274860
TinyOS programming 1st Edition Philip Levis
Programming hints, condensed
Programming Hint 1 Use the “as” keyword liberally. (page 24)
Programming Hint 2 Never write recursive functions within a module. In combination
with the TinyOS coding conventions, this guarantees that all programs have bounded
stack usage. (page 38)
Programming Hint 3 Never use malloc and free. Allocate all state in components. If
your application requirements necessitate a dynamic memory pool, encapsulate it in a
component and try to limit the set of users. (page 38)
Programming Hint 4 When possible, avoid passing pointers across interfaces; when
this cannot be avoided only one component should be able to modify a pointer’s data at
any time. (page 39)
Programming Hint 5 Conserve memory by using enums rather than const variables for
integer constants, and don’t declare variables with an enum type. (page 42)
Programming Hint 6 Never, ever use the “packed” attribute in portable code. (page 43)
Programming Hint 7 Use platform-independent types when defining message
structures. (page 44)
Programming Hint 8 If you have to perform significant computation on a
platform-independent type or access it many (hundreds or more) times, temporarily
copy it to a native type. (page 44)
Programming Hint 9 Interfaces should #include the header files for the types they use.
(page 46)
Programming Hint 10 Always #define a preprocessor symbol in a header file. Use
#include to load the header file in all components and interfaces that use the symbol.
(page 47)
Programming Hint 11 If a component is a usable abstraction by itself, its name should
end with C. If it is intended to be an internal and private part of a larger abstraction,
its name should end with P. Never wire to P components from outside your package
(directory). (page 58)
Programming Hint 12 Auto-wire Init to MainC in the top-level configuration of a
software abstraction. (page 60)
Programming Hint 13 When using layered abstractions, components should not wire
across multiple abstraction layers: they should wire to a single layer. (page 63)
Programming Hint 14 Never ignore combine warnings. (page 68)
xxii Programming hints, condensed
Programming Hint 15 Keep tasks short. (page 74)
Programming Hint 16 If an event handler needs to make possibly long-executing
command calls, post a task to make the calls. (page 75)
Programming Hint 17 Don’t signal events from commands – the command should post
a task that signals the event. (page 77)
Programming Hint 18 Use a parameterized interface when you need to distinguish
callers or when you have a compile-time constant parameter. (page 141)
Programming Hint 19 If a component depends on unique, then #define the string to
use in a header file, to prevent bugs due to string typos. (page 149)
Programming Hint 20 Whenever writing a module, consider making it more
general-purpose and generic. In most cases, modules must be wrapped by configurations
to be useful, so singleton modules have few advantages. (page 165)
Programming Hint 21 Keep code synchronous when you can. Code should be async
only if its timing is very important or if it might be used by something whose timing is
important. (page 195)
Programming Hint 22 Keep atomic statements short, and have as few of them as
possible. Be careful about calling out to other components from within an atomic
statement. (page 199)
Part I
TinyOS and nesC
TinyOS programming 1st Edition Philip Levis
1 Introduction
This book is about writing TinyOS systems and applications in the nesC language. This
chapter gives a brief overview ofTinyOS and its intended uses.TinyOS is an open-source
project which a large number of research universities and companies contribute to.
The main TinyOS website, www.tinyos.net, has instructions for downloading and
installing the TinyOS programming environment. The website has a great deal of useful
information which this book doesn’t cover, such as common hardware platforms and
how to install code on a node.
1.1 Networked, embedded sensors
TinyOS is designed to run on small, wireless sensors. Networks of these sensors have the
potential to revolutionize a wide range of disciplines, fields, and technologies. Recent
example uses of these devices include:
Golden Gate Bridge safety High-speed accelerometers collect synchonized data on
the movement of and oscillations within the structure of San Francisco’s Golden Gate
Bridge. This data allows the maintainers of the bridge to easily observe the structural
health of the bridge in response to events such as high winds or traffic, as well as quickly
assess possible damage after an earthquake [10]. Being wireless avoids the need for
installing and maintaining miles of wires.
Volcanic monitoringAccelerometers and microphones observe seismic events on the
Reventador and Tungurahua volcanoes in Ecuador. Nodes locally compare when they
observe events to determine their location, and report aggregate data to a camp several
kilometers away using a long-range wireless link. Small, wireless nodes allow geologists
and geophysicists to install dense, remote scientific instruments [30], obtaining data that
answers other questions about unapproachable environments.
Data center provisioning Data centers and enterprise computing systems require
huge amounts of energy, to the point at which they are placed in regions that have low
power costs. Approximately 50% of the energy in these systems goes into cooling, in
part due to highly conservative cooling systems. By installing wireless sensors across
machine racks, the data center can automatically sense what areas need cooling and
can adjust which computers do work and generate heat [19]. Dynamically adapting
4 Introduction
patch of sensors data sink gateway Internet
sensor code
(nesC/TinyOS)
base station code
(nesC/TinyOS)
gateway code
(Java, C, ...)
Figure 1.1 A typical sensor network architecture. Patches of ultra-low power sensors, running
nesC/TinyOS, communicate to gateway nodes through data sinks. These gateways
connect to the larger Internet.
these factors can greatly reduce power consumption, making the IT infrastructure more
efficient and reducing environmental impact.
While these three application domains are only a small slice of where networks
of sensors are used, they show the key differences between these networks and most
other computing systems. First, these “sensor networks” need to operate unattended for
long periods of time. Second, they gather data from and respond to an unpredictable
environment. Finally, for reasons of cost, deployment simplicity, and robustness,
they are wireless. Together, these three issues – longevity, embedment, and wireless
communication – cause sensor networks to use different approaches than traditional,
wired, and human-centric or machine-centric systems.
The sheer diversity of sensor network applications means that there are many network
architectures, but a dominant portion of deployments tend to follow a common one,
shown in Figure 1.1 [21, 26, 30] of ultra-low power sensors self-organized to form an
ad-hoc routing network to one or more data sink nodes. These sensor sinks are attached to
gateways, which are typically a few orders of magnitude more powerful than the sensors:
gateways run an embedded form of Linux, Windows, or other multitasking operating
system. Gateways have an Internet connection, either through a cell phone network,
long-distance wireless, or even just wired Ethernet.
Energy concerns dominate sensor hardware and software design. These nodes need to
be wireless, small, low-cost, and operate unattended for long periods. While it is often
possible to provide large power resources, such as large solar panels, periodic battery
replacement, or wall power, to small numbers of gateways, doing so to every one of
hundreds of sensors is infeasible.
1.1.1 Anatomy of a sensor node (mote)
Since energy consumption determines sensor node lifetime, sensor nodes, commonly
referred to as motes, tend to have very limited computational and communication
resources. Instead of a full-fledged 32-bit or 64-bit CPU with megabytes or gigabytes of
RAM, they have 8-bit or 16-bit microcontrollers with a few kilobytes of RAM. Rather
than gigahertz, these microcontrollers run at 1–10 megahertz. Their low-power radios
1.2 TinyOS 5
Antenna Radio Circuitry USB Serial
Expansion
Connector
Sensors
Figure 1.2 A Telos sensor produced by Moteiv. The top of the node has the radio, sensors, and circuitry for
the USB connector. The bottom, not shown, has the processor and flash storage chip. The
antenna is part of the printed circuit board (PCB).
can send tens to hundreds of kilobits per second (kbps), rather than 802.11’s tens of
megabits. As a result, software needs to be very efficient, both in terms of CPU cycles
and in terms of memory use.
Figure 1.2 shows a sample node platform, the Telos , which is designed for easy
experimentation and low-power operation. It has a TI MSP430 16-bit microcontroller
with 10 kB of RAM and 48 kB of flash program memory. Its radio, a TI CC2420 which
follows the IEEE 802.15.4 standard, can send up to 250 kbps. In terms of power, the
radio dominates the system: on a pair of AA batteries, a Telos can have the radio on for
about four days. Lasting longer than four days requires keeping the node in a deep sleep
state most of the time, waking only when necessary, and sleeping as soon as possible.
Theothermotediscussedinthisbook,themicazfromCrossbowTechnologyissimilar:
it has an Atmel ATmega128 8-bit microcontroller with 4 kB of RAM, 128 kB of flash
program memory, uses the same CC2420 radio chip, also runs off a pair of AA batteries
and has a similar power consumption profile.
Networks, once deployed, gather data uninterrupted for weeks, months, or years.
As the placement of sensors is very application-specific, it is rare for networks to
need to support multiple concurrent applications, or even require more than the
occasional reprogramming. Therefore, unlike general-purpose computing systems,
which emphasize run-time flexibility and composability, sensor network systems tend
to be highly optimized. Often, the sensor suite itself is selected for the specific
application:volcanicmonitoringusesaccelerometersandmicrophones,whiledatacenter
provisioning uses temperature sensors.
1.2 TinyOS
TinyOS is a lightweight operating system specifically designed for low-power wireless
sensors. TinyOS differs from most other operating systems in that its design focuses
on ultra low-power operation. Rather than a full-fledged processor, TinyOS is designed
6 Introduction
for the small, low-power microcontrollers motes have. Furthermore, TinyOS has very
aggressive systems and mechanisms for saving power.
TinyOS makes building sensor network applications easier. It provides a set of
importantservicesandabstractions,suchassensing,communication,storage,andtimers.
It defines a concurrent execution model, so developers can build applications out of
reusable services and components without having to worry about unforeseen interactions.
TinyOS runs on over a dozen generic platforms, most of which easily support adding
new sensors. Furthermore, TinyOS’s structure makes it reasonably easy to port to new
platforms.
TinyOS applications and systems, as well as the OS itself, are written in the nesC
language. nesC is a C dialect with features to reduce RAM and code size, enable
significant optimizations, and help prevent low-level bugs like race conditions. Chapter 2
goes into the details on how nesC differs significantly from other C-like languages, and
most of this book is about how to best use those features to write robust, efficient code.
1.2.1 What TinyOS provides
At a high level, TinyOS provides three things to make writing systems and applications
easier:
• a component model, which defines how you write small, reusable pieces of code and
compose them into larger abstractions;
• a concurrent execution model, which defines how components interleave their
computations as well as how interrupt and non-interrupt code interact;
• application programming interfaces (APIs), services, component libraries and an
overall component structure that simplify writing new applications and services.
The component model is grounded in nesC. It allows you to write pieces of reusable
code which explicitly declare their dependencies. For example, a generic user button
component that tells you when a button is pressed sits on top of an interrupt handler. The
component model allows the button implementation to be independent of which interrupt
that is – e.g. so it can be used on many different hardware platforms – without requiring
complex callbacks or magic function naming conventions. Chapter 2 and Chapter 3
describe the basic component model.
TheconcurrentexecutionmodelenablesTinyOStosupportmanycomponentsneeding
to act at the same time while requiring little RAM. First, every I/O call in TinyOS is
split-phase: rather than block until completion, a request returns immediately and the
caller gets a callback when the I/O completes. Since the stack isn’t tied up waiting
for I/O calls to complete, TinyOS only needs one stack, and doesn’t have threads.
Instead, Chapter 5 introduces tasks, which are lightweight deferred procedure calls. Any
component can post a task, whichTinyOS will run at some later time. Because low-power
devices must spend most of their time asleep, they have low CPU utilization and so in
practice tasks tend to run very soon after they are posted (within a few milliseconds).
Furthermore, because tasks can’t preempt each other, task code doesn’t need to worry
about data races. Low-level interrupt code (discussed in the advanced concurrency
1.3 Example application 7
chapter, Chapter 11) can have race conditions, of course: nesC detects possible data
races at compile-time and warns you.
Finally, TinyOS itself has a set of APIs for common functionality, such as sending
packets, reading sensors, and responding to events. Uses of these are sprinkled
throughpout the entire book, and presented in more detail in Chapter 6 and Appendix 1.
In addition to programming interfaces, TinyOS also provides a component structure and
component libraries. For example, Chapter 12 describes TinyOS’s HardwareAbstraction
Architecture (HAA), which defines how to build up from low-level hardware (e.g. a
radio chip) to a hardware-independent abstraction (e.g. sending packets). Part of this
component structure includes resource locks, covered in Chapter 11, which enable
automatic low-power operation, as well as the component libraries that simplify writing
such locks.
TinyOS itself is continually evolving. Within the TinyOS community, “Working
Groups” form to tackle engineering and design issues within the OS, improving existing
services and adding new ones. This book is therefore really a snapshot of the OS in
time. As Chapter 12 discusses and Appendix 1 presents, TinyOS has a set of standard,
stable APIs for core abstractions, but this set is always expanding as new hardware and
applications emerge. The best way to stay up to date with TinyOS is to check its web page
www.tinyos.net and participate in its mailing lists. The website also covers advanced
TinyOS and nesC features which are well beyond the scope of this book, including
binary components, over-the-air reprogramming services, debugging tools, and a nesC
reference manual.
1.3 Example application
To better understand the unique challenges faced by sensor networks, we walk through a
basic data-collection application. Nodes running this application periodically wake up,
sample some sensors, and send the data through an ad hoc collection tree to a data sink
(as in Figure 1.1). As the network must last for a year, nodes spend 99% of their time in
a deep sleep state.
In terms of energy, the radio is by far the most expensive part of the node. Lasting a year
requires telling the radio to be in a low power state. Low power radio implementation
techniques are beyond the scope of this book, but the practical upshot is that packet
transmissions have higher latency. [23]
Figure 1.3 shows the four TinyOS APIs the application uses: low power settings for
the radio, a timer, sensors, and a data collection routing layer. When TinyOS tells the
application that the node has booted, the application code configures the power settings
on the radio and starts a periodic timer. Every few minutes, this timer fires and the
application code samples its sensors. It puts these sensor values into a packet and calls
the routing layer to send the packet to a data sink. In practice, applications tend to be
more complex than this simple example. For example, they include additional services
such as a management layer which allows an administrator to reconfigure parameters
and inspect the state of the network, as well as over-the-air programming so the network
8 Introduction
Application
Timer Routing
Sensors Radio
Figure 1.3 Example application architecture. Application code uses a timer to act periodically, sensors to
collect data, and a routing layer to deliver data to a sink.
can be reprogrammed without needing to collect all of the nodes. However, these four
abstractions – power control, timers, sensors, and data collection – encompass the entire
datapath of the application.
1.4 Compiling and installing applications
You can download the latest TinyOS distribution, the nesC compiler, and other tools at
www.tinyos.net. Setting up your programming environment is outside the scope of
this book; the TinyOS website has step-by-step tutorials to get you started. One part of
TinyOS is an extensive build system for compiling applications. Generally, to compile a
program for a sensor platform, one types make <platform>, e.g. make telosb.
This compiles a binary. To install that binary on a node, you plug the node into your
PC using a USB or serial connection, and type make <platform> install. The
tutorials go into compilation and installation options in detail.
1.5 The rest of this book
The rest of this book goes into how to program in nesC and write TinyOS applications.
It is divided into three parts. The first is a short introduction to the major programming
concepts of nesC. The second part addresses basic application programming using
standardTinyOSAPIs.Thethirdpartdigsalittledeeper,andlooksintohowthoseTinyOS
APIs are implemented. For example, the third part describes how TinyOS abstracts
hardware, so you can write a driver for a new sensor.
Chapter by chapter, the book is structured as follows:
• Chapter 1 is this chapter.
• Chapter 2 describes the major way that nesC breaks from C and C-like languages:
how programs are built out of components, and how components and interfaces help
manage programs’ namespaces.
• Chapter 3 presents components and how they interact via interfaces.
• Chapter 4 goes into greater detail into configurations, components which connect
other components together.
• Chapter 5 covers the basic TinyOS execution model and gives guidance on how and
when to use tasks.
1.5 The rest of this book 9
• Chapter 6 takes the material from the prior three chapters and brings it together into
an example of writing a fully-fledged application that sends an alarm when a node
observes a change in its environment. In the process, it covers the major TinyOS APIs
(timing, sensing, communication, and storage).
• Chapter 7 details the PC-side tools for communicating with nodes connected over
the serial port, and covers the TinyOS serial stack and packet formats.
• Chapter 8 introduces more advanced component topics, such as parameterized
interfaces and attributes. While applications typically don’t use these mechanisms,
they are indispensable when writing reusable libraries and systems.
• Chapter 9 goes into wiring parameterized interfaces, which form the basis for most
reusable systems.After describing the basic mechanisms for managing interface keys,
it goes through four examples of increasing complexity.
• Chapter 10 presents eight common TinyOS design patterns: commonly useful and
powerful ways of organizing components.
• Chapter 11 concludes the advanced programming topics by covering concurrency. It
describes asynchronous code, the TinyOS task model, and power locks.
• Chapter 12 describes the Hardware Abstraction Architecture (HAA), the
three-level hierarchy TinyOS uses to raise low-level hardware abstractions to
hardware-independent, application-level services.
• Chapter 13 goes step-by-step through an advanced application that identifies the
location of an event based on when nodes sense it. It uses lower-layer interfaces to
implement time synchronization and high-frequency sampling.
• Appendix gives a concise overview of major TinyOS application interfaces.
Throughout the book, you will find programming hints: general best-use practices
that we’ve distilled from the many users of TinyOS and nesC. These are all listed on the
sheet at the front of the book.
Finally, the complete source code for example applications presented in this book (in
Chapters 6, 7 and 13) is available in TinyOS’s contributed code directory, under the name
“TinyOS Programming” – see www.tinyos.net for details.
2 Names and program structure
Program structure is the most essential and obvious difference between C and nesC.
C programs are composed of variables, types, and functions defined in files that are
compiled separately and then linked together. nesC programs are built out of components
that are connected (“wired”) by explicit program statements; the nesC compiler connects
and compiles these components as a single unit.To illustrate and explain these differences
in how programs are built, we compare and contrast C and nesC implementations of two
very simple “hello world”-like mote applications, Powerup (boot and turn on a LED)
and Blink (boot and repeatedly blink a LED).
2.1 Hello World!
The closest mote equivalent to the classic “Hello World!” program is the “Powerup”
application that simply turns on one of the motes LEDs at boot, then goes to sleep.
A C implementation of Powerup is fairly simple:
# include " mote .h"
int main ()
{
mote_init ();
led0_on ();
sleep ();
}
Listing 2.1 Powerup in C
The Powerup application is compiled and linked with a “mote” library which provides
functions to perform hardware initialization (mote_init), LED control (led0_on) and put
the mote in to a low-power sleep mode (sleep). The “mote.h” header file simply provides
declarations of these and other basic functions. The usual C main function is called
automatically when the mote boots.1
1 The C compiler, library, and linker typically arrange for this by setting the mote’s hardware reset vector to
point to a piece of assembly code that sets up a C environment, then calls main.
2.1 Hello World! 11
The nesC implementation of Powerup is split into two parts. The first, the PowerupC
module, contains the executable logic of Powerup (what there is of it …):
module PowerupC {
uses interface Boot ;
uses interface Leds ;
}
implementation {
event void Boot . booted () {
call Leds . led0On ();
}
}
Listing 2.2 PowerupC module in nesC
This code says that PowerupC interacts with the rest of the system via two interfaces,
Boot and Leds, and provides an implementation for the booted event of the Boot
interface that calls the led0On2 command of the Leds interface. Comparing with the
C code, we can see that the booted event implementation takes the place of the main
function, and the call to the led0On command the place of the call to the led0_on library
function.
This code shows two of the major differences between nesC and C: where C programs
are composed of functions, nesC programs are built out of components that implement a
particular service (in the case of PowerupC, turning a LED on at boot-time). Furthermore,
C functions typically interact by calling each other directly, while the interactions
between components are specified by interfaces: the interface’s user makes requests
(calls commands) on the interface’s provider, the provider makes callbacks (signals
events) to the interface’s user. Commands and events themselves are like regular
functions (they can contain arbitrary C code); calling a command or signaling an event
is just a function call. PowerupC is a user of both Boot and Leds; the booted event is
a callback signaled when the system boots, while the led0On is a command requesting
that LED 0 be turned on.
nesC interfaces are similar to Java interfaces, with the addition of a command or
event keyword to distinguish requests from callbacks:
interface Boot } {
event void } booted ();
}
interface Leds {
command void led0On ();
command void led0Off ();
2 LEDs are numbered in TinyOS, as different platforms have different color LEDs.
12 Names and program structure
command void led0Toggle ();
...
}
Listing 2.3 Simple nesC interfaces
The second part of Powerup, the PowerupAppC configuration, specifies how
PowerupC is connected to TinyOS’s services:
configuration PowerupAppC { }
implementation {
components MainC , LedsC , PowerupC ;
MainC . Boot -> PowerupC . Boot ;
PowerupC . Leds -> LedsC . Leds ;
}
Listing 2.4 PowerupAppC configuration in nesC
This says that the PowerupAppC application is built out of three components
(modules or configurations), MainC (system boot), LedsC (LED control), and PowerupC
(our powerup module). PowerupAppC explicitly specifies the connections (or wiring)
betweentheinterfacesprovidedandusedbythesecomponents.WhenMainChasfinished
booting the system it signals the booted event of its Boot interface, which is connected
by the wiring in PowerupAppC to the booted event in PowerupC. This event then
calls the led0On command of its Leds interface, which is again connected (wired) by
PowerupAppC to the Leds interface provided by LedsC. Thus the call turns on LED 0.
The resulting component diagram is shown in Figure 2.1 – this diagram was generated
automatically from PowerupAppC by nesdoc, nesC’s documentation generation tool.
PowerupAppCillustratesthethirdmajordifferencebetweenCandnesC:wiringmakes
the connections expressed by linking the C version of Powerup with its “mote” library
explicit. In the C version, Powerup calls a global function named led0_on which is
connected to whatever library provides a function with the same name; if two libraries
PowerupC
MainC LedsC
Boot Leds
Figure 2.1 Wiring Diagram for Powerup application
2.2 Essential differences: components, interfaces, and wiring 13
.nc
.nc
.nc app.c binary
nesC
compiler
Native C
compiler
Figure 2.2 The nesC compilation model. The nesC compiler loads and reads in nesC components, which it
compiles to a C file. This C file is passed to a native C compiler, which generates a mote binary.
provide such a function then (typically) the first one named on the linker command line
“wins.” Using a nesC configuration, the programmer instead explicitly selects which
component’s implementation of the function to use.
The nesC compiler can take advantage of this explicit wiring to build highly optimized
binaries. Current implementations of the nesC compiler (nesc1) take nesC files
describing components as input and output a C file. The C file is passed to a native C
compiler that can compile to the desired microcontroller or processor. Figure 2.2 shows
this process. The nesC compiler carefully constructs the generated C file to maximize the
optimization abilities of the C compiler. For example, since it is given a single file, the
C compiler can freely optimize across call boundaries, inlining code whenever needed.
The nesC compiler also prunes dead code which is never called and variables which are
never accessed: since there is no dynamic linking in nesC, it has a complete picture of
the application call graph. This speeds the C compilation and reduces program size in
terms of both RAM and code.
2.2 Essential differences: components, interfaces, and wiring
The three essential differences between C and nesC – components, interfaces, and
wiring – all relate to naming and organizing a program’s elements (variables, functions,
types, etc). In C, programs are broken into separate files which are connected via a global
namespace: a symbol X declared in one file is connected by the linker to a symbol X
defined in another file. For instance, if file1.c contains:
extern void g( void ); /* declaration of g */
int main () /* definition of main */
{
g(); g ();
}
and file2.c contains:
void g( void )
{
printf (" hello world !");
}
14 Names and program structure
then compiling and linking file1.c and file2.c connects the calls to g() in main
to the definition of g in file2.c. The resulting program prints “hello world!” twice.
Organizing symbols in a global namespace can be tricky. C programmers use a number
oftechniquestosimplifythistask,includingheaderfilesandnamingconventions.Header
files group declarations so they can be used in a number of files without having to retype
them, e.g. a header file file1.h for file1.c would normally contain:
# ifndef FILE1_H
# define FILE1_H
extern void g( void ); /* declaration of g */
# endif
Naming conventions are designed to avoid having two different symbols with the
same name. For instance, types are often suffixed with _t guaranteeing that a type and
function won’t have the same name. Some libraries use a common prefix for all their
symbols, e.g. Gtk and gtk_ for the GTK+ graphical toolkit. Such prefixes remind users
that functions are related and avoid accidental name collisions with other libraries, but
make programs more verbose.
nesC’s components provide a more systematic approach for organizing a program’s
elements. A component (module or configuration) groups related functionality (a timer,
a sensor, system boot) into a single unit, in a way that is very similar to a class in an
object-oriented language. For instance, TinyOS represents its system services as separate
components such as LedsC (LED control, seen above), ActiveMessageC (sending and
receivingradiomessages),etc.Onlytheservice(component)nameisglobal,theservice’s
operations are named in a per-component scope:ActiveMessageC.SplitControl starts and
stops the radio, ActiveMessageC.AMSend sends a radio message, etc.
Interfaces bring further structure to components: components are normally specified
in terms of the set of interfaces (Leds, Boot, SplitControl,AMSend) that they provide and
use, rather than directly in terms of the actual operations. Interfaces simplify and clarify
code because, in practice, interactions between components follow standard patterns:
many components want to control LEDs or send radio messages, many services need
to be started or stopped, etc. Encouraging programmers to express their components in
terms of common interfaces also promotes code reuse: expressing your new network
protocol in terms of the AMSend message transmission interface means it can be used
with existing applications, using AMSend in your application means that it can be used
with any existing or future network protocol.
Rather than connect declarations to definitions with the same name, nesC programs
use wiring to specify how components interact: PowerupAppC wired PowerupC’s Leds
interface to that provided by the LedsC component, but a two-line change could switch
that wiring to the NoLedsC component (which just does nothing):
components PowerupC , NoLedsC ;
PowerupC . LedsC -> NoLedsC . Leds ;
without affecting any other parts of the program that wish to use LedsC. In C, one could
replace the “mote” library used by Powerup by a version where the LED functions did
nothing, but that change would affect all LED users, not just Powerup.
2.3 Wiring and callbacks 15
2.3 Wiring and callbacks
Leaving the component connection decisions to the programmer does more than just
simplify switching between multiple service implementations. It also provides an
efficient mechanism for supporting callbacks, as we show through the example of timers.
TinyOS provides a variable number of periodic or deadline timers; associated with each
timer is a callback to a function that is executed each time the timer fires. We first look
at how such timers would be expressed in C, by modifying Powerup to blink LED 0 at
2 Hz rather than turn it on once and for all:
# include " mote .h"
timer_t mytimer ;
void blink_timer_fired ( void )
{
leds0_toggle ();
}
int main ()
{
mote_init ();
timer_start_periodic (& mytimer , 250 , blink_timer_fired );
sleep ();
}
Listing 2.5 Powerup with blinking LED in C
In this example, the Blink application declares a global mytimer variable to hold
timer state, and calls timer_start_periodic to set up a periodic 250 ms timer. Every time
the timer fires, the timer implementation performs a callback to the blink_timer_fired
function specified when the timer was set up. This function simply calls a library function
that toggles LED 0 on or off.
The nesC version of Blink is similar to the C version, but uses interfaces and wiring
to specify the connection between the timer and the application:
module BlinkC {
uses interface Boot ;
uses interface Timer ;
uses interface Leds ;
}
implementation {
event void Boot . booted () {
call Timer . startPeriodic (250);
}
event void Timer . fired () {
16 Names and program structure
call Leds . led0Toggle ();
}
}
Listing 2.6 Powerup with blinking LED in nesC (slightly simplified)
The BlinkC module starts the periodic 250 ms timer when it boots. The connection
between the startPeriodic command that starts the timer and the fired event which blinks
the LED is implicitly specified by having the command and event in the same interface:
interface Timer {
command void startPeriodic ( uint32_t interval );
event void fired ();
...
}
Finally, this Timer must be connected to a component that provides an actual timer.
BlinkAppC wires BlinkC.Timer to a newly allocated timer MyTimer:
configuration BlinkAppC { }
implementation {
components MainC , LedsC , new TimerC () as MyTimer , BlinkC ;
BlinkC . Boot -> MainC . Boot ;
BlinkC . Leds -> LedsC . Leds ;
BlinkC . Timer -> MyTimer . Timer ;
}
Listing 2.7 Powerup with blinking LED configuration (slightly simplified)
In the C version the callback from the timer to the application is a run-time argument to
the timer_start_periodic function. The timer implementation stores this function pointer
in the mytimer variable that holds the timer’s state, and performs an indirect function
call each time the timer fires. Conversely, in the nesC version, the connection between
the timer and the Blink application is specified at compile-time in BlinkAppC. This
avoids the need to store a function pointer (saving precious RAM), and allows the nesC
compiler to perform optimizations (in particular, inlining) across callbacks.
2.4 Summary
Table 2.1 summarizes the difference in how programs are structured in C, C++ and nesC.
In C, the typical high-level programming unit is the file, with an associated header file
that specified and documents the file’s behavior. The linker builds applications out of
files by matching global names; where this is not sufficient to express program structure
(e.g. for callbacks), the programmer can use function pointers to delay the decision of
which function is called at what point.
2.4 Summary 17
Table 2.1. Program Structure in C, C++ and nesC
structural element C C++ nesC
program unit file class component
unit specification header file class declaration component specification
specification pattern – abstract class interface
unit composition name matching name matching wiring
delayed composition function pointer virtual method wiring
C++ provides explicit language mechanisms for structuring programs: classes are
typically used to group related functionality, and programs are built out of interacting
objects (class instances). An abstract class can be used to define common class
specification patterns (like sending a message); classes that wish to follow this pattern
then inherit from the abstract class and implement its methods – Java’s interfaces provide
similar functionality. Like in C, the linker builds applications by matching class and
function names. Finally, virtual methods provide a more convenient and more structured
way than function pointers for delaying beyond link-time decisions about what code to
execute.
In nesC, programs are built out of a set of cooperating components. Each component
uses interfaces to specify the services it provides and uses; the programmer uses wiring
to build an application out of components by writing wiring statements, each of which
connects an interface used by one component to an interface provided by another. Making
these wiring statements explicit instead of relying on implicit name matching eliminates
the requirement to use dynamic mechanisms (function pointers, virtual methods) to
express concepts such as callbacks from a service to a client.
TinyOS programming 1st Edition Philip Levis
Part II
Basic programming
TinyOS programming 1st Edition Philip Levis
3 Components and interfaces
This chapter describes components, the building blocks of nesC programs. Every
component has a signature, which describes the functions it needs to call as well as the
functions that others can call on it. A component declares its signature with interfaces,
whicharesetsoffunctionsforacompleteserviceorabstraction. Modulesarecomponents
that implement and call functions in C-like code. Configurations connect components
into larger abstractions. This chapter focuses on modules, and covers configurations only
well enough to modify and extend existing applications: Chapter 4 covers writing new
configurations from scratch.
3.1 Component signatures
A nesC program is a collection of components. Every component is in its own source
file, and there is a one-to-one mapping between component and source file names. For
example, the file LedsC.nc contains the nesC code for the component LedsC, while
the component PowerupC can be found in the file PowerupC.nc. Components in nesC
reside in a global namespace: there is only one PowerupC definition, and so the nesC
compiler loads only one file named PowerupC.nc.
There are two kinds of components: modules and configurations. Modules and
configurations can be used interchangeably when combining components into larger
services or abstractions. The two types of components differ in their implementation
sections. Module implementation sections consist of nesC code that looks like C. Module
code declares variables and functions, calls functions, and compiles to assembly code.
Configuration implementation sections consist of nesC wiring code, which connects
components together. Configurations are the major difference between nesC and C (and
other C derivatives).
All components have two code blocks. The first block describes its signature, and the
second block describes its implementation:
module PowerupC { configuration LedsC {
// signature // signature
} }
implementation { implementation {
// implementation // implementation
} }
Listing 3.1 The signature and implementation blocks
Discovering Diverse Content Through
Random Scribd Documents
milestones in the onward march of democracy.
The immigrant has not been unmindful of the blessings conferred upon him
in this country. He has adjusted himself quickly to his new environment. In
every crisis, he has faithfully stood by our country and institutions. He has
striven to teach his children to love and honor the land which harbors them.
All human history teaches us that the price of human liberty is the
continuous enlargement of that liberty. The only safe principle of democracy is
justice, equity, and equal respect among all our people. Great unfinished tasks
remain for us to solve. Our common loyalty must hold high the torch and pass
it on, with fire unquenched, to the citizen of tomorrow.
Transcriber’s Note: Click image for larger
version.
IMMIGRATION FIGURES FOR SOME
COUNTRIES FROM 1820-1936
Recordings of “Americans All—
Immigrants All”
Many organizations, churches, schools, and colleges have
requested that “Americans All—Immigrants All” be made available
in recorded form. The Office of Education, by special arrangement
with the Columbia Broadcasting System, the Committee on
Scientific Aids to Learning, the American Federation of Musicians,
and the Music Authors and Publishers Protective Association, have
recordings for non-commercial use in both 33⅓ r.p.m. and 78
r.p.m. (suitable for use on phonographs). For complete information
regarding the recordings, write to: Educational Radio Script
Exchange, Radio Division, Office of Education, Washington, D. C.
Transcriber’s Note: Click image for larger
version.
THEY HAVE BUILT A NATION
TYPICAL CONTRIBUTIONS TO
AMERICAN INDUSTRY AND CULTURE
TinyOS programming 1st Edition Philip Levis
I
Are People Really Different?
“Democracy means not ‘I’m as good as you are’ but ‘you’re as
good as I am.’”—Theodore Parker.
mmigration has made the United States the most composite nation on earth.
More peoples of widely different national and racial origins have been
brought together and welded into a single political, economic, and social
system than anywhere else in the world.
What constitutes a race? Does each race have certain hereditary
characteristics which determine its mental life and social behavior? Is there a
racial stock which is superior—physically, mentally, and morally—to other
racial stocks? Just what differences, if any, exist between those who were
born here and those who have adopted this country as their home land?
There is no such person as a native American, nor was there ever such a
person if we are to be strictly accurate. We are told that even the American
Indian is an immigrant who came from far-off Asia by way of the Bering
Straits and Alaska. Our ancestors may have come on the Mayflower or in the
steerage, we may be descended from immigrants who settled here
generations ago, or we may have come direct from other lands, yet one fact
remains crystal clear—WE ARE ALL IMMIGRANTS.
Physical Characteristics
From the physical standpoint, races do have certain very definite differences
that are obvious. One of the most obvious is that of color. White, black,
yellow, red, brown, and yellow-brown are the colors we usually associate with
certain racial types. Some of us are tall, blond, and blue-eyed. Others are
short, dark, and brown-eyed. Some people have long, narrow heads while
others have short, round heads. However, the same physical differences may
be found not only between racial and national groups, but also between
individuals within the nation, tribe, or family.
Mental Characteristics
In answer to the contention that certain racial groups are mentally superior
to others, Franz Boas, an outstanding scientist, says, “No one has ever proved
that a human being through his descent from a group of people must of
necessity have certain mental characteristics.... If we were to select the most
intelligent, imaginative, energetic, and emotionally stable third of mankind, all
races would be represented.”
Hooton, another scientist, is even more emphatic. He declares that “each
racial type runs the gamut from idiots and criminals to geniuses and
statesmen. No type produces a majority of individuals from either end of the
scale. There are no racial monopolies of either human virtues or vices.”
Carefully controlled intelligence tests given by educators and scientists to
different racial groups show that, where environment and social conditions are
the same, no group can claim mental superiority. In fact, it has been clearly
apparent that “man, everywhere, is basically and fundamentally similar” and
that his differences, be they physical, mental, or moral, are determined not by
race so much as by the social conditions and opportunities around him.
Important Findings
The assimilation of different groups within the United States would seem to
show that:
1. Under favorable conditions of equal opportunity, all racial
groups, whatever their original homeland conditions and status, are
capable of rapid social change both as individuals and as groups.
“It can easily be shown,” says one scientist, “how dependent mental
differences are upon social conditions. For instance, exact observations have
been made on Negroes who have moved from the country to the city and it
has been shown that assimilation of these people to the behavior of the city
population takes place within a few years.
“Likewise, it has been shown in the case of Italian immigrants that they
grow to resemble the Americans in behavior the longer they have been in this
country, provided they do not remain isolated. One of the most instructive
illustrations of this assimilation is the ease with which children adopt the
dialect and manner of expression of their environment.”
2. All groups, under the stimulus of opportunity and contact, have
capacity to produce exceptional individuals of high creative ability or
genius and thus help build up and perfect human culture.
The Nordic and Slav, the southern European and Jew, black, white, brown,
and yellow have all produced men and women of outstanding brains and
genius. To confirm these statements it is only necessary to read, in the pages
that follow, the contributions of the immigrant and his descendants to
American life.
Research studies, conducted on an objective basis, prove that individual
brilliance may be and is, found in all groups.
3. Under the influence of a common environment, physical and
cultural, the offspring of different racial and national groups in a
democracy tend toward a common culture with common customs
and ideals.
John Dewey has emphasized that, “in a democratic society, individuals give
freely to others of the peculiar value, essence, quality, and contribution of the
group to which they belong, and receive freely the corresponding treasures of
other groups, and this without violence to the complete uniqueness of the
group.”
At birth, no individual has any culture and so the culture he eventually
acquires is the one he finds around him and is capable of assimilating.
However, “new conditions bring the need of new ideals and new emphasis on
certain aspects of old ideals.” Civilization itself is not only safeguarded but
advanced when a nation, composed of many races, finds it possible for each
racial group to “function creatively in building the culture of the race into the
whole culture pattern.”
4. Within the framework of common political and economic
institutions, a variety of cultural elements makes for a richer and
more active social culture.
In all history, some of the most advanced civilizations have been the
product of a mixture of cultures. No great nations or civilizations have been
born in isolation. Inbreeding inevitably results in one-sidedness and,
eventually, in stagnation and decadence.
Spain was at its greatest “when the mixture of peoples was at its height.”
England grew great because the ingredients of many racial groups ran in the
Englishman’s blood. The United States will continue to be great because the
intermingling of many groups tends to build a culture or civilization that
unifies the best of their contributions.
5. A civilization of many different elements develops religious,
social, and cultural tolerance. It also creates ability which may
permit it to grow and change.
Immigration from 1820 to 1936
Albania 2,846
Austria and Hungary 4,138,333
Belgium 155,024
Bulgaria 65,424
Czechoslovakia 110,928
Denmark 333,900
Estonia 1,839
Finland 18,310
France 588,023
Germany 5,938,822
Great Britain:
England 2,629,335
Scotland 732,587
Wales 86,233
Not Specified 793,741
Greece 427,006
Ireland 4,588,464
Italy 4,692,447
Latvia 3,918
Lithuania 7,166
Luxemburg 854
Netherlands 249,059
Norway and Sweden 2,018,640
Poland 407,366
Portugal 254,499
Rumania 155,496
Russia 3,343,088
Spain 168,913
Switzerland 292,153
Turkey in Europe 155,568
Yugoslavia 53,394
Other Europe 21,309
TOTAL FROM EUROPE 32,434,685
China 379,982
India 9,704
Japan 277,162
Turkey in Asia 205,317
Other Asia 38,858
ASIA COMPLETE TOTAL 911,023
Canada and Newfoundland 2,957,422
Mexico 768,453
Central America 46,919
West Indies 438,633
South America 117,649
Other America 40
AMERICA TOTAL 4,329,116
AFRICA 25,311
AUSTRALIA-NEW ZEALAND 53,739
PACIFIC ISLANDS 10,610
NOT SPECIFIED 254,066
TOTAL FROM ALL COUNTRIES 38,018,550
From 1931 to 1938, departures have exceeded admissions by 203,694.
T
Our Gifts to Science and to Agriculture
he brawn, brain, and inventive genius of the immigrants and their
descendants have made the United States a world leader in science and
industry. In reading about this pageant of achievement, which is unique in
human history, you will also learn something about the diverse racial
origins of those who laid the gifts on the “altar of America.” Here they are—
IMMIGRANTS! SONS OF IMMIGRANTS! AND SONS OF SONS OF
IMMIGRANTS!—men and women who have thrilled the worlds of science and
industry, the arts and crafts, and social progress and government. The italics
indicate the racial origin of each individual or a major racial group from which
he is descended, although it should be kept in mind that a person’s ancestors
frequently include many racial strains. The achievements listed are suggestive
rather than exhaustive.
Medicine
Use of cocaine as local anaesthetic first introduced by
Carl Koller, German Jew ... ether first demonstrated to the
world in surgical operation by William Morton, Scot ... first
successful operation on human heart performed by Daniel
H. Williams, Negro.
Schick Diphtheria Test devised by Dr. Bela Schick,
Hungarian Jew ... pioneer work in antiseptics by Henry
Banga, Swiss, and many lives saved during World War
through contributions to aseptic surgery of Alexis Carrel,
French ... preventive compound for cholera and typhoid fever discovered by F.
G. Novy, Slovak ... apparatus for electric blood transfusion perfected by D. J.
Calicchio, Italian.
Charles and William Mayo, Irish, have made surgery almost as reliable a
science as bookkeeping ... Charles McBurney, Scotch-Irish, discovered
McBurney’s Point as a sign for the necessity of operating for appendicitis.
Discovery that the disease pellagra was due to faulty diet made by Joseph
Goldberger, German Jew ... typhus and typhoid fever distinguished by Alfred
Stillé, Swede ... human blood classified in different types by Karl Landsteiner,
Austrian Jew ... research work in combatting syphilis and yellow fever by
Hideyo Noguchi, Japanese.
Expert on infantile paralysis and meningitis is Simon Flexner, German Jew ...
first removal of human ovary by Ephraim MacDowell, Scot ... one of the
famous authorities on plastic surgery is V. Kazanjian, Armenian ... world
authority on venereal disease is Vecki Victor, Yugoslav ... Edward Trudeau,
French, began sanatorium treatment for tuberculosis ... Clifford Beers,
English-Netherlander, founder of mental hygiene movement.
Discovery that mosquitoes carried yellow fever made by Walter Reed,
English ... malaria driven out of Panama by General William C. Gorgas,
Scotch-Irish-Netherlander ... first hospital in colonies founded by Dr. Thomas
Bond, Welsh.
Physics
Our great electrical wizards have been: Joseph Henry,
Scotch-Irish, who helped to invent the telegraph ... Charles
Steinmetz, German-Polish, mathematical genius and
electrical scientist, who had one of the world’s most
inventive minds ... Thomas Edison, Scot-Netherlander, who
invented electric light bulb and phonograph ... Michael
Pupin, Yugoslav, who perfected tuning-in mechanism of
radio.... Nicola Tesla, Yugoslav, who made extensive use of
electrical power possible ... Vladimir Karapetoff, Armenian,
inventor of electrical devices.
Most distinguished physicist on light rays is Albert A. Michelson, German
Jew ... on x-rays, Arthur H. Compton, English ... on cosmic rays, Robert
Millikan, Scotch-Irish ... outstanding investigator of Röentgen ray is Mihran
Kassabian, Armenian ... through work on electrotechnics, expansion of
telephonic and telegraphic communication made possible by E. F. W.
Alexanderson, Swede ... John Kruesi, Swiss, helped Edison develop electric
incandescent lamp, dynamo, and phonograph.
Astronomy
First observatory put up by Ephraim Williams, Welsh ... many of our early-
day almanacs based on astronomical studies and computations of David
Rittenhouse, German-Welsh ... Lick Observatory, California,
and Yerkes Observatory, Wisconsin, founded by James Lick
and Charles Yerkes, Germans ... for pictures of many of
the stars, Dorothy Klumpke, German, achieved much fame
... famous mathematician and everyday almanac maker
was Benjamin Banneker, Negro, who also helped L’Enfant,
French, to lay out Washington, D. C.
Chemistry
Ephedrin, drug used as base for cold remedies, discovered by K. K. Chen,
Chinese ... adrenalin and diastase, discovered by Jokichi Takamine, Japanese
... grape sugar changed into tartaric acid by Mooshegh Vaygoony, Armenian
... George Washington Carver, Negro, made 145 products from peanut, 100
products from sweet potato, and 60 products from the pecan ... fermented
milk product of high curative values discovered by H. M. Dadoorian, Armenian.
Exploration
A pilot on one of Columbus’ ships was Pedro Alonzo, Negro ... first explorers
in New Mexico led by Estévanico, Moroccan ... first settlers of Alabama, who
accompanied De Soto in 1540, were Robles, Negro, and Feryada, Greek ...
first reliable map of Virginia and Maryland made by Augustine Herrman,
Czech.
Lewis, Welsh, and Clark, English, led the famous expedition to the
Northwest ... 1903 Ziegler Expedition to the North Pole led by Anthony Fiala,
Czech ... North Pole discovered by Robert Peary, French-English, accompanied
by Matthew Henson, Negro ... first to fly across South Pole was Richard Byrd,
English.
Other Sciences
First of American geologists was William McClure, Scot ... the great
naturalist, John J. Audubon, French-Spanish, taught us about birds of America
... many inspired to study natural sciences by Louis Agassiz, French ... Henry
D. Thoreau, Huguenot, was great naturalist and writer ... famous
anthropologists are Franz Boas and Edward Sapir, German Jews, and Ales
Hrdlicka, Czech.
International authority on zoology and botany is Leonhard Steiniger,
Norwegian ... expert on function of cell and fertilization is Ernest Just, Negro
... first botanical garden in world founded near Philadelphia by John Bartram,
Welsh, early in 18th century ... public garden, established in Georgia by
General Oglethorpe, English, served as our first agricultural experiment station
... scientific breeding of plants demonstrated by Luther Burbank, English-
French-Netherlander-Scot.
Philosophers
Famous philosophers: Wm. James, Welsh-English ... John Dewey, Irish ...
Santayana, Spaniard ... Jiddu Krishnamurti, Hindu.
Agriculture
First vineyard in our country was set out by Jean
Jacques Dufour, Swiss ... oranges, olives, dates, and
grapes were brought to California by Fray Junipero
Serra, Spaniard ... fig cuttings were imported by
Denotovitch of Fresno, Yugoslav ... wild strawberry
developed into large table variety by Johann
Schwerdkopf, German, who came to Long Island
before Revolutionary War.
Alfalfa seed, known as Lucerne, brought to Minnesota and developed by
Wendelin Grimm, German, in 1858 ... hardy alfalfa for prairies of northwest,
brought from Siberia and Turkestan by Niels Hansen, Dane ... mower and
reaper invented by Cyrus McCormick, Scotch-Irish.
Simple tests to determine whether soil needs nitrogen, phosphates, or
potash devised by George Hoffer, German ... pasteurization introduced by
Julius Moldenhawar, Dane ... orange that will stay on tree for months after
ripening propagated by Lue Gim Gong, Chinese ... honey industry
revolutionized by Frank Jaeger, Yugoslav.
Early cooperative creamery at Clark’s Grove, Minn., organized under
leadership of Hans Jensen, Dane ... first to find trichina spiralis in hogs and
hookworm in cats was Joseph Leidy, German ... International Institute of
Agriculture established by David Lubin, Polish-Jew.
TinyOS programming 1st Edition Philip Levis
Our Gifts to Industry and Commerce
Inventions
First clock in America constructed to strike the hours built by Benjamin
Banneker, Negro, in 1790 ... early flour-milling machinery by Oliver Evans,
Welsh ... iron comb, made by a Negro to help cotton pickers, gave Eli
Whitney, English, idea for his cotton gin ... screw propeller and revolving
turret on battleship invented by John Ericsson, Swede ... first patent to a
Negro granted to Henry Blair for corn harvester in 1834 ... comb-making
machine built by Nathaniel Jones, Welsh.
First zipper fastener invented by Gideon Sundbäck, Swede ... green coloring
matter used in our paper dollar invented by Dr. Seropian, Armenian ...
machine for lasting shoes built by Jan Matzeliger, Haitian, in 1852 ... self-
starter automobile clutch invented by Victor Bendix, Swede; also developed
four-wheel brakes and carburetor ... steam-boiler furnace, electrical air-
brakes, and incubator invented by Granville T. Woods, Negro ... inventor of
carborundum was E. G. Acheson, English.
Sewing machine invented by Elias Howe, English, in
1846 ... lubricating cup, used on locomotives and marine
engines, invented by Elijah J. McCoy, Negro ... discovery of
artificial rubber by Father Nieuland of Notre Dame,
Belgian, broke the British hold on rubber ... induction
motors invented by Nicolas Tesla, Yugoslav ... co-
discoverer of process for making luminous paints was John
Sochocky, Ukrainian ... fireproof stairs and library
bookstacks invented by Neils Poulson, Dane ... Stilson
wrench invented by Daniel Stilson, Swede, in 1875.
Bakelite, a substitute used for ivory and bone in making toilet articles,
invented by Leo Baekeland, Belgian. He discovered velox, a paper used by
photographers, and made several other discoveries through experimenting
with the electrolytic cell ... one of our earliest elevators was built by Dr. Nils
Collins, Swede, a Philadelphia pastor ... the condensor used in radios and
electric motors is the result of work done by Alexander Georgiev, Bulgarian ...
numerous inventions of a wide and varied nature in connection with steam
turbines were developed by Oscar Junggren and by Carl Söderburg, Swedes
... huge machines used for knitting are the invention of Ladislaus Robaczynski,
Armenian ... outstanding typewriter designer is Carl Gabrielson, Swede.
Airbrake invented by George Westinghouse, English-Netherlander ...
“scientific divining rod” used in electro-magnetic method of locating metal ore,
petroleum, and other minerals devised by Hans Lundberg and Karl Sundberg,
Swedes ... in inventing telephone transmitter and motion-picture projector,
Edison, Scot-Netherlander, helped by Emile Berliner, German Jew ... accuracy
gauges from which precision machinery is made, invented by Carl Johannson,
Swede ... process for making artificial stone invented by Michael Tymofiev,
Ukrainian ... pioneer in radio work and sound motion pictures was Lee De
Forest, French-English.
Transportation
First steamboat built and taken down Ohio and
Mississippi by Nicholas Roosevelt, Netherlander ...
first elevated railroad in New York City was built by
José Francisco de Navarro, a Spaniard, in 1878 ...
first demonstration of steam railroad in practice by
John Stevens, English, in 1825 ... the Clermont, our
first commercially successful steamboat, built by
Robert Fulton, Irish ... greatest of clipper ships,
Rainbow and Sea Witch, built by John Griffith, Welsh ... wagons and
automobiles produced by Studebaker Brothers, German.
Inventor of modern suspension bridge was John Roebling, German, who
built beautiful Brooklyn Bridge ... the Niagara cantilever bridge, for heavy
railroad traffic, invented by Charles Schneider, German ... the Northwest
opened up by railroad builder James J. Hill, Scotch-Irish ... transatlantic flier,
Charles Lindbergh, and airship commander, Charles Rosendahl, Swedes.
Manufacturing
Window glass manufactured by Caspar Wistar, German, in 1739 ...
decorative stoves and glass of highly prized nature manufactured in 18th
century by Heinrich Stiegel, German ... the New England cotton mills
established by Samuel Slater, English ... first to unite all processes for
manufacturing finished cloth in one factory was Patrick Jackson, Irish ... art of
making gunpowder perfected by Eleuthere Dupont, French.
Great steel works of Pittsburgh founded by Andrew Carnegie, Scot, assisted
by William Jones, Welsh ... iron and steel industries of Pueblo, Colorado,
established by Daniel Jones, Welsh ... famous pioneer organ builder, Matthias
Moller, a Dane ... pianos and other instruments by Steinway, Knabe, Weber,
Wurlitzer, Gemünder, Germans ... steel manufactured by Charles Schwab,
German ... sugar produced by Havemeyer, German ... food products by Heinz
and Fleischmann, Germans ... world-noted cymbals made by Zildijian,
Armenian ... airplane builders are Igor Sigorsky, Russian; Bellanca, Italian;
Douglas, Scot; Boeing, German; and Curtiss, English-German.
Communication
The telephone was invented by Alexander Graham
Bell, Scot ... the telegraph was invention of Joseph
Henry and Samuel Morse, Scotch-Irish ... steam-
cylinder printing press, making possible our great
daily newspapers, was brain child of Robert Hoe,
English ... Erie Canal built by DeWitt Clinton, Irish-
Netherlander ... long distance telephone and wireless
telegraphy made possible by Michael Pupin, Yugoslav
... inventor of wireless switch was Fritz Lowenstein, German Jew ... new
device for transmitting radio photographs by Arthur Korn, German Jew ... loud
speaker invented by Peter Jensen, Dane ... Zworykin, Russian, pioneered in
television ... first printing press imported to California by Agustin Zamorana,
Spaniard.
Commerce
One of the largest cotton gins owned by Scott Bond, Negro ... our leading
industrialists include Astor, Vanderbilt, and Rockefeller, Germans ... Julius
Rosenwald, Chicago mail-order executive, German Jew ... Alfred Knudsen,
Dane, automobile manufacturing executive.
Leading rug merchants are Karaghuesian, Gulbenkian, Kelekian, and
Pushman, Armenians ... leading linen and lace merchants are Mallouk, Kassab,
Bardwill, Jabara, Mamary, and Boutross, Syrians ... largest raiser of orchids
and specialist in cacti is J. A. Manda, Yugoslav ... first American circus opened
in Baraboo, Wisconsin, in 1854, by Ringling Brothers, German ... Virginia
tobacco trade founded by Augustine Herrman, Czech ... gas first introduced in
1830 by Edward Jones, Welsh, in Boston.
Mining
First oil well drilled at Titusville, Pa., by Edwin Drake,
English, in 1859.... In Texas, oil was first struck by Anthony
F. Lucas, Yugoslav ... coal in Pennsylvania first discovered
by William Jones, Welsh ... pioneer miner of Colorado was
Vaso Chakovic, Yugoslav ... first California gold found on
ranch of John Sutter, German-Swiss ... eminent mining
industrialists include Simon and Daniel Guggenheim, Swiss
Jews, and Adolph Lewisohn, German Jew.
Banking
Leading bankers include: J. Pierpont Morgan, Welsh ... Nathan Straus, Felix
Warburg, Jacob Schiff, Otto Kahn, and James Speyer, German Jews ... Charles
G. Dawes, English ... Amadeo Gianini, Italian ... and Jesse Jones, Welsh.
Building
First American iron sea-going steamship built in 1859 by José Francisco de
Navarro, Spaniard, who also laid foundation of cement business in this
country ... Panama Canal built by General Goethals, Netherlander ... George
Washington Bridge built by Othmar Ammann, Swiss ... Manhattan Bridge in
New York and Interstate Bridge connecting Philadelphia and Camden built by
Leon Moisseff, Russian.
Hetch Hetchy water system from Sierra Nevada to San Francisco built by
Michael O’Shaughnessy, Irish ... Ralph Modjeski, Polish Jew, chairman, Board
of Engineers, San Francisco-Oakland Bridge ... Peter Demyanoff, Russian,
railroad builder.
Our Gifts to the Arts and Crafts
Literature
Outstanding novelists have been James Fenimore Cooper, English-Swedish;
Oliver W. Holmes, English-Netherlander; Mark Twain, English; Wm. Dean
Howells, Welsh-Irish-English-German; Mary Wilkins-Freeman, English;
Nathaniel Hawthorne, Irish; Theodore Dreiser, German; James W. Johnson,
Negro; Frank Norris, English; Booth Tarkington, English; Fannie Hurst, Edna
Ferber, and Ludwig Lewisohn, German Jews; Jacob Riis, Dane; Louis Adamic,
Yugoslav.
Our leading poets include, Longfellow, Lowell, and Whittier, English; Edgar
A. Poe, Scotch-Irish-English; Walt Whitman, English-Netherlander; Sidney
Lanier, French; Eugene Field, English; Robert Frost, Scotch-English; Edwin
Markham, English; James W. Riley, Netherlander-English; Carl Sandburg,
Swede; Edna St. Vincent Millay, English-French; Joaquin Miller and Joyce
Kilmer, Germans; Louis Untermeyer, German Jew, and Arthur Guitermann,
Austrian Jew; Christopher Morley, Irish; Phillis Wheatley and Paul Dunbar,
Negroes.
Pioneer heroism immortalized by O. E. Rölvaag, Norwegian.... Good
literature circulated in humble homes by P. F. Collier, Irish ... historian, writer,
and lecturer, William Hendrik van Loon, Netherlander.
Music
Father of our orchestras and founder of Handel and Haydn Society was
Gottlieb Graupner, German ... first organ builder and maker of spinets was
Gustaf Hesselius, Swede ... our first important
composer was Ernst Bloch, Swiss Jew.
“Carry Me Back to Old Virginny” composed by
James Bland, Negro ... “Johnny Comes Marching
Home” composed by Patrick Gilmore, Irish ... “Old
Folks at Home,” by Stephen Foster, Scotch-Irish ... an
Italian, Campanini, was first director and leader of
Metropolitan ... Gatti Casazza, Italian, famous director of Metropolitan ...
organizer of Flonzaley Quartet was Alfred Pochon, Swiss.
Famous composers include: Victor Herbert, Irish; Edward MacDowell, Scot;
John Philip Sousa, Portuguese; Percy Grainger, Australian; Eugene Goosens,
English; Howard Hanson, Swede; William Grant Still, Negro; Daniel Protheroe,
Welsh; Sigmond Romberg, German Jew; George Gershwin and Irving Berlin,
Russian Jews; Alma Glück, Roumanian; Rudolf Friml, Czech.
Outstanding conductors include Gabrilowitch, Russian Jew; Walter and
Klemperer, German; Koussevitsky and Smallens, Russian Jews; Stokowski,
Polish; Ormany and Rapee, Hungarians; Ganz, Swiss; Koshetz, Ukrainian;
Zilotti, Russian; Busch, Dane; Kindler, Netherlander; Damrosch, German;
Rodzinsky, Yugoslav; Victor Kolar, Czech.
Leading violin players of world-wide fame are: Elman, Heifetz, Zimbalist,
Russian Jews; and Yehudi Menuhin, Roumanian Jew; Ysaye, Belgian; Dvonc,
Czech; Prydatkevich, Ukrainian.
Famous pianists include Rachmaninoff, Russian; Iturbi, Spaniard; Honti,
Hungarian.
Leading flutist is Callimahos, Greek; noted zylophonist is Y. Hiraoka,
Japanese.
Among the great concert artists are Sophie Braslau, Russian Jew; Lotte
Lehmann, German; Rosa Raisa, Italian Jew; Schumann-Heink, Austrian; John
Charles Thomas, Welsh, and Paul Robeson, Jules Bledsoe, Marian Anderson,
Roland Hayes, Negroes.
Art
Father of American painting was Benjamin West, English ... portraits of
Washington, Adams, Jefferson, and Madison by Charles Gilbert Stuart, Scot ...
“Washington Crossing the Delaware,” by Emmanuel Lutze, German ... famous
portraits by John Copley, Irish ... famous etchings by Joseph Pennell, English-
Irish ... “Artist’s Mother” by James McNeil Whistler, Scotch-Irish.
“Swing Low, Sweet Chariot” by Malvin Johnson, Negro ... “Return of
Prodigal Son” by Henry Mosler, German Jew ... “Gassed” and portraits by John
S. Sargent, English-Italian ... “Autumn Oaks” by George Inness, Scot ...
“Conquerors”—building of Panama Canal—by Jonas Lie, Norwegian ...
“Resurrection of Lazarus” by Henry O. Tanner, Negro ... “Still Life” by Yasu
Kuniyoshi, Japanese.
First modernist in America was Arthur Davies, Welsh ... corrupt Tweed ring
in New York City smashed by cartoons of Thomas Nast, German ... leader in
landscape painting, Frederick Detwiller, Swiss ... master of miniatures, Malthe
Hasselriis, Dane ... famous frescoes in National Capitol by Brumidi, Italian ...
illustrator of folk tales and fairy stories, Willie Pogany, Hungarian ...
journalistic cartoons by Harrison Fisher, Czech.
Sculpture
“Puritan,” “Shaw Memorial,” and other statues by
Saint-Gaudens, Irish-French ... “Memory” and
“Lincoln” statues by Daniel Chester French, English
... work on Stone Mountain, Georgia, and Mt.
Rushmore, South Dakota by Gutzon Borglum, Dane
... “Pioneer Mother” at Kansas City by Phimester
Proctor, Canadian ... “The Sower” on the Nebraska
State Capitol by Lee Lawrie, German ... statues of
Indians by Ivan Mestrovic, Yugoslav ... McKinley monument by Haig Patigian,
Armenian.
Italian sculptors who helped adorn National Capitol were: Franzoni, bronze
clock with statue of Storia on top ... Valperti, emblematic eagle ... Amateis,
bronze doors ... Causici, Statue of Liberty Proclaiming Peace ... Trentanove,
“Pere Marquette” statue ... Vincenti, Indian chief, Be-she-ke.
Architecture
Skyscraper developed by Louis Henry Sullivan, Irish-French-German ...
Fanueil Hall, Boston, designed by John Smibert, Scot ... Vieux Carrè, New
Orleans, laid out by Adrien de Pauger, French ... foremost architect in stone
was Henry Richardson, English ... Frank Lloyd Wright, Welsh, harmonized
buildings with surroundings ... St. Patrick’s Cathedral, New
York City, built by Joseph Zvak, Czech ... prominent naval
architect is Wm. Hovgaard, Dane.
City planning by Eliel Saarinen, Finn ... Bertram
Goodhue, Scot-English, developed and refined Gothic in
public buildings ... Folger Library and Pan-American
Building in Washington by Paul Cret, Belgian ... banks and
office buildings by Stephen Voorhees, Netherlander ...
church architecture by Ralph Cram, German, and Charles
Maginnis, Irish.
Motion Pictures
Outstanding motion-picture stars: Antonio Moreno,
Spaniard ... Luise Rainer, Austrian ... Charles
Laughton and Ronald Colman, English ... Francis
Lederer, Czech ... Jean Hersholt, Dane ... Pola Negri,
Pole ... Anna Sten, Ukrainian ... Laura La Plante,
Yugoslav.
Leading producers: Mayer, Lasky, Warner, Russian
Jews, and Goldwyn, Polish Jew ... pioneers of industry were D. W. Griffith,
Welsh, Zukor and Fox, Hungarian Jews, and Loew, German Jew ... technique
of cinematography modernized by Vorkepic, Yugoslav.
Theatre
Pioneer of modern American theatre, Augustin Daly, Irish ... geniuses of the
theatre include Belasco, Portuguese Jew; Frohmans, Shuberts, Selwyn,
Warfield, Hammerstein, German Jews, and Nazimova, Russian Jew ... John
Drew, Irish ... Richard Mansfield, Julia Marlowe, and Barrymores, English ...
Paul Robeson, Negro ... the magician, Houdini, Hungarian.
Journalism
New York Weekly Journal founded by Peter Zenger, German, in 1733 ... New
York Tribune founded by Horace Greeley, Scotch-Irish ... publisher of St. Louis
Post-Dispatch and New York World was Joseph Pulitzer, Hungarian Jew ... first
great newspaper syndicate established by S. S. McClure, Irish ... magazine,
famous as a militant muckraker founded by P. F. Collier, Irish.
First modern newspaper, the New York Morning Herald, founded in 1835 by
James G. Bennett, Scot ... New York Times founded by Henry Raymond, Scot,
and George Jones, Welsh ... chain of newspapers founded by James Scripps,
English ... chain of newspapers founded by Wm. Randolph Hearst, Scotch-
English ... editor of a ladies’ magazine, Edward Bok, Netherlander.
Our Gifts to Social Progress and
Government
Declaration of Independence, written by Thomas
Jefferson, Welsh, signed by 1 Swede, 3 Irish, 4
Scots, 5 Welsh, 5 Scotch-Irish, 38 English, with John
Morton, Swede, casting deciding ballot ... the
thirteen colonies were christened the “United States
of America” by Thomas Paine, English.
Social Welfare
Our first social reformer was Robert Owen, Welsh ... first one to make use
of music in social work was Wm. van de Wall, Netherlander ... founder of Red
Cross, Clara Barton, English ... founder of Chicago’s famous Hull House was
Jane Addams, English ... slums attacked by Jacob Riis, Dane, in “How Other
Half Lives” ... welfare library on Ellis Island organized by Rev. John Kweetin,
Latvian ... anti-saloonist and feminist, Carrie Chapman Catt, English-German
... Atlanta School of Social Work, directed by Forrester Washington, Negro ...
Lillian Wald, German Jew, a social-welfare leader ... famous home for boys,
Father Flanagan, Irish.
Government and Politics
Two-thirds of our presidents, including Washington, are of English descent
... Martin van Buren and Herbert Hoover, German ... Theodore Roosevelt and
Franklin Roosevelt, Netherlanders ... Jefferson, Madison, John Adams, John Q.
Adams, Harrison, and Garfield, Welsh ... Monroe, Hayes, Grant, Wilson, and
McKinley, Scots.
Among our leading statesmen were Hamilton, Calhoun, Webster, Jefferson
Davis, Scot-Welsh ... James Blaine, Chauncey Depew, Stephen Douglas,
mainly Scots ... Patrick Henry, Scot-English-Welsh ... leading civil service and
tariff reformer was Carl Schurz, German ... iron puddler who became
Secretary of Labor, James J. Davis, Welsh.
First governors: of Delaware, John McKinley; Georgia, John Houston;
Illinois, John Boyle; Kansas, James Denver; Louisiana, Wm. Claiborne, Irish or
Scotch-Irish ... present governor of New York, H. H. Lehman, German Jew; of
Illinois, Henry Horner, German Jew ... first governor general of Florida,
Bouquet, Swiss ... first president of the Republic of Texas, Sam Houston, Scot.
Tammany Society, founded in 1789 by William Mooney, Irish, as protest
against attempt of wealthy Tories to prevent soldiers and others from voting
... first Secretary of Treasury under Jefferson, responsible for arranging
Louisiana Purchase, was Albert Gallatin, Swiss ... first to fight for conservation
of our forests was Carl Schurz, German.
Philanthropy
Astor Library, now part of New York Library,
founded by John Jacob Astor, German, in 1848 ...
4,000 Negro schools founded by Julius Rosenwald,
German Jew ... Chautauqua movement begun by
Lewis Miller, German ... gifts during panic of the 90’s,
penny meals during World War, foodships to
Palestine, and Milk Fund by Nathan Straus, Austrian
Jew ... $42,000,000 gift to General Education Board
by John D. Rockefeller, German.
Libraries founded throughout United States by Andrew Carnegie, Scot ...
funds raised to bring Statue of Liberty from France by Joseph Pulitzer,
Hungarian Jew ... appreciation of arts and literature stimulated by Edward
Bok, Netherlander ... Boy Scouts of America helped by Jacob and Mortimer
Schiff, German Jews ... $6,000,000 to Princeton University by H. C. Frick,
German.
Colgate University founded by Wm. Colgate, English ... $122,000 to Fisk
University by James Burrus, Negro ... foundations for opportunities to study
abroad and to promote well-being of mankind established by Simon and
Daniel Guggenheim, Swiss Jews.
Champions of Human Liberty
Protest against slavery by Pastorius, German ... author of “Common Sense,”
“The Crisis” and “Public Good” was Thomas Paine, English ... powerful leaders
against slavery were John Russworm, Benjamin Banneker, David Walker,
Harriet Tubman, William Brown, William Still, Samuel Ward, Frederick
Douglass, Negroes.
Peter Zenger, German, defended by Andrew Hamilton, Scot, registered
great triumph for freedom of press when he won his fight against Governor
Cosby of New York.
National Defense
Minutemen roused by Paul Revere, Huguenot ... drill-
master of Continental armies, who helped to plan West
Point, was Frederick von Steuben, German ... $600,000
advanced to Congress and subsidies negotiated from
France and the Netherlands by Haym Solomon, Polish Jew
... father of American cavalry was General Casimir Pulaski,
Pole.
First to lose life in Revolutionary War was Chrispus
Attucks, Negro ... first commodore of Navy was John Barry,
Irish ... naval hero John Paul Jones, Scot ... $5,000,000 contributed toward
War of 1812 by Stephen Girard, French ... famous privateer, who abolished
corporal punishment in the Navy, was Uriah Levy, Jew ... British defeated on
Lake Erie by Captain Perry, Scotch-Irish.
Labor
First president of American Federation of Labor, who improved living
standards of workers was Samuel Gompers, English Jew ... leader of C. I. O.,
John L. Lewis, Welsh ... organizer of coal miners, John Mitchell, Welsh ...
president of A. F. of L., William Green, English-Welsh ... leader of
Amalgamated Clothing Workers, Sidney Hillman, Lithuanian Jew.
Religious Work
Participating in Washington’s Inaugural was Rabbi Seixas, Portuguese Jew
... one of our greatest clergymen, Jonathan Edwards, Welsh ... leader in
welfare and religious work, Huie Kin, Chinese ... first Protestant missionary to
West Indies was George Lisle, former Negro slave ... professor of theology at
Hartford Seminary, N. Y. Ananigian, Armenian ... authority on early church
history is Prof. La Plana, Albanian.
Education
First book on pedagogy published in 1770 by
Christopher Dock, German ... Harvard University named
after John Harvard, English; Yale University by Elihu Yale,
Welsh; William and Mary by James Blair, Scot; Brown
University by Morgan Edwards and Samuel Jones, Welsh ...
New York University by Gallatin, Swiss ... Tuskegee
Institute by Booker Washington, Negro, world-famed
educator ... Williams College by Ephraim Williams, Welsh
... one of incorporators of Columbia University was Rabbi
Seixas, Portuguese Jew ... Hunter College by Thomas
Hunter, Irish ... Creighton University, Omaha, by Creighton brothers, Irish ...
Princeton University founded by Scottish Presbyterians ... Barnard College
founded by Annie Nathan Meyer, German Jew.
Infant school introduced in 1816, by Robert Owen, Welsh ... first German
kindergarten introduced in Wisconsin in 1855 by wife of Carl Schurz, German
... a primer, first book produced in Pennsylvania, written by Franz Pastorius,
German, headmaster of first school in Germantown ... College of Journalism
at Columbia University founded by Joseph Pulitzer, Hungarian Jew ... School of
Mines founded by Adolph Lewisohn, German Jew ... first English kindergarten
founded in Boston in 1860 by Elizabeth Peabody, English ... father of modern
American education was Horace Mann, English.
World-famous orientalist P. K. Hitti, Syrian ... one of foremost educators was
Henry Suzallo, Yugoslav ... Angelo Patri, Italian, counsels parents and children
... one of our greatest economists was Thorstein Veblen, Norwegian.
Law and Order
First Chief Justice of Supreme Court was John Jay, French ... present Chief
Justice Charles Evans Hughes, Welsh ... one of foremost authorities on
international law is Stephen Ladas, Greek.
Finns work the iron-ore fields of northern Minnesota. ... Netherlanders and
Poles developed wood-working trades of Michigan.... Italians, Portuguese,
Greeks, and Swiss have built up the grape and wine industry of California....
Greek candy-makers.... Mexicans and Japanese in beet fields of Colorado,
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookgate.com

More Related Content

PDF
TinyOS programming 1st Edition Philip Levis
PDF
TinyOS programming 1st Edition Philip Levis
PDF
(Ebook) TinyOS programming by Philip Levis, David Gay ISBN 9780521896061, 052...
PPTX
PDF
Arduino bộ vi điều khiển cho tất cả chúng ta part 1
PDF
Tos tutorial
PDF
Programming Embedded Systems With C And Gnu Development Tools 2nd Edition 2nd...
TinyOS programming 1st Edition Philip Levis
TinyOS programming 1st Edition Philip Levis
(Ebook) TinyOS programming by Philip Levis, David Gay ISBN 9780521896061, 052...
Arduino bộ vi điều khiển cho tất cả chúng ta part 1
Tos tutorial
Programming Embedded Systems With C And Gnu Development Tools 2nd Edition 2nd...

Similar to TinyOS programming 1st Edition Philip Levis (20)

PDF
EEEM048_Lecture5_Software platforms and services .pdf
PDF
T2: What the Second Generation Holds
PDF
Tinyos programming
PDF
Intro to embedded systems programming
PPT
Lecture 5: Software platforms and services
PPT
Embedded systems
PPT
TinyOS 2.1 tutorial at IPSN 2009
DOCX
Me cse
PDF
Nesc tutorial
PDF
Embedded Systems Architecture Programming and Design 2nd Edition Raj Kamal
PPT
Tiny os
PDF
Embedded Software For The Iot 3rd Edition Klaus Elk
PDF
Embedded Software for the IoT 3rd Edition Klaus Elk
PDF
nesC Part 1 (1).pdfbhhhhjjjjjjjjjjjjjjjjjkk
PDF
Discovering st32
PDF
Embedded Systems Architecture Programming And Design 2nd Edition Raj Kamal
PPT
0903 1
PDF
PDF Embedded Systems Design 2nd Edition Steve Heath download
PDF
Embedded Systems Architecture Programming and Design 2nd Edition Raj Kamal
PDF
22323006 embedded-c-tutorial-8051
EEEM048_Lecture5_Software platforms and services .pdf
T2: What the Second Generation Holds
Tinyos programming
Intro to embedded systems programming
Lecture 5: Software platforms and services
Embedded systems
TinyOS 2.1 tutorial at IPSN 2009
Me cse
Nesc tutorial
Embedded Systems Architecture Programming and Design 2nd Edition Raj Kamal
Tiny os
Embedded Software For The Iot 3rd Edition Klaus Elk
Embedded Software for the IoT 3rd Edition Klaus Elk
nesC Part 1 (1).pdfbhhhhjjjjjjjjjjjjjjjjjkk
Discovering st32
Embedded Systems Architecture Programming And Design 2nd Edition Raj Kamal
0903 1
PDF Embedded Systems Design 2nd Edition Steve Heath download
Embedded Systems Architecture Programming and Design 2nd Edition Raj Kamal
22323006 embedded-c-tutorial-8051
Ad

Recently uploaded (20)

PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
Institutional Correction lecture only . . .
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Insiders guide to clinical Medicine.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
master seminar digital applications in india
Abdominal Access Techniques with Prof. Dr. R K Mishra
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Cell Structure & Organelles in detailed.
Institutional Correction lecture only . . .
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
TR - Agricultural Crops Production NC III.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Pharma ospi slides which help in ospi learning
O5-L3 Freight Transport Ops (International) V1.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Complications of Minimal Access Surgery at WLH
Renaissance Architecture: A Journey from Faith to Humanism
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
VCE English Exam - Section C Student Revision Booklet
Insiders guide to clinical Medicine.pdf
Supply Chain Operations Speaking Notes -ICLT Program
master seminar digital applications in india
Ad

TinyOS programming 1st Edition Philip Levis

  • 1. TinyOS programming 1st Edition Philip Levis pdf download https://ebookgate.com/product/tinyos-programming-1st-edition- philip-levis/ Get Instant Ebook Downloads – Browse at https://ebookgate.com
  • 2. Get Your Digital Files Instantly: PDF, ePub, MOBI and More Quick Digital Downloads: PDF, ePub, MOBI and Other Formats Sheep 1st Edition Philip Armstrong https://ebookgate.com/product/sheep-1st-edition-philip-armstrong/ The Collected Poems of Philip Lamantia First Edition Philip Lamantia https://ebookgate.com/product/the-collected-poems-of-philip- lamantia-first-edition-philip-lamantia/ Dear Zoe 1st Edition Edition Philip Beard https://ebookgate.com/product/dear-zoe-1st-edition-edition- philip-beard/ Philip Kaufman 1st Edition Edition Annette Insdorf https://ebookgate.com/product/philip-kaufman-1st-edition-edition- annette-insdorf/
  • 3. Alec Wilder 1st Edition Edition Philip Lambert https://ebookgate.com/product/alec-wilder-1st-edition-edition- philip-lambert/ Valode Pistre Architects 1st Edition Philip Jodidio https://ebookgate.com/product/valode-pistre-architects-1st- edition-philip-jodidio/ Computer Programming 1st Edition E. Balagurusamy https://ebookgate.com/product/computer-programming-1st-edition-e- balagurusamy/ Carbon Programming 1st Edition Kevin Bricknell https://ebookgate.com/product/carbon-programming-1st-edition- kevin-bricknell/ Programming Clojure 1st Edition Stuart Halloway https://ebookgate.com/product/programming-clojure-1st-edition- stuart-halloway/
  • 6. TinyOS Programming Do you need to know how to write systems, services, and applications using the TinyOS operating system? Learn how to write nesC code and efficient applications with this indispensable guide to TinyOS programming. Detailed examples show you how to write TinyOS code in full, from basic applications right up to new low-level systems and high-performance applications. Two leading figures in the development of TinyOS also explain the reasons behind many of the design decisions made and explain for the first time how nesC relates to and differs from other C dialects. Handy features such as a library of software design patterns, programming hints and tips, end-of-chapter exercises, and an appendix summarizing the basic application-level TinyOS APIs make this the ultimate guide to TinyOS for embedded systems programmers, developers, designers, and graduate students. Philip Levis is Assistant Professor of Computer Science and Electrical Engineering at Stanford University. A Fellow of the Microsoft Research Faculty, he is also Chair of the TinyOS Core Working Group and a Member of the TinyOS Network Protocol (net2), Simulation (sim), and Documentation (doc) Working Groups. David Gay joined Intel Research in Berkeley in 2001, where he has been a designer and the principal implementer of the nesC language, the C dialect used to implement the TinyOS sensor network operating system, and its applications. He has a diploma in Computer Science from the Swiss Federal Institute of Technology in Lausanne and a Ph.D. from the University of California, Berkeley.
  • 8. TinyOS Programming PHILIP LEVIS Stanford University and DAVID GAY Intel Research
  • 9. CAMBRIDGE UNIVERSITY PRESS Cambridge, New York, Melbourne, Madrid, Cape Town, Singapore, São Paulo Cambridge University Press The Edinburgh Building, Cambridge CB2 8RU, UK First published in print format ISBN-13 978-0-521-89606-1 ISBN-13 978-0-511-50730-4 © Cambridge University Press 2009 2009 Information on this title: www.cambridge.org/9780521896061 This publication is in copyright. Subject to statutory exception and to the provision of relevant collective licensing agreements, no reproduction of any part may take place without the written permission of Cambridge University Press. Cambridge University Press has no responsibility for the persistence or accuracy of urls for external or third-party internet websites referred to in this publication, and does not guarantee that any content on such websites is, or will remain, accurate or appropriate. Published in the United States of America by Cambridge University Press, New York www.cambridge.org eBook (EBL) paperback
  • 10. Contents List of Code examples page xi Preface xvii Acknowledgements xix Programming hints, condensed xxi Part I TinyOS and nesC 1 1 Introduction 3 1.1 Networked, embedded sensors 3 1.1.1 Anatomy of a sensor node (mote) 4 1.2 TinyOS 5 1.2.1 What TinyOS provides 6 1.3 Example application 7 1.4 Compiling and installing applications 8 1.5 The rest of this book 8 2 Names and program structure 10 2.1 Hello World! 10 2.2 Essential differences: components, interfaces, and wiring 13 2.3 Wiring and callbacks 15 2.4 Summary 16 Part II Basic programming 19 3 Components and interfaces 21 3.1 Component signatures 21 3.1.1 Visualizing components 22 3.1.2 The “as” keyword and clustering interfaces 23 3.1.3 Clustering interfaces 24 3.2 Interfaces 24 3.2.1 Generic interfaces 27 3.2.2 Bidirectional interfaces 28
  • 11. vi Contents 3.3 Component implementations 29 3.3.1 Modules 30 3.3.2 A basic configuration 31 3.3.3 Module variables 32 3.3.4 Generic components 33 3.4 Split-phase interfaces 34 3.4.1 Read 36 3.4.2 Send 36 3.5 Module memory allocation, avoiding recursion, and other details 36 3.5.1 Memory ownership and split-phase calls 38 3.5.2 Constants and saving memory 41 3.5.3 Platform-independent types 42 3.5.4 Global names 44 3.5.5 nesC and the C preprocessor 46 3.5.6 C libraries 47 3.6 Exercises 48 4 Configurations and wiring 49 4.1 Configurations 50 4.1.1 The −> and <− operators 51 4.1.2 The = operator 52 4.1.3 Namespace management 53 4.1.4 Wiring rules 54 4.1.5 Wiring shortcuts 56 4.2 Building abstractions 57 4.2.1 Component naming 58 4.2.2 Component initialization 59 4.3 Component layering 60 4.3.1 Extensibility 61 4.3.2 Hardware specificity 61 4.4 Multiple wirings 63 4.4.1 Fan-in and fan-out 64 4.4.2 Uses of multiple wiring 65 4.4.3 Combine functions 66 4.5 Generics versus singletons 68 4.5.1 Generic components, revisited 68 4.5.2 Singleton components, revisited 70 4.6 Exercises 70 5 Execution model 71 5.1 Overview 71 5.2 Tasks 72 5.2.1 Task timing 74
  • 12. Contents vii 5.2.2 Timing and event handlers 75 5.3 Tasks and split-phase calls 75 5.3.1 Hardware versus software 75 5.3.2 Tasks and call loops 76 5.4 Exercises 78 6 Applications 79 6.1 The basics: timing, LEDs, and booting 79 6.1.1 Deadline-based timing 81 6.1.2 Wiring AntiTheftC 83 6.2 Sensing 83 6.2.1 Simple sampling 84 6.2.2 Sensor components 85 6.2.3 Sensor values, calibration 86 6.2.4 Stream sampling 87 6.3 Single-hop networking 89 6.3.1 Sending packets 90 6.3.2 Receiving packets 93 6.3.3 Selecting a communication stack 94 6.4 Multi-hop networking: collection, dissemination, and base stations 95 6.4.1 Collection 96 6.4.2 Dissemination 97 6.4.3 Wiring collection and dissemination 97 6.4.4 Base station for collection and dissemination 98 6.5 Storage 101 6.5.1 Volumes 102 6.5.2 Configuration data 103 6.5.3 Block and Log storage 105 6.6 Exercises 111 7 Mote-PC communication 112 7.1 Basics 112 7.1.1 Serial communication stack 113 7.2 Using mig 114 7.2.1 Sending and receiving mig-generated packets 116 7.3 Using ncg 118 7.4 Packet sources 119 7.5 Example: simple reliable transmission 120 7.5.1 Reliable transmission protocol 121 7.5.2 Reliable transmission in Java 121 7.5.3 Reimplementing TestSerial 125 7.6 Exercises 125
  • 13. viii Contents Part III Advanced programming 127 8 Advanced components 129 8.1 Generic components review 129 8.2 Writing generic modules 131 8.2.1 Type arguments 132 8.2.2 Abstract data types as generics 133 8.2.3 ADTs in TinyOS 1.x 134 8.3 Parameterized interfaces 135 8.3.1 Parameterized interfaces and configurations 137 8.3.2 Parameterized interfaces and modules 139 8.3.3 Defaults 141 8.4 Attributes 142 8.5 Exercises 144 9 Advanced wiring 145 9.1 unique() and uniqueCount() 145 9.1.1 unique 146 9.1.2 uniqueCount 147 9.1.3 Example: HilTimerMilliC and VirtualizeTimerC 147 9.2 Generic configurations 150 9.2.1 TimerMilliC 150 9.2.2 CC2420SpiC 152 9.2.3 AMSenderC 156 9.2.4 BlockStorageC 160 9.3 Reusable component libraries 162 9.4 Exercises 165 10 Design patterns 166 10.1 Behavioral: Dispatcher 166 10.2 Structural: Service Instance 170 10.3 Namespace: Keyspace 174 10.4 Namespace: Keymap 177 10.5 Structural: Placeholder 180 10.6 Structural: Facade 183 10.7 Behavioral: Decorator 186 10.8 Behavioral: Adapter 189 11 Concurrency 192 11.1 Asynchronous code 192 11.1.1 The async keyword 192 11.1.2 The cost of async 193 11.1.3 Atomic statements and the atomic keyword 195
  • 14. Contents ix 11.1.4 Managing state transitions 197 11.1.5 Example: CC2420ControlP 197 11.1.6 Tasks, revisited 199 11.2 Power locks 200 11.2.1 Example lock need: link-layer acknowledgements 200 11.2.2 Split-phase locks 201 11.2.3 Lock internals 202 11.2.4 Energy management 203 11.2.5 Hardware configuration 204 11.2.6 Example: MSP430 USART 204 11.2.7 Power lock library 205 11.3 Exercises 205 12 Device drivers and the hardware abstraction architecture (HAA) 206 12.1 Portability and the hardware abstraction architecture 206 12.1.1 Examples 208 12.1.2 Portability 210 12.2 Device drivers 210 12.2.1 Access control 211 12.2.2 Access control examples 212 12.2.3 Power management 215 12.2.4 Microcontroller power management 218 12.3 Fitting in to the HAA 219 13 Advanced application: SoundLocalizer 221 13.1 SoundLocalizer design 221 13.1.1 Time synchronization 222 13.1.2 Implementing SoundLocalizer in TinyOS 223 13.2 SynchronizerC 225 13.3 DetectorC 230 13.4 MicrophoneC 233 13.5 Wrap-up 237 Part IV Appendix and references 239 A TinyOS APIs 241 A.1 Booting 241 A.2 Communication 241 A.2.1 Single-hop 242 A.2.2 Multi-hop collection 243 A.2.3 Multi-hop dissemination 244 A.2.4 Binary reprogramming 245 A.3 Time 245 A.4 Sensing 245
  • 15. x Contents A.5 Storage 246 A.6 Data structures 247 A.6.1 BitVectorC 247 A.6.2 QueueC 247 A.6.3 BigQueueC 248 A.6.4 PoolC 248 A.6.5 StateC 249 A.7 Utilities 249 A.7.1 Random numbers 249 A.7.2 Leds 249 A.7.3 Cyclic redundancy checks 250 A.7.4 Printf 250 A.8 Low power 251 References 252 Index 254
  • 16. Code examples 2.1 Powerup in C page 10 2.2 PowerupC module in nesC 11 2.3 Simple nesC interfaces 11 2.4 PowerupAppC configuration in nesC 12 2.5 Powerup with blinking LED in C 15 2.6 Powerup with blinking LED in nesC (slightly simplified) 15 2.7 Powerup with blinking LED configuration (slightly simplified) 16 3.1 The signature and implementation blocks 21 3.2 Signatures of PowerupC and LedsC 22 3.3 MainC’s signature 22 3.4 The LedsP module 23 3.5 PowerupC and an alternative signature 24 3.6 Interface declarations for Leds and Boot 25 3.7 The Init and Boot interfaces 25 3.8 Signatures of MainC and PowerupC 26 3.9 The Queue interface 27 3.10 Using a queue of 32-bit integers 27 3.11 Providing a 16-bit or a 32-bit queue 27 3.12 The Notify interface 28 3.13 UserButtonC 28 3.14 Simplified Timer interface showing three commands and one event 29 3.15 PowerupC module code 30 3.16 The module PowerupToggleC 30 3.17 The PowerupToggleAppC configuration 31 3.18 Example uses of the components keyword 31 3.19 The Get interface 32 3.20 A self-incrementing counter 32 3.21 Generic module SineSensorC and generic configuration TimerMilliC 33 3.22 Instantiating a generic component 34 3.23 Signature of BitVectorC 34 3.24 QueueC signature 34 3.25 The Read interface 36 3.26 The split-phase Send interface 36 3.27 The Send interface 38
  • 17. xii List of code examples 3.28 The Receive interface 39 3.29 The signature of PoolC 41 3.30 CC2420 packet header 42 3.31 The dreaded “packed” attribute in the 1.x MintRoute library 43 3.32 The CC2420 header 44 3.33 TinyError.h, a typical nesC header file 45 3.34 Including a header file in a component 45 3.35 Indirectly including a header file 46 3.36 Fancy.nc: C preprocessor example 46 3.37 FancyModule.nc: C preprocessor pitfalls 47 3.38 Fancy.h: the reliable way to use C preprocessor symbols 47 3.39 Using a C library function 47 4.1 Signature of part of the CC1000 radio stack 49 4.2 The PowerupToggleAppC configuration revisited 51 4.3 C code generated from the PowerupToggleAppC configuration 51 4.4 The LedsC configuration 52 4.5 CC2420ReceiveC’s use of the as keyword 53 4.6 Naming generic component instances 54 4.7 MainC and LedsP 55 4.8 Valid alternate of PowerupToggleAppC 55 4.9 Invalid alternate of PowerupToggleAppC 55 4.10 LedsC revisited 56 4.11 BlinkC signature 56 4.12 The RandomC configuration 57 4.13 The RandomMlcgC signature 58 4.14 Seed initialization in RandomMlcgP 59 4.15 ActiveMessageC for the CC2420 61 4.16 The signature of CC2420ActiveMessageC 62 4.17 Fan-out on CC2420TransmitC’s Init 63 4.18 StdControl and SplitControl initialization interfaces 64 4.19 Why the metaphor of “wires” is only a metaphor 65 4.20 The combine function for error_t 66 4.21 Fan-out on SoftwareInit 67 4.22 Resulting code from fan-out on SoftwareInit 67 4.23 AMSenderC signature 68 4.24 RadioCountToLedsAppC 68 4.25 PoolC 69 4.26 Exposing a generic component instance as a singleton 70 5.1 The main TinyOS scheduling loop from SchedulerBasicP.nc 72 5.2 A troublesome implementation of a magnetometer sensor 76 5.3 Signal handler that can lead to an infinite loop 77 5.4 An improved implementation of FilterMagC 77 6.1 Anti-theft: simple flashing LED 80 6.2 The Leds interface 80
  • 18. List of code examples xiii 6.3 The Boot interface 81 6.4 The full Timer interface 81 6.5 WarningTimer.fired with drift problem fixed 82 6.6 Anti-Theft: application-level configuration 83 6.7 The Read interface 84 6.8 Anti-theft: detecting dark conditions 84 6.9 Anti-Theft: wiring to light sensor 86 6.10 ReadStream Interface 87 6.11 Anti-theft: detecting movement 88 6.12 The AMSend interface 90 6.13 Anti-Theft: reporting theft over the radio 91 6.14 The SplitControl interface 92 6.15 The Receive interface 93 6.16 Anti-Theft: changing settings 93 6.17 Serial vs Radio-based AM components 94 6.18 The Send interface 96 6.19 Anti-Theft: reporting theft over a collection tree 96 6.20 DisseminationValue interface 97 6.21 Anti-Theft: settings via a dissemination tree 97 6.22 The StdControl interface 97 6.23 The DisseminationUpdate interface 99 6.24 AntiTheft base station code: disseminating settings 99 6.25 The RootControl interface 100 6.26 AntiTheft base station code: reporting thefts 101 6.27 AntiTheft base station wiring 101 6.28 ConfigStorageC signature 102 6.29 Mount interface for storage volumes 103 6.30 ConfigStorage interface 103 6.31 Anti-Theft: reading settings at boot time 104 6.32 Anti-Theft: saving configuration data 105 6.33 BlockStorageC signature 106 6.34 The BlockWrite interface 106 6.35 Simultaneously sampling and storing to flash (most error checking omitted) 108 6.36 The BlockRead interface 108 6.37 LogStorageC signature 108 6.38 The LogWrite interface 109 6.39 The LogWrite interface 110 6.40 The LogRead interface 111 7.1 Serial AM Packet layout 113 7.2 TestSerial packet layout 114 7.3 Backing array methods 115 7.4 Sending packets with mig and MoteIF 117 7.5 Interface for handling received packets 117
  • 19. xiv List of code examples 7.6 Receiving packets with mig and MoteIF 117 7.7 Constants and packet layout for Oscillscope application 118 7.8 Class generated by ncg 119 7.9 Simplified code to save received samples 119 7.10 Reliable transmission protocol in Java – transmission 121 7.11 Reliable transmission protocol in Java – transmission 123 7.12 A reliable TestSerial.java 125 8.1 Instantiation within a generic configuration 130 8.2 The fictional component SystemServiceVectorC 131 8.3 QueueC excerpt 131 8.4 A generic constant sensor 132 8.5 Queue interface (repeated) 133 8.6 QueueC implementation 133 8.7 Representing an ADT through an interface in TinyOS 1.x 135 8.8 Timers without parameterized interfaces 135 8.9 Timers with a single interface 136 8.10 HilTimerMilliC signature 137 8.11 ActiveMessageC signature 138 8.12 Signature of TestAMC 138 8.13 Wiring TestAMC to ActiveMessageC 138 8.14 A possible module underneath ActiveMessageC 139 8.15 Parameterized interface syntax 140 8.16 Dispatching on a parameterized interface 140 8.17 How active message implementations decide on whether to signal to Receive or Snoop 140 8.18 Defining a parameter 141 8.19 Wiring full parameterized interface sets 141 8.20 Default events in an active message implementation 142 8.21 nesC attributes 143 9.1 Partial HilTimerMilliC signature 146 9.2 VirtualizeTimerC 148 9.3 Instantiating VirtualizeTimerC 148 9.4 VirtualizeTimerC state allocation 149 9.5 The TimerMilliC generic configuration 151 9.6 TimerMilliP auto-wires HilTimerMilliC to Main.SoftwareInit 151 9.7 The Blink application 151 9.8 The full module-to-module wiring chain in Blink (BlinkC to VirtualizeTimerC) 152 9.9 CC2420SpiC 153 9.10 CC2420SpiP 154 9.11 CC2420SpiC mappings to CC2420SpiP 154 9.12 The strobe implementation 155 9.13 The AMSenderC generic configuration 158 9.14 AMSendQueueEntryP 159
  • 20. List of code examples xv 9.15 AMQueueP 159 9.16 AMSendQueueImplP pseudocode 160 9.17 BlockStorageC 161 9.18 The full code of HilTimerMilliC 163 9.19 VirtualizeTimerC virtualizes a single timer 164 10.1 AMReceiverC 169 10.2 VirtualizeTimerC 172 10.3 Telos ActiveMessageC 181 10.4 The Matchbox facade 184 10.5 The CC2420CsmaC uses a Facade 185 10.6 AlarmToTimerC implementation 190 11.1 The Send interface 192 11.2 The Leds interface 193 11.3 Toggling a state variable 193 11.4 A call sequence that could corrupt a variable 194 11.5 State transition that is not async-safe 194 11.6 Incrementing with an atomic statement 195 11.7 Incrementing with two independent atomic statements 195 11.8 The first step of starting the CC2420 radio 198 11.9 The handler that the first step of starting the CC2420 is complete 198 11.10 The handler that the second step of starting the CC2420 is complete 198 11.11 The handler that the third step of starting the CC2420 radio is complete 199 11.12 State transition so components can send and receive packets 199 11.13 The Resource interface 201 11.14 Msp430Spi0C signature 202 11.15 Msp320Adc12ClientC signature 202 11.16 The ResourceDefaultOwner interface 203 11.17 The ResourceConfigure interface 204 12.1 ActiveMessageC signature 212 12.2 Arbitration in Stm25pSectorC 215 12.3 McuSleepC: platform-specific sleep code 218 13.1 SynchronizerC: time synchronization for SoundLocalizer 225 13.2 The Counter interface 226 13.3 DetectorC: loud sound detection for SoundLocalizer 231 13.4 The Alarm interface 231 13.5 Atm128AdcSingle: low-level single-sample ATmega128 A/D converter interface 232 13.6 The GeneralIO digital I/O pin interface 235 13.7 The I2CPacket interface for bus masters 236
  • 22. Preface This book provides an in-depth introduction to writing nesC code for the TinyOS 2.0 operating system. While it goes into greater depth than the TinyOS tutorials on this subject, there are several topics that are outside its scope, such as the structure and implementation of radio stacks or existing TinyOS libraries. It focuses on how to write nesC code, and explains the concepts and reasons behind many of the nesC and TinyOS design decisions. If you are interested in a brief introduction to TinyOS programming, then you should probably start with the tutorials. If you’re interested in details on particular TinyOS subsystems you should probably consult TEPs (TinyOSEnhancementProposals),whichdetailthecorrespondingdesignconsiderations, interfaces, and components. Both of these can be found in the doc/html directory of a TinyOS distribution. While some of the contents of this book are useful for 1.x versions of TinyOS , they do have several differences from TinyOS 2.0 which can lead to different programming practices. If in doubt, referring to the TEP on the subject is probably the best bet, as TEPs often discuss in detail the differences between 1.x and 2.0. For someone who has experience with C or C++, writing simple nesC programs is fairly straightforward: all you need to do is implement one or two modules and wire them together. The difficulty (and intellectual challenge) comes when building larger applications. The code inside TinyOS modules is fairly analogous to C coding, but configurations – which stitch together components – are not. This book is a first attempt to explain how nesC relates to and differs from other C dialects, stepping through how the differences lead to very different coding styles and approaches. As a starting point, this book assumes that 1. you know C, C++, or Java reasonably well, understand pointers and that 2. you have taken an undergraduate level operating systems class (or equivalent) and know about concurrency, interrupts, and preemption. Of course, this book is as much a description of nesC as it is an argument for a particular way of using the language to achieve software engineering goals. In this respect, it is the product of thousands of hours of work by many people, as they learned and explored the use of the language. In particular, Cory Sharp, Kevin Klues, and Vlado Handziski have always pushed the boundaries of nesC programming in order to better understand which practices lead to the simplest, most efficient, and robust code. In particular, Chapter 10
  • 23. xviii Preface is an edited version of a paper we wrote together, while using structs as a compile-time checking mechanism in interfaces (as Timer does) is an approach invented by Cory. This book is divided into four parts. The first part, Chapters 1–2, gives a high-level overviewofTinyOSandthenesClanguage.Thesecondpart,Chapters3–7goesintonesC and TinyOS at a level sufficient for writing applications. The third part, Chapters 8–13 goes into more advanced TinyOS and nesC programming, as is sometimes needed when writing new low-level systems or high performance applications. The book ends with an appendix summarizing the basic application-level TinyOS APIs.
  • 24. Acknowledgements We’dliketothankseveralpeoplefortheircontributionstothisbook.FirstisMikeHorton, of Crossbow, Inc., who first proposed writing it. Second is Pablo Guerrero, who gave detailed comments and corrections. Third is Joe Polastre of Moteiv, who gave valuable feedbackonhowtobetterintroducegenericcomponents.Fourth,we’dliketothankPhil’s father, who although he doesn’t program, read the entire thing! Fifth, John Regehr, Ben Greenstein and David Culler provided valuable feedback on this expanded edition. Last but not least, we would like to thank the TinyOS community and its developers. Many of the concepts in this book – power locks, tree routing, and interface type checking – are the work and ideas of others, which we merely present. Chapter 10 of this book is based on: Software design patterns for TinyOS, in ACM Transactions on Embedded Computing Systems (TECS), Volume 6, Issue 4 (September 2007), ©ACM, 2007. http://doi.acm.org/10.1145/1274858.1274860
  • 26. Programming hints, condensed Programming Hint 1 Use the “as” keyword liberally. (page 24) Programming Hint 2 Never write recursive functions within a module. In combination with the TinyOS coding conventions, this guarantees that all programs have bounded stack usage. (page 38) Programming Hint 3 Never use malloc and free. Allocate all state in components. If your application requirements necessitate a dynamic memory pool, encapsulate it in a component and try to limit the set of users. (page 38) Programming Hint 4 When possible, avoid passing pointers across interfaces; when this cannot be avoided only one component should be able to modify a pointer’s data at any time. (page 39) Programming Hint 5 Conserve memory by using enums rather than const variables for integer constants, and don’t declare variables with an enum type. (page 42) Programming Hint 6 Never, ever use the “packed” attribute in portable code. (page 43) Programming Hint 7 Use platform-independent types when defining message structures. (page 44) Programming Hint 8 If you have to perform significant computation on a platform-independent type or access it many (hundreds or more) times, temporarily copy it to a native type. (page 44) Programming Hint 9 Interfaces should #include the header files for the types they use. (page 46) Programming Hint 10 Always #define a preprocessor symbol in a header file. Use #include to load the header file in all components and interfaces that use the symbol. (page 47) Programming Hint 11 If a component is a usable abstraction by itself, its name should end with C. If it is intended to be an internal and private part of a larger abstraction, its name should end with P. Never wire to P components from outside your package (directory). (page 58) Programming Hint 12 Auto-wire Init to MainC in the top-level configuration of a software abstraction. (page 60) Programming Hint 13 When using layered abstractions, components should not wire across multiple abstraction layers: they should wire to a single layer. (page 63) Programming Hint 14 Never ignore combine warnings. (page 68)
  • 27. xxii Programming hints, condensed Programming Hint 15 Keep tasks short. (page 74) Programming Hint 16 If an event handler needs to make possibly long-executing command calls, post a task to make the calls. (page 75) Programming Hint 17 Don’t signal events from commands – the command should post a task that signals the event. (page 77) Programming Hint 18 Use a parameterized interface when you need to distinguish callers or when you have a compile-time constant parameter. (page 141) Programming Hint 19 If a component depends on unique, then #define the string to use in a header file, to prevent bugs due to string typos. (page 149) Programming Hint 20 Whenever writing a module, consider making it more general-purpose and generic. In most cases, modules must be wrapped by configurations to be useful, so singleton modules have few advantages. (page 165) Programming Hint 21 Keep code synchronous when you can. Code should be async only if its timing is very important or if it might be used by something whose timing is important. (page 195) Programming Hint 22 Keep atomic statements short, and have as few of them as possible. Be careful about calling out to other components from within an atomic statement. (page 199)
  • 30. 1 Introduction This book is about writing TinyOS systems and applications in the nesC language. This chapter gives a brief overview ofTinyOS and its intended uses.TinyOS is an open-source project which a large number of research universities and companies contribute to. The main TinyOS website, www.tinyos.net, has instructions for downloading and installing the TinyOS programming environment. The website has a great deal of useful information which this book doesn’t cover, such as common hardware platforms and how to install code on a node. 1.1 Networked, embedded sensors TinyOS is designed to run on small, wireless sensors. Networks of these sensors have the potential to revolutionize a wide range of disciplines, fields, and technologies. Recent example uses of these devices include: Golden Gate Bridge safety High-speed accelerometers collect synchonized data on the movement of and oscillations within the structure of San Francisco’s Golden Gate Bridge. This data allows the maintainers of the bridge to easily observe the structural health of the bridge in response to events such as high winds or traffic, as well as quickly assess possible damage after an earthquake [10]. Being wireless avoids the need for installing and maintaining miles of wires. Volcanic monitoringAccelerometers and microphones observe seismic events on the Reventador and Tungurahua volcanoes in Ecuador. Nodes locally compare when they observe events to determine their location, and report aggregate data to a camp several kilometers away using a long-range wireless link. Small, wireless nodes allow geologists and geophysicists to install dense, remote scientific instruments [30], obtaining data that answers other questions about unapproachable environments. Data center provisioning Data centers and enterprise computing systems require huge amounts of energy, to the point at which they are placed in regions that have low power costs. Approximately 50% of the energy in these systems goes into cooling, in part due to highly conservative cooling systems. By installing wireless sensors across machine racks, the data center can automatically sense what areas need cooling and can adjust which computers do work and generate heat [19]. Dynamically adapting
  • 31. 4 Introduction patch of sensors data sink gateway Internet sensor code (nesC/TinyOS) base station code (nesC/TinyOS) gateway code (Java, C, ...) Figure 1.1 A typical sensor network architecture. Patches of ultra-low power sensors, running nesC/TinyOS, communicate to gateway nodes through data sinks. These gateways connect to the larger Internet. these factors can greatly reduce power consumption, making the IT infrastructure more efficient and reducing environmental impact. While these three application domains are only a small slice of where networks of sensors are used, they show the key differences between these networks and most other computing systems. First, these “sensor networks” need to operate unattended for long periods of time. Second, they gather data from and respond to an unpredictable environment. Finally, for reasons of cost, deployment simplicity, and robustness, they are wireless. Together, these three issues – longevity, embedment, and wireless communication – cause sensor networks to use different approaches than traditional, wired, and human-centric or machine-centric systems. The sheer diversity of sensor network applications means that there are many network architectures, but a dominant portion of deployments tend to follow a common one, shown in Figure 1.1 [21, 26, 30] of ultra-low power sensors self-organized to form an ad-hoc routing network to one or more data sink nodes. These sensor sinks are attached to gateways, which are typically a few orders of magnitude more powerful than the sensors: gateways run an embedded form of Linux, Windows, or other multitasking operating system. Gateways have an Internet connection, either through a cell phone network, long-distance wireless, or even just wired Ethernet. Energy concerns dominate sensor hardware and software design. These nodes need to be wireless, small, low-cost, and operate unattended for long periods. While it is often possible to provide large power resources, such as large solar panels, periodic battery replacement, or wall power, to small numbers of gateways, doing so to every one of hundreds of sensors is infeasible. 1.1.1 Anatomy of a sensor node (mote) Since energy consumption determines sensor node lifetime, sensor nodes, commonly referred to as motes, tend to have very limited computational and communication resources. Instead of a full-fledged 32-bit or 64-bit CPU with megabytes or gigabytes of RAM, they have 8-bit or 16-bit microcontrollers with a few kilobytes of RAM. Rather than gigahertz, these microcontrollers run at 1–10 megahertz. Their low-power radios
  • 32. 1.2 TinyOS 5 Antenna Radio Circuitry USB Serial Expansion Connector Sensors Figure 1.2 A Telos sensor produced by Moteiv. The top of the node has the radio, sensors, and circuitry for the USB connector. The bottom, not shown, has the processor and flash storage chip. The antenna is part of the printed circuit board (PCB). can send tens to hundreds of kilobits per second (kbps), rather than 802.11’s tens of megabits. As a result, software needs to be very efficient, both in terms of CPU cycles and in terms of memory use. Figure 1.2 shows a sample node platform, the Telos , which is designed for easy experimentation and low-power operation. It has a TI MSP430 16-bit microcontroller with 10 kB of RAM and 48 kB of flash program memory. Its radio, a TI CC2420 which follows the IEEE 802.15.4 standard, can send up to 250 kbps. In terms of power, the radio dominates the system: on a pair of AA batteries, a Telos can have the radio on for about four days. Lasting longer than four days requires keeping the node in a deep sleep state most of the time, waking only when necessary, and sleeping as soon as possible. Theothermotediscussedinthisbook,themicazfromCrossbowTechnologyissimilar: it has an Atmel ATmega128 8-bit microcontroller with 4 kB of RAM, 128 kB of flash program memory, uses the same CC2420 radio chip, also runs off a pair of AA batteries and has a similar power consumption profile. Networks, once deployed, gather data uninterrupted for weeks, months, or years. As the placement of sensors is very application-specific, it is rare for networks to need to support multiple concurrent applications, or even require more than the occasional reprogramming. Therefore, unlike general-purpose computing systems, which emphasize run-time flexibility and composability, sensor network systems tend to be highly optimized. Often, the sensor suite itself is selected for the specific application:volcanicmonitoringusesaccelerometersandmicrophones,whiledatacenter provisioning uses temperature sensors. 1.2 TinyOS TinyOS is a lightweight operating system specifically designed for low-power wireless sensors. TinyOS differs from most other operating systems in that its design focuses on ultra low-power operation. Rather than a full-fledged processor, TinyOS is designed
  • 33. 6 Introduction for the small, low-power microcontrollers motes have. Furthermore, TinyOS has very aggressive systems and mechanisms for saving power. TinyOS makes building sensor network applications easier. It provides a set of importantservicesandabstractions,suchassensing,communication,storage,andtimers. It defines a concurrent execution model, so developers can build applications out of reusable services and components without having to worry about unforeseen interactions. TinyOS runs on over a dozen generic platforms, most of which easily support adding new sensors. Furthermore, TinyOS’s structure makes it reasonably easy to port to new platforms. TinyOS applications and systems, as well as the OS itself, are written in the nesC language. nesC is a C dialect with features to reduce RAM and code size, enable significant optimizations, and help prevent low-level bugs like race conditions. Chapter 2 goes into the details on how nesC differs significantly from other C-like languages, and most of this book is about how to best use those features to write robust, efficient code. 1.2.1 What TinyOS provides At a high level, TinyOS provides three things to make writing systems and applications easier: • a component model, which defines how you write small, reusable pieces of code and compose them into larger abstractions; • a concurrent execution model, which defines how components interleave their computations as well as how interrupt and non-interrupt code interact; • application programming interfaces (APIs), services, component libraries and an overall component structure that simplify writing new applications and services. The component model is grounded in nesC. It allows you to write pieces of reusable code which explicitly declare their dependencies. For example, a generic user button component that tells you when a button is pressed sits on top of an interrupt handler. The component model allows the button implementation to be independent of which interrupt that is – e.g. so it can be used on many different hardware platforms – without requiring complex callbacks or magic function naming conventions. Chapter 2 and Chapter 3 describe the basic component model. TheconcurrentexecutionmodelenablesTinyOStosupportmanycomponentsneeding to act at the same time while requiring little RAM. First, every I/O call in TinyOS is split-phase: rather than block until completion, a request returns immediately and the caller gets a callback when the I/O completes. Since the stack isn’t tied up waiting for I/O calls to complete, TinyOS only needs one stack, and doesn’t have threads. Instead, Chapter 5 introduces tasks, which are lightweight deferred procedure calls. Any component can post a task, whichTinyOS will run at some later time. Because low-power devices must spend most of their time asleep, they have low CPU utilization and so in practice tasks tend to run very soon after they are posted (within a few milliseconds). Furthermore, because tasks can’t preempt each other, task code doesn’t need to worry about data races. Low-level interrupt code (discussed in the advanced concurrency
  • 34. 1.3 Example application 7 chapter, Chapter 11) can have race conditions, of course: nesC detects possible data races at compile-time and warns you. Finally, TinyOS itself has a set of APIs for common functionality, such as sending packets, reading sensors, and responding to events. Uses of these are sprinkled throughpout the entire book, and presented in more detail in Chapter 6 and Appendix 1. In addition to programming interfaces, TinyOS also provides a component structure and component libraries. For example, Chapter 12 describes TinyOS’s HardwareAbstraction Architecture (HAA), which defines how to build up from low-level hardware (e.g. a radio chip) to a hardware-independent abstraction (e.g. sending packets). Part of this component structure includes resource locks, covered in Chapter 11, which enable automatic low-power operation, as well as the component libraries that simplify writing such locks. TinyOS itself is continually evolving. Within the TinyOS community, “Working Groups” form to tackle engineering and design issues within the OS, improving existing services and adding new ones. This book is therefore really a snapshot of the OS in time. As Chapter 12 discusses and Appendix 1 presents, TinyOS has a set of standard, stable APIs for core abstractions, but this set is always expanding as new hardware and applications emerge. The best way to stay up to date with TinyOS is to check its web page www.tinyos.net and participate in its mailing lists. The website also covers advanced TinyOS and nesC features which are well beyond the scope of this book, including binary components, over-the-air reprogramming services, debugging tools, and a nesC reference manual. 1.3 Example application To better understand the unique challenges faced by sensor networks, we walk through a basic data-collection application. Nodes running this application periodically wake up, sample some sensors, and send the data through an ad hoc collection tree to a data sink (as in Figure 1.1). As the network must last for a year, nodes spend 99% of their time in a deep sleep state. In terms of energy, the radio is by far the most expensive part of the node. Lasting a year requires telling the radio to be in a low power state. Low power radio implementation techniques are beyond the scope of this book, but the practical upshot is that packet transmissions have higher latency. [23] Figure 1.3 shows the four TinyOS APIs the application uses: low power settings for the radio, a timer, sensors, and a data collection routing layer. When TinyOS tells the application that the node has booted, the application code configures the power settings on the radio and starts a periodic timer. Every few minutes, this timer fires and the application code samples its sensors. It puts these sensor values into a packet and calls the routing layer to send the packet to a data sink. In practice, applications tend to be more complex than this simple example. For example, they include additional services such as a management layer which allows an administrator to reconfigure parameters and inspect the state of the network, as well as over-the-air programming so the network
  • 35. 8 Introduction Application Timer Routing Sensors Radio Figure 1.3 Example application architecture. Application code uses a timer to act periodically, sensors to collect data, and a routing layer to deliver data to a sink. can be reprogrammed without needing to collect all of the nodes. However, these four abstractions – power control, timers, sensors, and data collection – encompass the entire datapath of the application. 1.4 Compiling and installing applications You can download the latest TinyOS distribution, the nesC compiler, and other tools at www.tinyos.net. Setting up your programming environment is outside the scope of this book; the TinyOS website has step-by-step tutorials to get you started. One part of TinyOS is an extensive build system for compiling applications. Generally, to compile a program for a sensor platform, one types make <platform>, e.g. make telosb. This compiles a binary. To install that binary on a node, you plug the node into your PC using a USB or serial connection, and type make <platform> install. The tutorials go into compilation and installation options in detail. 1.5 The rest of this book The rest of this book goes into how to program in nesC and write TinyOS applications. It is divided into three parts. The first is a short introduction to the major programming concepts of nesC. The second part addresses basic application programming using standardTinyOSAPIs.Thethirdpartdigsalittledeeper,andlooksintohowthoseTinyOS APIs are implemented. For example, the third part describes how TinyOS abstracts hardware, so you can write a driver for a new sensor. Chapter by chapter, the book is structured as follows: • Chapter 1 is this chapter. • Chapter 2 describes the major way that nesC breaks from C and C-like languages: how programs are built out of components, and how components and interfaces help manage programs’ namespaces. • Chapter 3 presents components and how they interact via interfaces. • Chapter 4 goes into greater detail into configurations, components which connect other components together. • Chapter 5 covers the basic TinyOS execution model and gives guidance on how and when to use tasks.
  • 36. 1.5 The rest of this book 9 • Chapter 6 takes the material from the prior three chapters and brings it together into an example of writing a fully-fledged application that sends an alarm when a node observes a change in its environment. In the process, it covers the major TinyOS APIs (timing, sensing, communication, and storage). • Chapter 7 details the PC-side tools for communicating with nodes connected over the serial port, and covers the TinyOS serial stack and packet formats. • Chapter 8 introduces more advanced component topics, such as parameterized interfaces and attributes. While applications typically don’t use these mechanisms, they are indispensable when writing reusable libraries and systems. • Chapter 9 goes into wiring parameterized interfaces, which form the basis for most reusable systems.After describing the basic mechanisms for managing interface keys, it goes through four examples of increasing complexity. • Chapter 10 presents eight common TinyOS design patterns: commonly useful and powerful ways of organizing components. • Chapter 11 concludes the advanced programming topics by covering concurrency. It describes asynchronous code, the TinyOS task model, and power locks. • Chapter 12 describes the Hardware Abstraction Architecture (HAA), the three-level hierarchy TinyOS uses to raise low-level hardware abstractions to hardware-independent, application-level services. • Chapter 13 goes step-by-step through an advanced application that identifies the location of an event based on when nodes sense it. It uses lower-layer interfaces to implement time synchronization and high-frequency sampling. • Appendix gives a concise overview of major TinyOS application interfaces. Throughout the book, you will find programming hints: general best-use practices that we’ve distilled from the many users of TinyOS and nesC. These are all listed on the sheet at the front of the book. Finally, the complete source code for example applications presented in this book (in Chapters 6, 7 and 13) is available in TinyOS’s contributed code directory, under the name “TinyOS Programming” – see www.tinyos.net for details.
  • 37. 2 Names and program structure Program structure is the most essential and obvious difference between C and nesC. C programs are composed of variables, types, and functions defined in files that are compiled separately and then linked together. nesC programs are built out of components that are connected (“wired”) by explicit program statements; the nesC compiler connects and compiles these components as a single unit.To illustrate and explain these differences in how programs are built, we compare and contrast C and nesC implementations of two very simple “hello world”-like mote applications, Powerup (boot and turn on a LED) and Blink (boot and repeatedly blink a LED). 2.1 Hello World! The closest mote equivalent to the classic “Hello World!” program is the “Powerup” application that simply turns on one of the motes LEDs at boot, then goes to sleep. A C implementation of Powerup is fairly simple: # include " mote .h" int main () { mote_init (); led0_on (); sleep (); } Listing 2.1 Powerup in C The Powerup application is compiled and linked with a “mote” library which provides functions to perform hardware initialization (mote_init), LED control (led0_on) and put the mote in to a low-power sleep mode (sleep). The “mote.h” header file simply provides declarations of these and other basic functions. The usual C main function is called automatically when the mote boots.1 1 The C compiler, library, and linker typically arrange for this by setting the mote’s hardware reset vector to point to a piece of assembly code that sets up a C environment, then calls main.
  • 38. 2.1 Hello World! 11 The nesC implementation of Powerup is split into two parts. The first, the PowerupC module, contains the executable logic of Powerup (what there is of it …): module PowerupC { uses interface Boot ; uses interface Leds ; } implementation { event void Boot . booted () { call Leds . led0On (); } } Listing 2.2 PowerupC module in nesC This code says that PowerupC interacts with the rest of the system via two interfaces, Boot and Leds, and provides an implementation for the booted event of the Boot interface that calls the led0On2 command of the Leds interface. Comparing with the C code, we can see that the booted event implementation takes the place of the main function, and the call to the led0On command the place of the call to the led0_on library function. This code shows two of the major differences between nesC and C: where C programs are composed of functions, nesC programs are built out of components that implement a particular service (in the case of PowerupC, turning a LED on at boot-time). Furthermore, C functions typically interact by calling each other directly, while the interactions between components are specified by interfaces: the interface’s user makes requests (calls commands) on the interface’s provider, the provider makes callbacks (signals events) to the interface’s user. Commands and events themselves are like regular functions (they can contain arbitrary C code); calling a command or signaling an event is just a function call. PowerupC is a user of both Boot and Leds; the booted event is a callback signaled when the system boots, while the led0On is a command requesting that LED 0 be turned on. nesC interfaces are similar to Java interfaces, with the addition of a command or event keyword to distinguish requests from callbacks: interface Boot } { event void } booted (); } interface Leds { command void led0On (); command void led0Off (); 2 LEDs are numbered in TinyOS, as different platforms have different color LEDs.
  • 39. 12 Names and program structure command void led0Toggle (); ... } Listing 2.3 Simple nesC interfaces The second part of Powerup, the PowerupAppC configuration, specifies how PowerupC is connected to TinyOS’s services: configuration PowerupAppC { } implementation { components MainC , LedsC , PowerupC ; MainC . Boot -> PowerupC . Boot ; PowerupC . Leds -> LedsC . Leds ; } Listing 2.4 PowerupAppC configuration in nesC This says that the PowerupAppC application is built out of three components (modules or configurations), MainC (system boot), LedsC (LED control), and PowerupC (our powerup module). PowerupAppC explicitly specifies the connections (or wiring) betweentheinterfacesprovidedandusedbythesecomponents.WhenMainChasfinished booting the system it signals the booted event of its Boot interface, which is connected by the wiring in PowerupAppC to the booted event in PowerupC. This event then calls the led0On command of its Leds interface, which is again connected (wired) by PowerupAppC to the Leds interface provided by LedsC. Thus the call turns on LED 0. The resulting component diagram is shown in Figure 2.1 – this diagram was generated automatically from PowerupAppC by nesdoc, nesC’s documentation generation tool. PowerupAppCillustratesthethirdmajordifferencebetweenCandnesC:wiringmakes the connections expressed by linking the C version of Powerup with its “mote” library explicit. In the C version, Powerup calls a global function named led0_on which is connected to whatever library provides a function with the same name; if two libraries PowerupC MainC LedsC Boot Leds Figure 2.1 Wiring Diagram for Powerup application
  • 40. 2.2 Essential differences: components, interfaces, and wiring 13 .nc .nc .nc app.c binary nesC compiler Native C compiler Figure 2.2 The nesC compilation model. The nesC compiler loads and reads in nesC components, which it compiles to a C file. This C file is passed to a native C compiler, which generates a mote binary. provide such a function then (typically) the first one named on the linker command line “wins.” Using a nesC configuration, the programmer instead explicitly selects which component’s implementation of the function to use. The nesC compiler can take advantage of this explicit wiring to build highly optimized binaries. Current implementations of the nesC compiler (nesc1) take nesC files describing components as input and output a C file. The C file is passed to a native C compiler that can compile to the desired microcontroller or processor. Figure 2.2 shows this process. The nesC compiler carefully constructs the generated C file to maximize the optimization abilities of the C compiler. For example, since it is given a single file, the C compiler can freely optimize across call boundaries, inlining code whenever needed. The nesC compiler also prunes dead code which is never called and variables which are never accessed: since there is no dynamic linking in nesC, it has a complete picture of the application call graph. This speeds the C compilation and reduces program size in terms of both RAM and code. 2.2 Essential differences: components, interfaces, and wiring The three essential differences between C and nesC – components, interfaces, and wiring – all relate to naming and organizing a program’s elements (variables, functions, types, etc). In C, programs are broken into separate files which are connected via a global namespace: a symbol X declared in one file is connected by the linker to a symbol X defined in another file. For instance, if file1.c contains: extern void g( void ); /* declaration of g */ int main () /* definition of main */ { g(); g (); } and file2.c contains: void g( void ) { printf (" hello world !"); }
  • 41. 14 Names and program structure then compiling and linking file1.c and file2.c connects the calls to g() in main to the definition of g in file2.c. The resulting program prints “hello world!” twice. Organizing symbols in a global namespace can be tricky. C programmers use a number oftechniquestosimplifythistask,includingheaderfilesandnamingconventions.Header files group declarations so they can be used in a number of files without having to retype them, e.g. a header file file1.h for file1.c would normally contain: # ifndef FILE1_H # define FILE1_H extern void g( void ); /* declaration of g */ # endif Naming conventions are designed to avoid having two different symbols with the same name. For instance, types are often suffixed with _t guaranteeing that a type and function won’t have the same name. Some libraries use a common prefix for all their symbols, e.g. Gtk and gtk_ for the GTK+ graphical toolkit. Such prefixes remind users that functions are related and avoid accidental name collisions with other libraries, but make programs more verbose. nesC’s components provide a more systematic approach for organizing a program’s elements. A component (module or configuration) groups related functionality (a timer, a sensor, system boot) into a single unit, in a way that is very similar to a class in an object-oriented language. For instance, TinyOS represents its system services as separate components such as LedsC (LED control, seen above), ActiveMessageC (sending and receivingradiomessages),etc.Onlytheservice(component)nameisglobal,theservice’s operations are named in a per-component scope:ActiveMessageC.SplitControl starts and stops the radio, ActiveMessageC.AMSend sends a radio message, etc. Interfaces bring further structure to components: components are normally specified in terms of the set of interfaces (Leds, Boot, SplitControl,AMSend) that they provide and use, rather than directly in terms of the actual operations. Interfaces simplify and clarify code because, in practice, interactions between components follow standard patterns: many components want to control LEDs or send radio messages, many services need to be started or stopped, etc. Encouraging programmers to express their components in terms of common interfaces also promotes code reuse: expressing your new network protocol in terms of the AMSend message transmission interface means it can be used with existing applications, using AMSend in your application means that it can be used with any existing or future network protocol. Rather than connect declarations to definitions with the same name, nesC programs use wiring to specify how components interact: PowerupAppC wired PowerupC’s Leds interface to that provided by the LedsC component, but a two-line change could switch that wiring to the NoLedsC component (which just does nothing): components PowerupC , NoLedsC ; PowerupC . LedsC -> NoLedsC . Leds ; without affecting any other parts of the program that wish to use LedsC. In C, one could replace the “mote” library used by Powerup by a version where the LED functions did nothing, but that change would affect all LED users, not just Powerup.
  • 42. 2.3 Wiring and callbacks 15 2.3 Wiring and callbacks Leaving the component connection decisions to the programmer does more than just simplify switching between multiple service implementations. It also provides an efficient mechanism for supporting callbacks, as we show through the example of timers. TinyOS provides a variable number of periodic or deadline timers; associated with each timer is a callback to a function that is executed each time the timer fires. We first look at how such timers would be expressed in C, by modifying Powerup to blink LED 0 at 2 Hz rather than turn it on once and for all: # include " mote .h" timer_t mytimer ; void blink_timer_fired ( void ) { leds0_toggle (); } int main () { mote_init (); timer_start_periodic (& mytimer , 250 , blink_timer_fired ); sleep (); } Listing 2.5 Powerup with blinking LED in C In this example, the Blink application declares a global mytimer variable to hold timer state, and calls timer_start_periodic to set up a periodic 250 ms timer. Every time the timer fires, the timer implementation performs a callback to the blink_timer_fired function specified when the timer was set up. This function simply calls a library function that toggles LED 0 on or off. The nesC version of Blink is similar to the C version, but uses interfaces and wiring to specify the connection between the timer and the application: module BlinkC { uses interface Boot ; uses interface Timer ; uses interface Leds ; } implementation { event void Boot . booted () { call Timer . startPeriodic (250); } event void Timer . fired () {
  • 43. 16 Names and program structure call Leds . led0Toggle (); } } Listing 2.6 Powerup with blinking LED in nesC (slightly simplified) The BlinkC module starts the periodic 250 ms timer when it boots. The connection between the startPeriodic command that starts the timer and the fired event which blinks the LED is implicitly specified by having the command and event in the same interface: interface Timer { command void startPeriodic ( uint32_t interval ); event void fired (); ... } Finally, this Timer must be connected to a component that provides an actual timer. BlinkAppC wires BlinkC.Timer to a newly allocated timer MyTimer: configuration BlinkAppC { } implementation { components MainC , LedsC , new TimerC () as MyTimer , BlinkC ; BlinkC . Boot -> MainC . Boot ; BlinkC . Leds -> LedsC . Leds ; BlinkC . Timer -> MyTimer . Timer ; } Listing 2.7 Powerup with blinking LED configuration (slightly simplified) In the C version the callback from the timer to the application is a run-time argument to the timer_start_periodic function. The timer implementation stores this function pointer in the mytimer variable that holds the timer’s state, and performs an indirect function call each time the timer fires. Conversely, in the nesC version, the connection between the timer and the Blink application is specified at compile-time in BlinkAppC. This avoids the need to store a function pointer (saving precious RAM), and allows the nesC compiler to perform optimizations (in particular, inlining) across callbacks. 2.4 Summary Table 2.1 summarizes the difference in how programs are structured in C, C++ and nesC. In C, the typical high-level programming unit is the file, with an associated header file that specified and documents the file’s behavior. The linker builds applications out of files by matching global names; where this is not sufficient to express program structure (e.g. for callbacks), the programmer can use function pointers to delay the decision of which function is called at what point.
  • 44. 2.4 Summary 17 Table 2.1. Program Structure in C, C++ and nesC structural element C C++ nesC program unit file class component unit specification header file class declaration component specification specification pattern – abstract class interface unit composition name matching name matching wiring delayed composition function pointer virtual method wiring C++ provides explicit language mechanisms for structuring programs: classes are typically used to group related functionality, and programs are built out of interacting objects (class instances). An abstract class can be used to define common class specification patterns (like sending a message); classes that wish to follow this pattern then inherit from the abstract class and implement its methods – Java’s interfaces provide similar functionality. Like in C, the linker builds applications by matching class and function names. Finally, virtual methods provide a more convenient and more structured way than function pointers for delaying beyond link-time decisions about what code to execute. In nesC, programs are built out of a set of cooperating components. Each component uses interfaces to specify the services it provides and uses; the programmer uses wiring to build an application out of components by writing wiring statements, each of which connects an interface used by one component to an interface provided by another. Making these wiring statements explicit instead of relying on implicit name matching eliminates the requirement to use dynamic mechanisms (function pointers, virtual methods) to express concepts such as callbacks from a service to a client.
  • 48. 3 Components and interfaces This chapter describes components, the building blocks of nesC programs. Every component has a signature, which describes the functions it needs to call as well as the functions that others can call on it. A component declares its signature with interfaces, whicharesetsoffunctionsforacompleteserviceorabstraction. Modulesarecomponents that implement and call functions in C-like code. Configurations connect components into larger abstractions. This chapter focuses on modules, and covers configurations only well enough to modify and extend existing applications: Chapter 4 covers writing new configurations from scratch. 3.1 Component signatures A nesC program is a collection of components. Every component is in its own source file, and there is a one-to-one mapping between component and source file names. For example, the file LedsC.nc contains the nesC code for the component LedsC, while the component PowerupC can be found in the file PowerupC.nc. Components in nesC reside in a global namespace: there is only one PowerupC definition, and so the nesC compiler loads only one file named PowerupC.nc. There are two kinds of components: modules and configurations. Modules and configurations can be used interchangeably when combining components into larger services or abstractions. The two types of components differ in their implementation sections. Module implementation sections consist of nesC code that looks like C. Module code declares variables and functions, calls functions, and compiles to assembly code. Configuration implementation sections consist of nesC wiring code, which connects components together. Configurations are the major difference between nesC and C (and other C derivatives). All components have two code blocks. The first block describes its signature, and the second block describes its implementation: module PowerupC { configuration LedsC { // signature // signature } } implementation { implementation { // implementation // implementation } } Listing 3.1 The signature and implementation blocks
  • 49. Discovering Diverse Content Through Random Scribd Documents
  • 50. milestones in the onward march of democracy. The immigrant has not been unmindful of the blessings conferred upon him in this country. He has adjusted himself quickly to his new environment. In every crisis, he has faithfully stood by our country and institutions. He has striven to teach his children to love and honor the land which harbors them. All human history teaches us that the price of human liberty is the continuous enlargement of that liberty. The only safe principle of democracy is justice, equity, and equal respect among all our people. Great unfinished tasks remain for us to solve. Our common loyalty must hold high the torch and pass it on, with fire unquenched, to the citizen of tomorrow. Transcriber’s Note: Click image for larger version. IMMIGRATION FIGURES FOR SOME COUNTRIES FROM 1820-1936
  • 51. Recordings of “Americans All— Immigrants All” Many organizations, churches, schools, and colleges have requested that “Americans All—Immigrants All” be made available in recorded form. The Office of Education, by special arrangement with the Columbia Broadcasting System, the Committee on Scientific Aids to Learning, the American Federation of Musicians, and the Music Authors and Publishers Protective Association, have recordings for non-commercial use in both 33⅓ r.p.m. and 78 r.p.m. (suitable for use on phonographs). For complete information regarding the recordings, write to: Educational Radio Script Exchange, Radio Division, Office of Education, Washington, D. C. Transcriber’s Note: Click image for larger version. THEY HAVE BUILT A NATION TYPICAL CONTRIBUTIONS TO AMERICAN INDUSTRY AND CULTURE
  • 53. I Are People Really Different? “Democracy means not ‘I’m as good as you are’ but ‘you’re as good as I am.’”—Theodore Parker. mmigration has made the United States the most composite nation on earth. More peoples of widely different national and racial origins have been brought together and welded into a single political, economic, and social system than anywhere else in the world. What constitutes a race? Does each race have certain hereditary characteristics which determine its mental life and social behavior? Is there a racial stock which is superior—physically, mentally, and morally—to other racial stocks? Just what differences, if any, exist between those who were born here and those who have adopted this country as their home land? There is no such person as a native American, nor was there ever such a person if we are to be strictly accurate. We are told that even the American Indian is an immigrant who came from far-off Asia by way of the Bering Straits and Alaska. Our ancestors may have come on the Mayflower or in the steerage, we may be descended from immigrants who settled here generations ago, or we may have come direct from other lands, yet one fact remains crystal clear—WE ARE ALL IMMIGRANTS. Physical Characteristics From the physical standpoint, races do have certain very definite differences that are obvious. One of the most obvious is that of color. White, black, yellow, red, brown, and yellow-brown are the colors we usually associate with certain racial types. Some of us are tall, blond, and blue-eyed. Others are short, dark, and brown-eyed. Some people have long, narrow heads while others have short, round heads. However, the same physical differences may be found not only between racial and national groups, but also between individuals within the nation, tribe, or family. Mental Characteristics
  • 54. In answer to the contention that certain racial groups are mentally superior to others, Franz Boas, an outstanding scientist, says, “No one has ever proved that a human being through his descent from a group of people must of necessity have certain mental characteristics.... If we were to select the most intelligent, imaginative, energetic, and emotionally stable third of mankind, all races would be represented.” Hooton, another scientist, is even more emphatic. He declares that “each racial type runs the gamut from idiots and criminals to geniuses and statesmen. No type produces a majority of individuals from either end of the scale. There are no racial monopolies of either human virtues or vices.” Carefully controlled intelligence tests given by educators and scientists to different racial groups show that, where environment and social conditions are the same, no group can claim mental superiority. In fact, it has been clearly apparent that “man, everywhere, is basically and fundamentally similar” and that his differences, be they physical, mental, or moral, are determined not by race so much as by the social conditions and opportunities around him. Important Findings The assimilation of different groups within the United States would seem to show that: 1. Under favorable conditions of equal opportunity, all racial groups, whatever their original homeland conditions and status, are capable of rapid social change both as individuals and as groups. “It can easily be shown,” says one scientist, “how dependent mental differences are upon social conditions. For instance, exact observations have been made on Negroes who have moved from the country to the city and it has been shown that assimilation of these people to the behavior of the city population takes place within a few years. “Likewise, it has been shown in the case of Italian immigrants that they grow to resemble the Americans in behavior the longer they have been in this country, provided they do not remain isolated. One of the most instructive illustrations of this assimilation is the ease with which children adopt the dialect and manner of expression of their environment.” 2. All groups, under the stimulus of opportunity and contact, have capacity to produce exceptional individuals of high creative ability or genius and thus help build up and perfect human culture.
  • 55. The Nordic and Slav, the southern European and Jew, black, white, brown, and yellow have all produced men and women of outstanding brains and genius. To confirm these statements it is only necessary to read, in the pages that follow, the contributions of the immigrant and his descendants to American life. Research studies, conducted on an objective basis, prove that individual brilliance may be and is, found in all groups. 3. Under the influence of a common environment, physical and cultural, the offspring of different racial and national groups in a democracy tend toward a common culture with common customs and ideals. John Dewey has emphasized that, “in a democratic society, individuals give freely to others of the peculiar value, essence, quality, and contribution of the group to which they belong, and receive freely the corresponding treasures of other groups, and this without violence to the complete uniqueness of the group.” At birth, no individual has any culture and so the culture he eventually acquires is the one he finds around him and is capable of assimilating. However, “new conditions bring the need of new ideals and new emphasis on certain aspects of old ideals.” Civilization itself is not only safeguarded but advanced when a nation, composed of many races, finds it possible for each racial group to “function creatively in building the culture of the race into the whole culture pattern.” 4. Within the framework of common political and economic institutions, a variety of cultural elements makes for a richer and more active social culture. In all history, some of the most advanced civilizations have been the product of a mixture of cultures. No great nations or civilizations have been born in isolation. Inbreeding inevitably results in one-sidedness and, eventually, in stagnation and decadence. Spain was at its greatest “when the mixture of peoples was at its height.” England grew great because the ingredients of many racial groups ran in the Englishman’s blood. The United States will continue to be great because the intermingling of many groups tends to build a culture or civilization that unifies the best of their contributions. 5. A civilization of many different elements develops religious, social, and cultural tolerance. It also creates ability which may
  • 56. permit it to grow and change.
  • 57. Immigration from 1820 to 1936 Albania 2,846 Austria and Hungary 4,138,333 Belgium 155,024 Bulgaria 65,424 Czechoslovakia 110,928 Denmark 333,900 Estonia 1,839 Finland 18,310 France 588,023 Germany 5,938,822 Great Britain: England 2,629,335 Scotland 732,587 Wales 86,233 Not Specified 793,741 Greece 427,006 Ireland 4,588,464 Italy 4,692,447 Latvia 3,918 Lithuania 7,166 Luxemburg 854 Netherlands 249,059 Norway and Sweden 2,018,640 Poland 407,366 Portugal 254,499 Rumania 155,496 Russia 3,343,088 Spain 168,913 Switzerland 292,153 Turkey in Europe 155,568 Yugoslavia 53,394
  • 58. Other Europe 21,309 TOTAL FROM EUROPE 32,434,685 China 379,982 India 9,704 Japan 277,162 Turkey in Asia 205,317 Other Asia 38,858 ASIA COMPLETE TOTAL 911,023 Canada and Newfoundland 2,957,422 Mexico 768,453 Central America 46,919 West Indies 438,633 South America 117,649 Other America 40 AMERICA TOTAL 4,329,116 AFRICA 25,311 AUSTRALIA-NEW ZEALAND 53,739 PACIFIC ISLANDS 10,610 NOT SPECIFIED 254,066 TOTAL FROM ALL COUNTRIES 38,018,550 From 1931 to 1938, departures have exceeded admissions by 203,694.
  • 59. T Our Gifts to Science and to Agriculture he brawn, brain, and inventive genius of the immigrants and their descendants have made the United States a world leader in science and industry. In reading about this pageant of achievement, which is unique in human history, you will also learn something about the diverse racial origins of those who laid the gifts on the “altar of America.” Here they are— IMMIGRANTS! SONS OF IMMIGRANTS! AND SONS OF SONS OF IMMIGRANTS!—men and women who have thrilled the worlds of science and industry, the arts and crafts, and social progress and government. The italics indicate the racial origin of each individual or a major racial group from which he is descended, although it should be kept in mind that a person’s ancestors frequently include many racial strains. The achievements listed are suggestive rather than exhaustive. Medicine Use of cocaine as local anaesthetic first introduced by Carl Koller, German Jew ... ether first demonstrated to the world in surgical operation by William Morton, Scot ... first successful operation on human heart performed by Daniel H. Williams, Negro. Schick Diphtheria Test devised by Dr. Bela Schick, Hungarian Jew ... pioneer work in antiseptics by Henry Banga, Swiss, and many lives saved during World War through contributions to aseptic surgery of Alexis Carrel, French ... preventive compound for cholera and typhoid fever discovered by F. G. Novy, Slovak ... apparatus for electric blood transfusion perfected by D. J. Calicchio, Italian. Charles and William Mayo, Irish, have made surgery almost as reliable a science as bookkeeping ... Charles McBurney, Scotch-Irish, discovered McBurney’s Point as a sign for the necessity of operating for appendicitis. Discovery that the disease pellagra was due to faulty diet made by Joseph Goldberger, German Jew ... typhus and typhoid fever distinguished by Alfred
  • 60. Stillé, Swede ... human blood classified in different types by Karl Landsteiner, Austrian Jew ... research work in combatting syphilis and yellow fever by Hideyo Noguchi, Japanese. Expert on infantile paralysis and meningitis is Simon Flexner, German Jew ... first removal of human ovary by Ephraim MacDowell, Scot ... one of the famous authorities on plastic surgery is V. Kazanjian, Armenian ... world authority on venereal disease is Vecki Victor, Yugoslav ... Edward Trudeau, French, began sanatorium treatment for tuberculosis ... Clifford Beers, English-Netherlander, founder of mental hygiene movement. Discovery that mosquitoes carried yellow fever made by Walter Reed, English ... malaria driven out of Panama by General William C. Gorgas, Scotch-Irish-Netherlander ... first hospital in colonies founded by Dr. Thomas Bond, Welsh. Physics Our great electrical wizards have been: Joseph Henry, Scotch-Irish, who helped to invent the telegraph ... Charles Steinmetz, German-Polish, mathematical genius and electrical scientist, who had one of the world’s most inventive minds ... Thomas Edison, Scot-Netherlander, who invented electric light bulb and phonograph ... Michael Pupin, Yugoslav, who perfected tuning-in mechanism of radio.... Nicola Tesla, Yugoslav, who made extensive use of electrical power possible ... Vladimir Karapetoff, Armenian, inventor of electrical devices. Most distinguished physicist on light rays is Albert A. Michelson, German Jew ... on x-rays, Arthur H. Compton, English ... on cosmic rays, Robert Millikan, Scotch-Irish ... outstanding investigator of Röentgen ray is Mihran Kassabian, Armenian ... through work on electrotechnics, expansion of telephonic and telegraphic communication made possible by E. F. W. Alexanderson, Swede ... John Kruesi, Swiss, helped Edison develop electric incandescent lamp, dynamo, and phonograph. Astronomy First observatory put up by Ephraim Williams, Welsh ... many of our early- day almanacs based on astronomical studies and computations of David
  • 61. Rittenhouse, German-Welsh ... Lick Observatory, California, and Yerkes Observatory, Wisconsin, founded by James Lick and Charles Yerkes, Germans ... for pictures of many of the stars, Dorothy Klumpke, German, achieved much fame ... famous mathematician and everyday almanac maker was Benjamin Banneker, Negro, who also helped L’Enfant, French, to lay out Washington, D. C. Chemistry Ephedrin, drug used as base for cold remedies, discovered by K. K. Chen, Chinese ... adrenalin and diastase, discovered by Jokichi Takamine, Japanese ... grape sugar changed into tartaric acid by Mooshegh Vaygoony, Armenian ... George Washington Carver, Negro, made 145 products from peanut, 100 products from sweet potato, and 60 products from the pecan ... fermented milk product of high curative values discovered by H. M. Dadoorian, Armenian. Exploration A pilot on one of Columbus’ ships was Pedro Alonzo, Negro ... first explorers in New Mexico led by Estévanico, Moroccan ... first settlers of Alabama, who accompanied De Soto in 1540, were Robles, Negro, and Feryada, Greek ... first reliable map of Virginia and Maryland made by Augustine Herrman, Czech. Lewis, Welsh, and Clark, English, led the famous expedition to the Northwest ... 1903 Ziegler Expedition to the North Pole led by Anthony Fiala, Czech ... North Pole discovered by Robert Peary, French-English, accompanied by Matthew Henson, Negro ... first to fly across South Pole was Richard Byrd, English. Other Sciences First of American geologists was William McClure, Scot ... the great naturalist, John J. Audubon, French-Spanish, taught us about birds of America ... many inspired to study natural sciences by Louis Agassiz, French ... Henry D. Thoreau, Huguenot, was great naturalist and writer ... famous
  • 62. anthropologists are Franz Boas and Edward Sapir, German Jews, and Ales Hrdlicka, Czech. International authority on zoology and botany is Leonhard Steiniger, Norwegian ... expert on function of cell and fertilization is Ernest Just, Negro ... first botanical garden in world founded near Philadelphia by John Bartram, Welsh, early in 18th century ... public garden, established in Georgia by General Oglethorpe, English, served as our first agricultural experiment station ... scientific breeding of plants demonstrated by Luther Burbank, English- French-Netherlander-Scot. Philosophers Famous philosophers: Wm. James, Welsh-English ... John Dewey, Irish ... Santayana, Spaniard ... Jiddu Krishnamurti, Hindu. Agriculture First vineyard in our country was set out by Jean Jacques Dufour, Swiss ... oranges, olives, dates, and grapes were brought to California by Fray Junipero Serra, Spaniard ... fig cuttings were imported by Denotovitch of Fresno, Yugoslav ... wild strawberry developed into large table variety by Johann Schwerdkopf, German, who came to Long Island before Revolutionary War. Alfalfa seed, known as Lucerne, brought to Minnesota and developed by Wendelin Grimm, German, in 1858 ... hardy alfalfa for prairies of northwest, brought from Siberia and Turkestan by Niels Hansen, Dane ... mower and reaper invented by Cyrus McCormick, Scotch-Irish. Simple tests to determine whether soil needs nitrogen, phosphates, or potash devised by George Hoffer, German ... pasteurization introduced by Julius Moldenhawar, Dane ... orange that will stay on tree for months after ripening propagated by Lue Gim Gong, Chinese ... honey industry revolutionized by Frank Jaeger, Yugoslav. Early cooperative creamery at Clark’s Grove, Minn., organized under leadership of Hans Jensen, Dane ... first to find trichina spiralis in hogs and hookworm in cats was Joseph Leidy, German ... International Institute of Agriculture established by David Lubin, Polish-Jew.
  • 64. Our Gifts to Industry and Commerce Inventions First clock in America constructed to strike the hours built by Benjamin Banneker, Negro, in 1790 ... early flour-milling machinery by Oliver Evans, Welsh ... iron comb, made by a Negro to help cotton pickers, gave Eli Whitney, English, idea for his cotton gin ... screw propeller and revolving turret on battleship invented by John Ericsson, Swede ... first patent to a Negro granted to Henry Blair for corn harvester in 1834 ... comb-making machine built by Nathaniel Jones, Welsh. First zipper fastener invented by Gideon Sundbäck, Swede ... green coloring matter used in our paper dollar invented by Dr. Seropian, Armenian ... machine for lasting shoes built by Jan Matzeliger, Haitian, in 1852 ... self- starter automobile clutch invented by Victor Bendix, Swede; also developed four-wheel brakes and carburetor ... steam-boiler furnace, electrical air- brakes, and incubator invented by Granville T. Woods, Negro ... inventor of carborundum was E. G. Acheson, English. Sewing machine invented by Elias Howe, English, in 1846 ... lubricating cup, used on locomotives and marine engines, invented by Elijah J. McCoy, Negro ... discovery of artificial rubber by Father Nieuland of Notre Dame, Belgian, broke the British hold on rubber ... induction motors invented by Nicolas Tesla, Yugoslav ... co- discoverer of process for making luminous paints was John Sochocky, Ukrainian ... fireproof stairs and library bookstacks invented by Neils Poulson, Dane ... Stilson wrench invented by Daniel Stilson, Swede, in 1875. Bakelite, a substitute used for ivory and bone in making toilet articles, invented by Leo Baekeland, Belgian. He discovered velox, a paper used by photographers, and made several other discoveries through experimenting with the electrolytic cell ... one of our earliest elevators was built by Dr. Nils Collins, Swede, a Philadelphia pastor ... the condensor used in radios and electric motors is the result of work done by Alexander Georgiev, Bulgarian ... numerous inventions of a wide and varied nature in connection with steam
  • 65. turbines were developed by Oscar Junggren and by Carl Söderburg, Swedes ... huge machines used for knitting are the invention of Ladislaus Robaczynski, Armenian ... outstanding typewriter designer is Carl Gabrielson, Swede. Airbrake invented by George Westinghouse, English-Netherlander ... “scientific divining rod” used in electro-magnetic method of locating metal ore, petroleum, and other minerals devised by Hans Lundberg and Karl Sundberg, Swedes ... in inventing telephone transmitter and motion-picture projector, Edison, Scot-Netherlander, helped by Emile Berliner, German Jew ... accuracy gauges from which precision machinery is made, invented by Carl Johannson, Swede ... process for making artificial stone invented by Michael Tymofiev, Ukrainian ... pioneer in radio work and sound motion pictures was Lee De Forest, French-English. Transportation First steamboat built and taken down Ohio and Mississippi by Nicholas Roosevelt, Netherlander ... first elevated railroad in New York City was built by José Francisco de Navarro, a Spaniard, in 1878 ... first demonstration of steam railroad in practice by John Stevens, English, in 1825 ... the Clermont, our first commercially successful steamboat, built by Robert Fulton, Irish ... greatest of clipper ships, Rainbow and Sea Witch, built by John Griffith, Welsh ... wagons and automobiles produced by Studebaker Brothers, German. Inventor of modern suspension bridge was John Roebling, German, who built beautiful Brooklyn Bridge ... the Niagara cantilever bridge, for heavy railroad traffic, invented by Charles Schneider, German ... the Northwest opened up by railroad builder James J. Hill, Scotch-Irish ... transatlantic flier, Charles Lindbergh, and airship commander, Charles Rosendahl, Swedes. Manufacturing Window glass manufactured by Caspar Wistar, German, in 1739 ... decorative stoves and glass of highly prized nature manufactured in 18th century by Heinrich Stiegel, German ... the New England cotton mills established by Samuel Slater, English ... first to unite all processes for manufacturing finished cloth in one factory was Patrick Jackson, Irish ... art of making gunpowder perfected by Eleuthere Dupont, French.
  • 66. Great steel works of Pittsburgh founded by Andrew Carnegie, Scot, assisted by William Jones, Welsh ... iron and steel industries of Pueblo, Colorado, established by Daniel Jones, Welsh ... famous pioneer organ builder, Matthias Moller, a Dane ... pianos and other instruments by Steinway, Knabe, Weber, Wurlitzer, Gemünder, Germans ... steel manufactured by Charles Schwab, German ... sugar produced by Havemeyer, German ... food products by Heinz and Fleischmann, Germans ... world-noted cymbals made by Zildijian, Armenian ... airplane builders are Igor Sigorsky, Russian; Bellanca, Italian; Douglas, Scot; Boeing, German; and Curtiss, English-German. Communication The telephone was invented by Alexander Graham Bell, Scot ... the telegraph was invention of Joseph Henry and Samuel Morse, Scotch-Irish ... steam- cylinder printing press, making possible our great daily newspapers, was brain child of Robert Hoe, English ... Erie Canal built by DeWitt Clinton, Irish- Netherlander ... long distance telephone and wireless telegraphy made possible by Michael Pupin, Yugoslav ... inventor of wireless switch was Fritz Lowenstein, German Jew ... new device for transmitting radio photographs by Arthur Korn, German Jew ... loud speaker invented by Peter Jensen, Dane ... Zworykin, Russian, pioneered in television ... first printing press imported to California by Agustin Zamorana, Spaniard. Commerce One of the largest cotton gins owned by Scott Bond, Negro ... our leading industrialists include Astor, Vanderbilt, and Rockefeller, Germans ... Julius Rosenwald, Chicago mail-order executive, German Jew ... Alfred Knudsen, Dane, automobile manufacturing executive. Leading rug merchants are Karaghuesian, Gulbenkian, Kelekian, and Pushman, Armenians ... leading linen and lace merchants are Mallouk, Kassab, Bardwill, Jabara, Mamary, and Boutross, Syrians ... largest raiser of orchids and specialist in cacti is J. A. Manda, Yugoslav ... first American circus opened in Baraboo, Wisconsin, in 1854, by Ringling Brothers, German ... Virginia tobacco trade founded by Augustine Herrman, Czech ... gas first introduced in 1830 by Edward Jones, Welsh, in Boston.
  • 67. Mining First oil well drilled at Titusville, Pa., by Edwin Drake, English, in 1859.... In Texas, oil was first struck by Anthony F. Lucas, Yugoslav ... coal in Pennsylvania first discovered by William Jones, Welsh ... pioneer miner of Colorado was Vaso Chakovic, Yugoslav ... first California gold found on ranch of John Sutter, German-Swiss ... eminent mining industrialists include Simon and Daniel Guggenheim, Swiss Jews, and Adolph Lewisohn, German Jew. Banking Leading bankers include: J. Pierpont Morgan, Welsh ... Nathan Straus, Felix Warburg, Jacob Schiff, Otto Kahn, and James Speyer, German Jews ... Charles G. Dawes, English ... Amadeo Gianini, Italian ... and Jesse Jones, Welsh. Building First American iron sea-going steamship built in 1859 by José Francisco de Navarro, Spaniard, who also laid foundation of cement business in this country ... Panama Canal built by General Goethals, Netherlander ... George Washington Bridge built by Othmar Ammann, Swiss ... Manhattan Bridge in New York and Interstate Bridge connecting Philadelphia and Camden built by Leon Moisseff, Russian. Hetch Hetchy water system from Sierra Nevada to San Francisco built by Michael O’Shaughnessy, Irish ... Ralph Modjeski, Polish Jew, chairman, Board of Engineers, San Francisco-Oakland Bridge ... Peter Demyanoff, Russian, railroad builder.
  • 68. Our Gifts to the Arts and Crafts Literature Outstanding novelists have been James Fenimore Cooper, English-Swedish; Oliver W. Holmes, English-Netherlander; Mark Twain, English; Wm. Dean Howells, Welsh-Irish-English-German; Mary Wilkins-Freeman, English; Nathaniel Hawthorne, Irish; Theodore Dreiser, German; James W. Johnson, Negro; Frank Norris, English; Booth Tarkington, English; Fannie Hurst, Edna Ferber, and Ludwig Lewisohn, German Jews; Jacob Riis, Dane; Louis Adamic, Yugoslav. Our leading poets include, Longfellow, Lowell, and Whittier, English; Edgar A. Poe, Scotch-Irish-English; Walt Whitman, English-Netherlander; Sidney Lanier, French; Eugene Field, English; Robert Frost, Scotch-English; Edwin Markham, English; James W. Riley, Netherlander-English; Carl Sandburg, Swede; Edna St. Vincent Millay, English-French; Joaquin Miller and Joyce Kilmer, Germans; Louis Untermeyer, German Jew, and Arthur Guitermann, Austrian Jew; Christopher Morley, Irish; Phillis Wheatley and Paul Dunbar, Negroes. Pioneer heroism immortalized by O. E. Rölvaag, Norwegian.... Good literature circulated in humble homes by P. F. Collier, Irish ... historian, writer, and lecturer, William Hendrik van Loon, Netherlander. Music Father of our orchestras and founder of Handel and Haydn Society was Gottlieb Graupner, German ... first organ builder and maker of spinets was
  • 69. Gustaf Hesselius, Swede ... our first important composer was Ernst Bloch, Swiss Jew. “Carry Me Back to Old Virginny” composed by James Bland, Negro ... “Johnny Comes Marching Home” composed by Patrick Gilmore, Irish ... “Old Folks at Home,” by Stephen Foster, Scotch-Irish ... an Italian, Campanini, was first director and leader of Metropolitan ... Gatti Casazza, Italian, famous director of Metropolitan ... organizer of Flonzaley Quartet was Alfred Pochon, Swiss. Famous composers include: Victor Herbert, Irish; Edward MacDowell, Scot; John Philip Sousa, Portuguese; Percy Grainger, Australian; Eugene Goosens, English; Howard Hanson, Swede; William Grant Still, Negro; Daniel Protheroe, Welsh; Sigmond Romberg, German Jew; George Gershwin and Irving Berlin, Russian Jews; Alma Glück, Roumanian; Rudolf Friml, Czech. Outstanding conductors include Gabrilowitch, Russian Jew; Walter and Klemperer, German; Koussevitsky and Smallens, Russian Jews; Stokowski, Polish; Ormany and Rapee, Hungarians; Ganz, Swiss; Koshetz, Ukrainian; Zilotti, Russian; Busch, Dane; Kindler, Netherlander; Damrosch, German; Rodzinsky, Yugoslav; Victor Kolar, Czech. Leading violin players of world-wide fame are: Elman, Heifetz, Zimbalist, Russian Jews; and Yehudi Menuhin, Roumanian Jew; Ysaye, Belgian; Dvonc, Czech; Prydatkevich, Ukrainian. Famous pianists include Rachmaninoff, Russian; Iturbi, Spaniard; Honti, Hungarian. Leading flutist is Callimahos, Greek; noted zylophonist is Y. Hiraoka, Japanese. Among the great concert artists are Sophie Braslau, Russian Jew; Lotte Lehmann, German; Rosa Raisa, Italian Jew; Schumann-Heink, Austrian; John Charles Thomas, Welsh, and Paul Robeson, Jules Bledsoe, Marian Anderson, Roland Hayes, Negroes. Art Father of American painting was Benjamin West, English ... portraits of Washington, Adams, Jefferson, and Madison by Charles Gilbert Stuart, Scot ... “Washington Crossing the Delaware,” by Emmanuel Lutze, German ... famous
  • 70. portraits by John Copley, Irish ... famous etchings by Joseph Pennell, English- Irish ... “Artist’s Mother” by James McNeil Whistler, Scotch-Irish. “Swing Low, Sweet Chariot” by Malvin Johnson, Negro ... “Return of Prodigal Son” by Henry Mosler, German Jew ... “Gassed” and portraits by John S. Sargent, English-Italian ... “Autumn Oaks” by George Inness, Scot ... “Conquerors”—building of Panama Canal—by Jonas Lie, Norwegian ... “Resurrection of Lazarus” by Henry O. Tanner, Negro ... “Still Life” by Yasu Kuniyoshi, Japanese. First modernist in America was Arthur Davies, Welsh ... corrupt Tweed ring in New York City smashed by cartoons of Thomas Nast, German ... leader in landscape painting, Frederick Detwiller, Swiss ... master of miniatures, Malthe Hasselriis, Dane ... famous frescoes in National Capitol by Brumidi, Italian ... illustrator of folk tales and fairy stories, Willie Pogany, Hungarian ... journalistic cartoons by Harrison Fisher, Czech. Sculpture “Puritan,” “Shaw Memorial,” and other statues by Saint-Gaudens, Irish-French ... “Memory” and “Lincoln” statues by Daniel Chester French, English ... work on Stone Mountain, Georgia, and Mt. Rushmore, South Dakota by Gutzon Borglum, Dane ... “Pioneer Mother” at Kansas City by Phimester Proctor, Canadian ... “The Sower” on the Nebraska State Capitol by Lee Lawrie, German ... statues of Indians by Ivan Mestrovic, Yugoslav ... McKinley monument by Haig Patigian, Armenian. Italian sculptors who helped adorn National Capitol were: Franzoni, bronze clock with statue of Storia on top ... Valperti, emblematic eagle ... Amateis, bronze doors ... Causici, Statue of Liberty Proclaiming Peace ... Trentanove, “Pere Marquette” statue ... Vincenti, Indian chief, Be-she-ke. Architecture Skyscraper developed by Louis Henry Sullivan, Irish-French-German ... Fanueil Hall, Boston, designed by John Smibert, Scot ... Vieux Carrè, New Orleans, laid out by Adrien de Pauger, French ... foremost architect in stone was Henry Richardson, English ... Frank Lloyd Wright, Welsh, harmonized
  • 71. buildings with surroundings ... St. Patrick’s Cathedral, New York City, built by Joseph Zvak, Czech ... prominent naval architect is Wm. Hovgaard, Dane. City planning by Eliel Saarinen, Finn ... Bertram Goodhue, Scot-English, developed and refined Gothic in public buildings ... Folger Library and Pan-American Building in Washington by Paul Cret, Belgian ... banks and office buildings by Stephen Voorhees, Netherlander ... church architecture by Ralph Cram, German, and Charles Maginnis, Irish. Motion Pictures Outstanding motion-picture stars: Antonio Moreno, Spaniard ... Luise Rainer, Austrian ... Charles Laughton and Ronald Colman, English ... Francis Lederer, Czech ... Jean Hersholt, Dane ... Pola Negri, Pole ... Anna Sten, Ukrainian ... Laura La Plante, Yugoslav. Leading producers: Mayer, Lasky, Warner, Russian Jews, and Goldwyn, Polish Jew ... pioneers of industry were D. W. Griffith, Welsh, Zukor and Fox, Hungarian Jews, and Loew, German Jew ... technique of cinematography modernized by Vorkepic, Yugoslav. Theatre Pioneer of modern American theatre, Augustin Daly, Irish ... geniuses of the theatre include Belasco, Portuguese Jew; Frohmans, Shuberts, Selwyn, Warfield, Hammerstein, German Jews, and Nazimova, Russian Jew ... John Drew, Irish ... Richard Mansfield, Julia Marlowe, and Barrymores, English ... Paul Robeson, Negro ... the magician, Houdini, Hungarian. Journalism New York Weekly Journal founded by Peter Zenger, German, in 1733 ... New York Tribune founded by Horace Greeley, Scotch-Irish ... publisher of St. Louis Post-Dispatch and New York World was Joseph Pulitzer, Hungarian Jew ... first
  • 72. great newspaper syndicate established by S. S. McClure, Irish ... magazine, famous as a militant muckraker founded by P. F. Collier, Irish. First modern newspaper, the New York Morning Herald, founded in 1835 by James G. Bennett, Scot ... New York Times founded by Henry Raymond, Scot, and George Jones, Welsh ... chain of newspapers founded by James Scripps, English ... chain of newspapers founded by Wm. Randolph Hearst, Scotch- English ... editor of a ladies’ magazine, Edward Bok, Netherlander.
  • 73. Our Gifts to Social Progress and Government Declaration of Independence, written by Thomas Jefferson, Welsh, signed by 1 Swede, 3 Irish, 4 Scots, 5 Welsh, 5 Scotch-Irish, 38 English, with John Morton, Swede, casting deciding ballot ... the thirteen colonies were christened the “United States of America” by Thomas Paine, English. Social Welfare Our first social reformer was Robert Owen, Welsh ... first one to make use of music in social work was Wm. van de Wall, Netherlander ... founder of Red Cross, Clara Barton, English ... founder of Chicago’s famous Hull House was Jane Addams, English ... slums attacked by Jacob Riis, Dane, in “How Other Half Lives” ... welfare library on Ellis Island organized by Rev. John Kweetin, Latvian ... anti-saloonist and feminist, Carrie Chapman Catt, English-German ... Atlanta School of Social Work, directed by Forrester Washington, Negro ... Lillian Wald, German Jew, a social-welfare leader ... famous home for boys, Father Flanagan, Irish. Government and Politics Two-thirds of our presidents, including Washington, are of English descent ... Martin van Buren and Herbert Hoover, German ... Theodore Roosevelt and Franklin Roosevelt, Netherlanders ... Jefferson, Madison, John Adams, John Q. Adams, Harrison, and Garfield, Welsh ... Monroe, Hayes, Grant, Wilson, and McKinley, Scots. Among our leading statesmen were Hamilton, Calhoun, Webster, Jefferson Davis, Scot-Welsh ... James Blaine, Chauncey Depew, Stephen Douglas, mainly Scots ... Patrick Henry, Scot-English-Welsh ... leading civil service and tariff reformer was Carl Schurz, German ... iron puddler who became Secretary of Labor, James J. Davis, Welsh.
  • 74. First governors: of Delaware, John McKinley; Georgia, John Houston; Illinois, John Boyle; Kansas, James Denver; Louisiana, Wm. Claiborne, Irish or Scotch-Irish ... present governor of New York, H. H. Lehman, German Jew; of Illinois, Henry Horner, German Jew ... first governor general of Florida, Bouquet, Swiss ... first president of the Republic of Texas, Sam Houston, Scot. Tammany Society, founded in 1789 by William Mooney, Irish, as protest against attempt of wealthy Tories to prevent soldiers and others from voting ... first Secretary of Treasury under Jefferson, responsible for arranging Louisiana Purchase, was Albert Gallatin, Swiss ... first to fight for conservation of our forests was Carl Schurz, German. Philanthropy Astor Library, now part of New York Library, founded by John Jacob Astor, German, in 1848 ... 4,000 Negro schools founded by Julius Rosenwald, German Jew ... Chautauqua movement begun by Lewis Miller, German ... gifts during panic of the 90’s, penny meals during World War, foodships to Palestine, and Milk Fund by Nathan Straus, Austrian Jew ... $42,000,000 gift to General Education Board by John D. Rockefeller, German. Libraries founded throughout United States by Andrew Carnegie, Scot ... funds raised to bring Statue of Liberty from France by Joseph Pulitzer, Hungarian Jew ... appreciation of arts and literature stimulated by Edward Bok, Netherlander ... Boy Scouts of America helped by Jacob and Mortimer Schiff, German Jews ... $6,000,000 to Princeton University by H. C. Frick, German. Colgate University founded by Wm. Colgate, English ... $122,000 to Fisk University by James Burrus, Negro ... foundations for opportunities to study abroad and to promote well-being of mankind established by Simon and Daniel Guggenheim, Swiss Jews. Champions of Human Liberty Protest against slavery by Pastorius, German ... author of “Common Sense,” “The Crisis” and “Public Good” was Thomas Paine, English ... powerful leaders against slavery were John Russworm, Benjamin Banneker, David Walker,
  • 75. Harriet Tubman, William Brown, William Still, Samuel Ward, Frederick Douglass, Negroes. Peter Zenger, German, defended by Andrew Hamilton, Scot, registered great triumph for freedom of press when he won his fight against Governor Cosby of New York. National Defense Minutemen roused by Paul Revere, Huguenot ... drill- master of Continental armies, who helped to plan West Point, was Frederick von Steuben, German ... $600,000 advanced to Congress and subsidies negotiated from France and the Netherlands by Haym Solomon, Polish Jew ... father of American cavalry was General Casimir Pulaski, Pole. First to lose life in Revolutionary War was Chrispus Attucks, Negro ... first commodore of Navy was John Barry, Irish ... naval hero John Paul Jones, Scot ... $5,000,000 contributed toward War of 1812 by Stephen Girard, French ... famous privateer, who abolished corporal punishment in the Navy, was Uriah Levy, Jew ... British defeated on Lake Erie by Captain Perry, Scotch-Irish. Labor First president of American Federation of Labor, who improved living standards of workers was Samuel Gompers, English Jew ... leader of C. I. O., John L. Lewis, Welsh ... organizer of coal miners, John Mitchell, Welsh ... president of A. F. of L., William Green, English-Welsh ... leader of Amalgamated Clothing Workers, Sidney Hillman, Lithuanian Jew. Religious Work Participating in Washington’s Inaugural was Rabbi Seixas, Portuguese Jew ... one of our greatest clergymen, Jonathan Edwards, Welsh ... leader in welfare and religious work, Huie Kin, Chinese ... first Protestant missionary to West Indies was George Lisle, former Negro slave ... professor of theology at Hartford Seminary, N. Y. Ananigian, Armenian ... authority on early church history is Prof. La Plana, Albanian.
  • 76. Education First book on pedagogy published in 1770 by Christopher Dock, German ... Harvard University named after John Harvard, English; Yale University by Elihu Yale, Welsh; William and Mary by James Blair, Scot; Brown University by Morgan Edwards and Samuel Jones, Welsh ... New York University by Gallatin, Swiss ... Tuskegee Institute by Booker Washington, Negro, world-famed educator ... Williams College by Ephraim Williams, Welsh ... one of incorporators of Columbia University was Rabbi Seixas, Portuguese Jew ... Hunter College by Thomas Hunter, Irish ... Creighton University, Omaha, by Creighton brothers, Irish ... Princeton University founded by Scottish Presbyterians ... Barnard College founded by Annie Nathan Meyer, German Jew. Infant school introduced in 1816, by Robert Owen, Welsh ... first German kindergarten introduced in Wisconsin in 1855 by wife of Carl Schurz, German ... a primer, first book produced in Pennsylvania, written by Franz Pastorius, German, headmaster of first school in Germantown ... College of Journalism at Columbia University founded by Joseph Pulitzer, Hungarian Jew ... School of Mines founded by Adolph Lewisohn, German Jew ... first English kindergarten founded in Boston in 1860 by Elizabeth Peabody, English ... father of modern American education was Horace Mann, English. World-famous orientalist P. K. Hitti, Syrian ... one of foremost educators was Henry Suzallo, Yugoslav ... Angelo Patri, Italian, counsels parents and children ... one of our greatest economists was Thorstein Veblen, Norwegian. Law and Order First Chief Justice of Supreme Court was John Jay, French ... present Chief Justice Charles Evans Hughes, Welsh ... one of foremost authorities on international law is Stephen Ladas, Greek. Finns work the iron-ore fields of northern Minnesota. ... Netherlanders and Poles developed wood-working trades of Michigan.... Italians, Portuguese, Greeks, and Swiss have built up the grape and wine industry of California.... Greek candy-makers.... Mexicans and Japanese in beet fields of Colorado,
  • 77. Welcome to Our Bookstore - The Ultimate Destination for Book Lovers Are you passionate about books and eager to explore new worlds of knowledge? At our website, we offer a vast collection of books that cater to every interest and age group. From classic literature to specialized publications, self-help books, and children’s stories, we have it all! Each book is a gateway to new adventures, helping you expand your knowledge and nourish your soul Experience Convenient and Enjoyable Book Shopping Our website is more than just an online bookstore—it’s a bridge connecting readers to the timeless values of culture and wisdom. With a sleek and user-friendly interface and a smart search system, you can find your favorite books quickly and easily. Enjoy special promotions, fast home delivery, and a seamless shopping experience that saves you time and enhances your love for reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookgate.com