O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Embedded Programming with the Microsoft® .NET Micro Framework

Book Description

Learn how to use the Microsoft .NET Micro Framework to develop applications for the next generation of embedded devices. Embedded programming is set to move into the mainstream as a variety of new devices come to market. A key embedded device enabled by Windows Vista™ that requires the .NET Micro Framework is Windows SideShow™, the external display that will be incorporated into many notebook computers. This reference shows developers how to use the .NET Micro Framework to create new applications for Windows SideShow displays and small, resource-constrained devices. With insights direct from the product team it covers essential topics, including interface design and managed drivers, device capabilities, and how to use emulation technologies. In addition, it delves into how to port key functionality from existing applications into other form factors. Ideal for developers with experience working with Microsoft Visual Studio® 2005 and Microsoft Visual C#®, this essential guide includes practical examples and code samples.

Table of Contents

  1. Embedded Programming with the Microsoft .NET Micro Framework
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. Acknowledgments
    3. Foreword
    4. Introduction
      1. Who This Book Is For
      2. System Requirements
      3. Code Samples
      4. Support for This Book
        1. Questions and Comments
    5. I. Preliminaries
      1. 1. Small, Connected Devices Built on the .NET Micro Framework
        1. Why Did Microsoft Create the .NET Micro Framework?
        2. How Does the Framework Fit with Microsoft's Embedded Products?
        3. What Is the .NET Micro Framework?
          1. A Bootable Runtime
          2. The .NET Micro Framework
          3. The .NET Micro Framework HAL
          4. Framework Libraries
          5. User Interface "Shell"
          6. Visual Studio Integration
          7. System Requirements
            1. Runtime
            2. Development Environment
        4. Conclusion
      2. 2. Introduction to .NET and the .NET Micro Framework
        1. .NET and the .NET Micro Framework
          1. .NET and the Needs of the Developer
          2. Managed Code on the .NET Micro Framework
          3. Compilers and Code Generation
          4. The .NET Framework
            1. The Common Language Infrastructure
            2. Just-In-Time Compilation
            3. .NET Micro Framework Challenges
          5. An Object-Based Representation of Hardware
            1. Memory-Mapped Input/Output
            2. Bit-Based Control
            3. Ports as Object Instances
        2. Conclusion
      3. 3. Getting Started
        1. Integrating with Visual Studio
        2. Installing the .NET Micro Framework SDK
        3. Creating a New Project
          1. Exploring the .NET Micro Framework Libraries
        4. Project Settings
        5. The Default C# Code
        6. Building, Deploying, and Executing
        7. Interactive Debugging
        8. Deploying to a Target Device
        9. Conclusion
    6. II. Making the .NET Micro Framework Work for You
      1. 4. Building a Device
        1. The Ultimate Flashlight
        2. Driving the Output
          1. Creating an Output-Port Object
          2. Instances and References
          3. Controlling Objects
        3. An Input-Port Object
        4. A Complete Program—Our First Flashlight
        5. Inputs with Events
          1. Methods and Delegates
          2. An Interrupt-Handler Method
          3. Connecting an Interrupt Handler to an Event
        6. A Complete Program—A Flashlight Using Interrupts
          1. Classes and Data Members
          2. Inheritance and Ports
          3. Objects and Devices
        7. Implementing a Flashlight-Finder Feature Using Threads
          1. Foreground and Background Threads
          2. Thread Synchronization
          3. Creating Threads
        8. Implementing a Flashlight-Finder Feature Using a Timer
        9. A Data-Logging Flashlight
          1. Creating a Data Storage Class
            1. The ToString Method in a Class
            2. Class Constructors
            3. Constructors, Errors, and Exceptions
          2. Exceptions in C#
            1. Throwing an Exception
            2. Catching an Exception
            3. Extracting Information from an Exception
            4. Exceptions and the finally Block
            5. Exceptions and Design
          3. Logging the Data
            1. Creating an Array
            2. Storing Log Records in an Array
            3. Storing Log Records in an ArrayList
            4. ArrayLists and Data Types
          4. Exporting Data via the RS-232 Serial Port
            1. Configuring and Creating an RS-232 Serial Port Instance
            2. Transmitting Data to an RS-232 Serial Port
            3. Receiving Data from a Serial Port
        10. Conclusion
      2. 5. Developing for the .NET Micro Framework
        1. Retaining Data
          1. Data Storage Hardware
          2. Storing Data
            1. Weak References
            2. Weak Delegates
            3. Retaining Data with Extended Weak References
          3. Restoring Persisted Data
            1. Creating an Extended Weak Reference
            2. Setting Extended Weak Reference Properties
            3. Recovering Persisted Data from an Extended Weak Reference
          4. Persistence and the Emulator
        2. Building Device Software Components
          1. An Embedded, Event-Driven Software Component
          2. GPS Component State and Properties
            1. Improving Flexibility by Using Components
            2. Improving Reusability by Using Components
            3. Improving Component Testability by Using Components
            4. Improving Device Testability by Using Components
          3. Creating a Message Pump
          4. C# Interfaces
          5. Design with Components and Interfaces
        3. Programming for Performance
          1. Improving Iteration
          2. Accessing Member Data
            1. Member Data and Properties
          3. Performance and Class Hierarchies
          4. Data Types and Performance
          5. Wait Loops and System Performance
            1. Wait Loops and Power Consumption
          6. Object Management
            1. String Manipulation
        4. Conclusion
      3. 6. Networking
        1. Getting Connected
          1. The OSI Model
          2. Layer 1: Physical
          3. Layer 2: Data Link
          4. Layer 3: Network
          5. Layer 4: Transport
          6. Layer 5: Session
          7. Layer 6: Presentation
          8. Layer 7: Application
        2. Client/Server Model
        3. Peer-to-Peer Model
        4. Microsoft.SPOT.Net
          1. Network Information
            1. Network Interfaces
            2. Ipconfig
        5. TCP/IP Programming with Sockets
          1. Ports
          2. UDP
          3. TCP
        6. The System.Net Namespace
          1. The Dns Class
        7. System.Net.Sockets Namespace
          1. Socket Class
            1. Socket Options
            2. SocketException
        8. Building a Connected Flashlight
          1. Creating the HQ Server
            1. Listening for Clients
            2. IP Address Binding
            3. Queuing Clients
            4. Accepting Connections
            5. Processing Client Requests
          2. The Flashlight Configuration Protocol
            1. Serialization
            2. Flashlight Identity
            3. Receiving Data
            4. Polling
          3. Connecting to HQ from the Flashlight
            1. Flashlight Configuration
          4. Updating HQ Using UDP
          5. Extending the UDP Example for P2P Flashlights
        9. Conclusion
      4. 7. Creating an Interface Display
        1. The Bitmap Class
          1. Creating a Bitmap Instance
          2. Drawing on a Bitmap
          3. Flushing a Bitmap onto the Display Hardware
          4. Colors in the .NET Micro Framework
        2. Drawing Shapes
          1. Drawing Plain Filled Rectangles
          2. Drawing Graduated Filled Rectangles
          3. Drawing Rectangles with Opacity
          4. Drawing with Rounded Corners
        3. Adding Resources to a .NET Micro Framework Project
        4. Image Drawing
        5. Image Scaling
        6. Drawing Text
          1. Drawing Text in a Bitmap
          2. Calculating the Length of Rendered Text
          3. Drawing Text in a Rectangle
          4. Building Up a Display
          5. Drawing Large Amounts of Text
          6. The WPF and the .NET Micro Framework
        7. The Application Class
          1. Creating an Application Instance
        8. Windows and Display Elements
          1. Using StackPanel to Lay Out a Display
          2. Placing Components Precisely Using the Canvas
          3. Updating Display Elements
        9. The Display Element Hierarchy
        10. Displaying Text
          1. Creating a Paged Display Component
        11. Displaying Images
          1. Creating a Custom Image—A Meter with a Dial
          2. Custom-Panel Size Behavior
          3. The Panel Class
        12. User Input and Events
          1. Binding to Hardware Events
            1. Port and Button Mapping
          2. Using Button Events
        13. Creating a Working User Interface
        14. Conclusion
      5. 8. Using SideShow as a User Interface
        1. What Does a SideShow Device Do?
          1. What Does a SideShow Device Do?
          2. SideShow and the Windows Vista Sidebar
        2. SideShow Device Management
        3. SideShow Devices and Gadget Applications
          1. SideShow Content Updates
        4. Creating and Deploying SideShow Applications
          1. Creating SideShow Applications
            1. Hardware Requirements for SideShow Development
          2. Our Sample Application
            1. Creating an Application Project
            2. Registering a Gadget Application
          3. Running the SideShow Gadget Application
        5. SideShow Content and Endpoints
          1. Displaying Content on the SideShow Device
            1. Handling Content Delivery Errors
          2. Glance Content
          3. The Simple Content Format Helper Classes
          4. Creating Graphical Content
            1. Rendering Images
            2. Sample Image Display
            3. Image Scaling
        6. Displaying Notifications
        7. Creating a SideShow Menu Page
        8. A Pop-up Menu Display
        9. Creating a SideShow Dialog Page
        10. SideShow Device Events
          1. Navigation Events
          2. Gadget Application Events
          3. Connection and Disconnection Events
        11. Using SideShow Devices
        12. Conclusion
      6. 9. Developing with the Emulator
        1. The Extensible Emulator
          1. Design of the Extensible Emulator
          2. Emulating Your Device
            1. Application Development Using Emulation
            2. Creating the Application Project
            3. Creating the Emulator Project
          3. Adding Emulated Components
            1. Creating an Emulator User Interface
            2. Binding a User Interface to the Emulator
            3. Creating a Test Program
            4. Using Other Built-in Components
          4. Creating Your Own Components
            1. Square-Wave Signal Generator
            2. Creating the Component Project
            3. Making the Component Available to the Emulator
            4. Configuring a Custom Component
            5. Setting Up the Custom Component
            6. Initializing the Custom Component
          5. Built-in Emulator Components
            1. MemoryManager
            2. GpioCollection
            3. LcdDisplay
            4. ComPort
            5. TimingServices
          6. Importing Configurations
          7. Advanced Emulator Techniques
            1. Emulator Command-Line Arguments
            2. Emulator Namespaces
        2. Conclusion
    7. III. Projects
      1. 10. Controlling a Robot
        1. The Hardware Platform
        2. A Robot-Control Project
          1. iRobot Roomba
          2. Getting Started with the iRobot Roomba
            1. Verifying a Serial Connection
            2. Sending a Simple Message
            3. Receiving Data
          3. Building an Object to Represent the Roomba
            1. Reading Data from the Robot
            2. Sending Commands to the Robot
          4. Object Instances and Threads
            1. Thread Management with Monitors
            2. Adding a Robot Management Process
            3. Timing Problems with Flags
            4. Preventing Interruptions Using the Interlocked Class
          5. Robot Events
          6. Performance Tradeoffs
            1. Threads
            2. Latency
        3. Conclusion
      2. 11. From Prototype to Product: Case Studies
        1. Case Study 1: EmbeddedFusion Ball-In-Maze Game
          1. About EmbeddedFusion
          2. Device Description
          3. Why the .NET Micro Framework?
          4. Design Approach
          5. Working with the .NET Micro Framework and Visual Studio
          6. Ship Mode
        2. Case Study 2: Vista SideShow
          1. About Rick Swaney and Vista SideShow
          2. Device Description
          3. Why .NET Micro Framework?
          4. Design Approach
          5. Working with the .NET Micro Framework and Visual Studio
            1. Development Environment
            2. Managed Code and the Framework Libraries
            3. User Interface Model
            4. Performance
        3. Conclusion
    8. Glossary
    9. Index
    10. SPECIAL OFFER: Upgrade this ebook with O’Reilly