# A C-Based Framework for Low-Cost Real-Time Embedded Systems
## 2 Related Work  
Among design methods standing at a higher level of abstraction with respect to plain C-language programming, MBD has been used successfully in multiple application domains, ranging from databases [13] to firmware for electricity distribution grids [14]. It offers unquestionable advantages, especially for large and mid-size systems with strong reliability and software certification requirements. However, it also forces embedded programmers to embrace a new design and programming paradigm and become familiar with new languages and tools. In some cases, especially for C-language programmers, the associated learning curve can be quite steep, like in the case of synchronous languages [15], even in their most recent evolution [16]. Similarly, approaches like the one discussed in [17; 18] entail the adoption of an event-driven design paradigm and UML statecharts. In the case of the CPAL language [19], language design aims at finding the best possible trade-off between staying as close as possible to the C language [20] (which most embedded programmers are likely to be proficient in), while incorporating all the features needed to model, simulate, and program embedded systems, as well as thoroughly scrutinize their behavior. This approach makes the language very versatile and has enabled its application to multiple case studies, like communication protocol analysis [21], fault tolerance [22], and more recently, the verification of an aerial video tracking system [23]. Nevertheless, programmers are still required to learn the CPAL language anew, as well as its specific tools and development environment. Programming environments for Programmable Logic Controllers (PLCs) [24], either proprietary [25] or open-source [26], are also very powerful, especially when confronted with typical industrial automation applications. They are undoubtedly popular [27; 28] but, like the previously mentioned ones, they are also tightly associated with dedicated Domain-Specific Languages (DSLs), such as the ones defined in [29], and the cost of PLC hardware is typically much higher than the cost of a microcontroller-based board of comparable processing power. Arduino-based systems [30] have their own software development framework that adopts a simplified dialect of the C++ language, but the programming model consists of a single main loop that contains the code to be executed. As a consequence, over the years, it has been extended in various non-native ways to suitably support multitasking, in either a cooperative [31] or pre-emptive [32, 33] way since such a feature becomes mandatory as the complexity of real-time embedded applications grows. A downside of cooperative approaches is that task execution is indeed cooperative. Hence, task switches are under the control of the running task and are executed in a timely manner only if tasks have been implemented correctly. At the same time, pre-emptive approaches make the underlying programming model more complex and introduce a new set of potential pitfalls, like race conditions, which Arduino programmers may or may not be aware of. Other proposals, like the one described in [34, 35] succeeded in speeding up firmware development by leveraging a variety of sophisticated, open-source firmware components, such as real-time operating systems (RTOSs) [36], filesystems [37], and TCP/IP protocol stacks [38]. Besides being quite sophisticated, those components have the additional advantage of being portable, and hence, readily available on many embedded platforms. However, even though those proposals effectively support modular embedded system construction and allow programmers to use the C language, they still lack much needed _abstraction_. As an example, if a programmer wants to read a process variable available on a sensor connected to the processor by means of a field bus like the Controller Area Network (CAN) [39] or via Ethernet, they still need to know all the details about this connection and call the appropriate library functions.