Do you need components when you're working on a real-time operating system? The components such as FinSH console, virtual file system, utest framework, dynamic module, socket abstraction layer, AT commands, POSIX interface, Ulog log, power management, or network framework. If you have these demands, this article may be of interest.
RT-Thread provides developers with a wealth of components and free-of-charge to use. Making it easy for developers to connect with different hardware platforms and business scenarios, and to achieve one-time programming, permanent to use.
FinSH Console
FinSH is a command-line component of RT-Thread that provides a set of operating interfaces that users can call on the command line, primarily for debugging or viewing system information. It can communicate with the PC using serial port/ Ethernet / USB, etc.
Function:
Virtual File System
A file system is a set of abstract data types that implements the storage, hierarchical organization, access, and retrieval of data. It is a mechanism for providing underlying data access to users. Files are usually the basic units stored in a file system, that is, data is organized in a single file. When there are a lot of files, it will lead to numerous files, and it is difficult to classify and rename them. And the folder exists as a container for multiple files.
DFS is a virtual file system component provided by RT-Thread. Its full name is Device File System which is a device virtual file system. The name of the file system uses a style similar to UNIX files and folders. The directory structure is as follows:
In RT-Thread DFS, the file system has a uniform root directory, which is represented by /. The f1.bin file in the root directory is represented by /f1.bin, and the /f1.bin directory in the 2019 directory is represented by /data/2019/f1.bin. That is, the partition symbol of the directory is /, which is exactly the same as UNIX/Linux, and is different from Windows (the \ is used as the separator of the directory on the Windows operating system).
The main features of the RT-Thread DFS component are:
The hierarchical structure of DFS is shown in the following figure, which is mainly divided into a POSIX interface layer, a virtual file system layer and a device abstraction layer.
utest Framework
utest (unit test) is a unit testing framework developed by RT-Thread. The original intention of designing utest is to make it easier for RT-Thread developers to write test programs using a unified framework interface for unit testing, coverage testing, and integration testing.
Dynamic Module: dlmodule
The dynamic module provides a mechanism for dynamically loading program modules for RT-Thread. Because it is also compiled independently of the kernel, it is more flexible to use. In terms of implementation, this is a mechanism to separate the kernel from the dynamic modules.
Through this mechanism, the kernel and dynamic modules can be compiled separately, and at runtime, the compiled dynamic modules are loaded into the kernel through the module loader in the kernel.
In the dynamic module of RT-Thread, two formats are currently supported:
SAL (Socket abstraction layer)
In order to adapt to more network protocol stack types and avoid the system's dependence on a single network protocol stack, the RT-Thread system provides a SAL (Socket Abstraction Layer) components that implement different network protocol stacks or network implementations.
The abstraction of the interface provides a set of standard BSD Socket APIs to the upper layer so that developers only need to care about and use the network interface provided by the network application layer, without concern for the underlying specific network protocol stack type and implementation, which greatly improves the system's compatibility makes it easy for developers to complete protocol stack adaptation and network-related development.
Main features of the SAL component are as follows:
SAL Network Framework
The SAL network framework of RT-Thread is mainly shown in the following structure:
AT Framework
In the Age of the Internet of Things, there is a wide variety of network AT modules, and for easy to develop, the RT-Thread abstraction implements the AT framework, which can be operated through the BSD socket standard interface.
The AT component is based on the implementation of the AT Server and AT Client of the RT-Thread system. The component completes the AT command transmission, command format and parameter judgment, command response, response data reception, response data parsing, URC data processing, etc. Command data interaction process.
Through the AT component, the device can use the serial port to connect to other devices to send and receive parsed data. It can be used as an AT Server to allow other devices or even the computer to connect to complete the response of sending data. It can also start the CLI mode in the local shell to enable the device to support AT Server and AT Client at the same time. Server and AT Client features, this mode is mostly used for device development and debugging.
AT component resource usage:
Overall, the AT component resources are extremely small, making them ideal for use in embedded devices with limited resources. The AT component code is primarily located in rt-thread/components/net/at/. The main functions include:
Main Functions of AT Server:
Main Functions of AT Client:
Main Functions of AT Socket:
As an extension of AT Client function, it uses AT command to send and receive as the basis, implements the standard BSD Socket API, completes the data sending and receiving function, and enables users to complete device networking and data communication through AT commands.
Multi-client support: The AT component currently supports multiple clients running simultaneously.
POSIX Interface
Using the POSIX API interface in RT-Thread includes several parts: libc (for example, newlib), filesystem, pthread, and so on. Need to open the relevant options in rtconfig.h:
#define RT_USING_LIBC
#define RT_USING_DFS
#define RT_USING_DFS_DEVFS
#define RT_USING_PTHREADS
RT-Thread implements most of the functions and constants of Pthreads, defined in the pthread.h, mqueue.h, semaphore.h, and sched.h header files according to the POSIX standard. Pthreads is a sublibrary of libc, and Pthreads in RT-Thread is based on the encapsulation of RT-Thread kernel functions, making them POSIX compliant.
Ulog log
Ulog is a very simple and easy to use C/C++ log component. The first letter u stands for μ, which means micro. It can achieve the lowest ROM<1K, RAM<0.2K resource usage. Ulog is not only small in size, but also has very comprehensive functions. Its design concept refers to another C/C++ open source log library: EasyLogger (referred to as elog), and has made many improvements in terms of functions and performance. The main features are as follows:
The following figure shows the ulog log component architecture diagram:
Power Management: PM
In the initial stage of product development, the first consideration is to complete the development of product functions as soon as possible. After the function of the product is gradually improved, it is necessary to add the power management (PM) function. To meet this need for IoT, RT-Thread provides power management components.
The idea of power management components is to be as transparent as possible, making it easier for products to add low power functions.
RT-Thread's PM components adopt a layered design idea, separating architecture and chip-related parts, and extracting common parts as the core. While providing a common interface to the upper layer, it also makes it easier for the bottom driver to adapt components.
The main features of RT-Thread PM components are as follows:
Network Framework
In order to support various network protocol stacks, RT-Thread has developed a SAL component, the full name of the Socket abstraction layer.
RT-Thread can seamlessly access various protocol stacks, including several commonly used TCP/IP protocol stack, such as the LwIP protocol stack commonly used in embedded development and the AT Socket protocol stack component developed by RT-Thread, which complete the conversion of data from the network layer to the transport layer.
The main features of the RT-Thread network framework are as follows:
RT-Thread's network framework adopts a layered design with four layers, each layer has different responsibilities. The following figure shows the RT-Thread network framework structure:
Those functional components are modularly designed to be loosely coupled with the OS core and can be tailored or extended through a graphical IDE. Even developers who are new to RT-Thread can easily get started with.
RT-Thread is an open-source embedded real-time operating system and released under Apache License v2.0. Check more about RT-Thread, please visit rt-thread.io
RT-Thread Contact Info