Modern Embedded Systems Programming with Miro Samek
Jan 18, 2022
auto_awesome
Miro Samek, expert in embedded systems programming, discusses the impact of technical decisions and architectures on development velocity. They explore convoluted code structures and compare the superloop and RTOS approaches. The active object design pattern is introduced for agile development. The challenge of keeping state diagrams in sync with manual coding is explored. The importance of automation and state machine design tools is highlighted.
The challenges of embedded software development can be categorized into three layers: getting off the ground issues, concurrency issues, and spaghetti code.
A new approach called the active object design pattern, which integrates state machines, can help address the challenges of concurrency and spaghetti code in embedded systems programming.
Deep dives
The Challenges of Embedded Software Development
The challenges of embedded software development are divided into three layers: getting off the ground issues, concurrency issues, and spaghetti code. The first layer includes tasks like setting up the hardware and software, while the second layer involves dealing with race conditions and other concurrency problems. The third layer, spaghetti code, refers to convoluted code structures with nested if statements and numerous variables and flags. These issues make the code difficult to understand and modify. To avoid these challenges, a new approach called the active object design pattern is suggested.
The Dominating Approaches in Embedded Systems Development
The two dominating approaches in embedded systems development are the superloop approach and the real-time operating system (RTOS) approach. The superloop approach involves having a main function that runs forever in a loop and performs various tasks. However, this approach can become unresponsive and difficult to expand. On the other hand, an RTOS allows for multiple superloops or tasks to run concurrently but requires careful management of shared resources. While the RTOS is an improvement over the superloop, it still has limitations and can lead to complex code interactions.
The Benefits of Using State Machines
To address the challenges of concurrency and spaghetti code, integrating state machines into the active object approach is proposed. State machines help manage the context and behavior of the system based on events. By partitioning the system's behavior into chunks or states, state machines simplify code structure and minimize the use of flags. State machines can be represented in state diagrams, which provide a visual representation of the system's behavior. However, it is important to use lightweight modeling tools that integrate seamlessly with code generation to ensure agility and avoid complexity.
The Importance of Modeling and Automation
Modeling with state machines is an iterative process that can be integrated into an agile development workflow. It allows for intentional incompleteness and early unit testing. While concerns about the complexity of modeling tools exist, there are lightweight options available that simplify the process. By integrating code generation from the models, developers can maintain a single source of truth and automate the code generation process. Modeling and code generation enable higher levels of abstraction and faster development while addressing issues of code review and maintainability.