Design and Implementation of State Machines in Embedded Systems: From Complex Logic to Clear Architecture

Design and Implementation of State Machines in Embedded Systems: From Complex Logic to Clear Architecture

Introduction Have you ever written code like this: layers of nested if-else statements, a multitude of condition checks, making maintenance a nightmare? // Troublesome embedded control logic <section class="mp_profile_iframe_wrp custom_select_card_wrp" nodeleaf=""> <mp-common-profile class="mpprofile js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-id="gh_acd22af287b7" data-nickname="An Embedded Programmer" data-headimg="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/md/images/mp-logo.png" data-service_type="1" data-verify_status="1"></mp-common-profile> <br class="ProseMirror-trailingBreak"> </section> void device_control() { if (is_power_on) { if (is_initialized) … Read more

Modbus TCP Message Parsing

Modbus TCP is a mainstream communication protocol in the field of industrial Ethernet, based on the TCP/IP protocol stack for data transmission. It simplifies the verification mechanism based on Modbus RTU (relying on the TCP protocol’s own verification instead of CRC16), and implements device addressing and request-response matching in an Ethernet environment through the MBAP … Read more

Industrial Control System Security: The Digital Shield Protecting the Lifeblood of Industry | Fengchi Insights

Industrial Control System Security: The Digital Shield Protecting the Lifeblood of Industry | Fengchi Insights

The Industrial Control System (ICS) is the core “nerve center” of the modern industrial system, supporting the production operations of critical sectors such as electricity, petrochemicals, rail transportation, and intelligent manufacturing. With the rapid development of the industrial internet and intelligent manufacturing, the deep integration of industrial control systems with information networks has not only … Read more

UART Serial Communication Template (Feel free to take it)

UART Serial Communication Template (Feel free to take it)

UART is frequently used in our embedded development process. It is quite simple, but to avoid reinventing the wheel, I have specifically summarized the serial communication software into a template for everyone to reference~Generally, our serial protocol format is as follows: [Frame Header] [Length] [Data Field] [Checksum] [Frame Tail] Frame Header: A fixed byte sequence … Read more

A Universal Embedded Measurement and Control Host (Flexible Configuration Without Repetition)

A Universal Embedded Measurement and Control Host (Flexible Configuration Without Repetition)

Introduction In the process of embedded system development and debugging, it is often necessary to use host software to monitor device operating status, send control commands, and analyze communication data. The traditional approach is to develop a dedicated host program for each project, which, while precise in functionality, incurs high development costs, is difficult to … Read more

A Versatile Embedded Measurement and Control Host (Flexible Configuration Without Repetition)

A Versatile Embedded Measurement and Control Host (Flexible Configuration Without Repetition)

Introduction In the process of embedded system development and debugging, it is often necessary to use host software to monitor device operating status, send control commands, and analyze communication data. The traditional approach is to develop a dedicated host program for each project, which, while precise in functionality, incurs high development costs, is difficult to … Read more

Applications of Unions in Microcontroller Programming

Applications of Unions in Microcontroller Programming

01Union In the previous article “Combining Enumerations and Structures”, it was mentioned that a structure is like a packaging that encapsulates variables with common characteristics. A structure is a composite or complex type that can contain multiple members of different types. In C language, there is another syntax that is very similar to structures, called … Read more

C# State Machine: A Tool for Parsing Binary Protocols

C# State Machine: A Tool for Parsing Binary Protocols

C# State Machine: A Tool for Parsing Binary Protocols Hello everyone! Today I want to share a very useful technique – using a state machine to parse binary protocols. In our work, we often need to handle various communication protocols, such as serial communication and network protocols. Using a state machine to tackle these problems … Read more