CN112231074A - Single-channel multi-task sharing multiplexing method - Google Patents
Single-channel multi-task sharing multiplexing method Download PDFInfo
- Publication number
- CN112231074A CN112231074A CN202010375084.2A CN202010375084A CN112231074A CN 112231074 A CN112231074 A CN 112231074A CN 202010375084 A CN202010375084 A CN 202010375084A CN 112231074 A CN112231074 A CN 112231074A
- Authority
- CN
- China
- Prior art keywords
- uart
- communication
- layer
- logic
- task
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Withdrawn
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/545—Interprogram communication where tasks reside in different layers, e.g. user- and kernel-space
Abstract
The invention relates to a sharing and multiplexing method for communication, which is applied to the field of computer communication or the field of embedding, and particularly the electric energy meter communication. In the communication between two modules of the electric energy meter, if a plurality of different services are running, the traditional method is to add UART resources to each service to ensure the decoupling of the services. By applying the invention, a plurality of tasks and a plurality of services can be simultaneously operated among modules; the communication protocol among the modules is not modified, the hardware is not modified, and the single UART communication is used for realizing the mutual noninterference of multiple services and multiple tasks among the modules.
Description
Technical Field
The invention relates to the field of computer communication, in particular to sharing multiplexing of communication channels between embedded chips or modules.
Background
UART communication is always one of the most common communication methods in the embedded field, and its features of low cost, easy use, reliability, and supporting full duplex are widely applied to communication between chips or between modules. In a traditional programming mode, one path of UART only supports one group or one class of services, and for multi-task and multi-service products, multiple UART ports are often added to realize service separation.
The UART resources are added to mature products, chips are often required to be updated, on one hand, cost is improved, on the other hand, updating of the whole embedded program is brought, and cost of manpower and material resources is improved. The increase of the cost of a product is often unacceptable, because the profit is reduced, and under the large environment of the embedded field which must be worried about, the realization of the shared multiplexing of the communication channels can bring the benefits of cost reduction, application development difficulty reduction and the like.
In view of this, it is necessary to develop a method capable of implementing single channel sharing multiplexing, so as to implement multi-service and multi-task processing without increasing cost and hardware modification.
Disclosure of Invention
The invention aims to provide a single-channel multi-task sharing multiplexing method, which divides the tasks of software into N tasks by classifying the services and the applications and pertinently splitting complex services, realizes the decoupling of the N tasks on a hardware abstraction layer of the software, realizes zero perception of the application layer, and appears as if a current hardware platform has N UART ports available for the application layer and does not interfere with each other among the tasks.
The scheme of the invention is as follows:
1. in a traditional embedded software architecture: a hardware abstraction layer is inserted into the driver + application, and the driver + hardware abstraction layer + application is called as follows for short: DRV + HAL + APP.
And 2, the service logic codes of the DRV layer and the APP layer are not required to be changed, and the interface of the DRV calling layer called by the APP is modified into the interface of the HAL calling layer.
3. The main realization of the invention is that in the HAL layer, the HAL layer abstracts UART and virtualizes N UART ports for the APP layer to call. Meanwhile, the shared logic is realized, and the N virtual UARTs share the same physical UART.
And 4, the HAL layer mainly comprises a UART mapping table, a UART task scheduler and a receiving data dispatcher.
5. The method can dynamically map a plurality of virtual UART ports to one or a plurality of physical UART ports, and the software and the hardware realize complete decoupling.
For example, in the application of an electric energy meter, one path of the UART port simultaneously carries data synchronization service between the two modules, a master station transparent forwarding and reading task, a display data push service and a remote control push task. The traditional method has two schemes: firstly, a plurality of UART ports are added, and the services are separated; and secondly, an application layer designs a complex task scheduling mechanism, the calling relation of the management tasks is comprehensively arranged, and only one task is occupied each time. Both solutions require a lot of work to modify and test for future traffic increases and decreases.
The method of the invention can greatly reduce the modification and test cost brought by the service change, firstly, the hardware platform and the chip do not need to be replaced, and the prior platform is used; besides the newly added service part, the service logic and the code of the application layer basically do not need to be modified, and the service adjustment can be realized only by modifying the mapping relation between the virtual UART and the physical UART in the UART mapping table.
Drawings
FIG. 1 is a system framework diagram;
FIG. 2 is a block diagram of a hardware abstraction layer;
FIG. 3 is a communication task scheduling model of a hardware abstraction layer;
FIG. 4 is a virtual UART model;
Detailed Description
In the method, a hardware abstraction layer is inserted between an application layer and a driver layer, as shown in fig. 1, the UART is virtually abstracted, a plurality of UART interfaces are provided for the application layer, only one physical UART is called next, and all processing is realized in the hardware abstraction layer.
The system framework of the hardware abstraction layer is shown in fig. 2, and mainly includes an interface provided for the application layer; packaging a calling interface driven by a lower-layer physical UART; mapping relation mapping tables of the virtual UART and the physical UART; the UART task scheduler and the received data dispatcher are composed of several modules.
The scheduling model of the communication task is shown in fig. 3, taking as an example that all virtual UARTs are mapped to the same physical UART, the specific implementation method is as follows:
1. the virtual UART list on the left side of fig. 3 is not only an abstract implementation of UART, but also a buffer queue, and each virtual UART allocates buffers independently according to specific services, and may be the same or different.
2. Each virtual UART includes: to-be-sent data buffer area, UART state machine parameter, priority parameter and priority floating algorithm
3. The current UART task circularly inquires the state of each virtual UART, if data is to be sent and the current UART task is in an IDLE state, the current UART is mapped to the corresponding virtual UART, the data is sent, and the guardian is started
And 4, during waiting the response period of the physical UART, the UART task always rounds the state of each virtual UART with data to be transmitted, and the priority of the virtual UART is updated regularly, so that each virtual UART is guaranteed to have an opportunity to process.
5. When the physical UART responds, the received data is mapped back to the virtual UART, and the UART task is released
6. The watchdog finds that the UART task occupies too long time, namely the physical UART does not respond to the message, and immediately releases the UART task
7. In either case, 5 or 6, after releasing the UART task, the process returns to 3 again, and the process loops back and forth
8. In addition to the description of fig. 3, each virtual UART is prioritized, and in principle, when there is data to be transmitted at the same time, the high priority virtual UART data is preferentially processed. In order to prevent a single high-priority UART from always occupying a channel, a set of priority floating algorithm is designed, when a lower-priority virtual UART is always in a state of waiting to be sent and is not executed all the time, priority weight is promoted according to the number of round robin rounds each time, and only the current data is targeted. This ensures that lower priority tasks are not executed due to a high priority jam.
9. The size of the data buffer of each virtual UART is adjustable, only one frame of message is buffered in principle, and the size of the buffer queue of the high-frequency task can be increased in a targeted manner according to the resources of the current chip.
UART task caretaker whose care time is adjustable for each task, with a default of 500ms
11. The above is exemplified by a one-to-many model, and the invention can realize the function realization of a plurality of virtual UARTs corresponding to N physical UARTs, for example, the virtual UARTs 1, 2, 3 correspond to the physical UART1, and the virtual UARTs 4, 5, 6 correspond to the physical UART2
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes performed by the present specification and drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (4)
1. A single-channel multi-task sharing multiplexing method is characterized in that communication is carried out between two physically isolated modules only through a UART (universal asynchronous receiver/transmitter), an SPI (serial peripheral interface) or other modes, and a communication protocol cannot be distinguished according to tasks or service logic. The method abstracts N logic UART ports for an application layer to use by enumerating the task number of the multiplexing communication ports in a hardware abstraction layer HAL, and the application layer does not need to concern several actual physical UARTs.
2. The multiplexing method for multitask sharing according to claim 1, wherein the following characteristics are provided:
1) the method mainly realizes the work of a hardware abstraction layer HAL, abstracts a single physical channel into a plurality of logic UARTs, provides a plurality of logic UART interfaces for an upper layer, and calls a standard driving interface for a lower layer;
2) the application layer has no perception, the implementation below HAL is not needed to be concerned, and the calling logic UART is not substantially different from the common UART;
3) the driving layer is only responsible for packaging the interface of the actual physical channel into a standard communication interface;
4) the physical communication port needs to be configured in full duplex mode.
3. The method of claim 2, which does not disrupt the original application-level processing logic and implementation;
the external communication protocol adopts the original communication protocol without expansion and modification.
4. A method as claimed in claims 2 and 3, wherein the requirement for interchangeability of modules is fulfilled if the peer module is a standard module.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010375084.2A CN112231074A (en) | 2020-05-06 | 2020-05-06 | Single-channel multi-task sharing multiplexing method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010375084.2A CN112231074A (en) | 2020-05-06 | 2020-05-06 | Single-channel multi-task sharing multiplexing method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112231074A true CN112231074A (en) | 2021-01-15 |
Family
ID=74111662
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010375084.2A Withdrawn CN112231074A (en) | 2020-05-06 | 2020-05-06 | Single-channel multi-task sharing multiplexing method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112231074A (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1862517A (en) * | 2005-04-28 | 2006-11-15 | 惠普开发有限公司 | Virtualizing uart interfaces |
CN102307230A (en) * | 2011-08-18 | 2012-01-04 | 中兴通讯股份有限公司 | Service transmission method and device |
CN102573122A (en) * | 2012-01-20 | 2012-07-11 | 中国科学院上海微系统与信息技术研究所 | Combined multifunctional node of wireless sensor network module |
US20130247073A1 (en) * | 2012-03-14 | 2013-09-19 | General Electric Company | Systems and methods for enhancing firmware |
CN104156335A (en) * | 2014-08-08 | 2014-11-19 | 成都联星微电子有限公司 | Method for multiplexing multiple UART interfaces |
CN109002405A (en) * | 2018-06-08 | 2018-12-14 | 北京东土科技股份有限公司 | A kind of industrial field bus virtualization system, method and apparatus |
-
2020
- 2020-05-06 CN CN202010375084.2A patent/CN112231074A/en not_active Withdrawn
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1862517A (en) * | 2005-04-28 | 2006-11-15 | 惠普开发有限公司 | Virtualizing uart interfaces |
CN102307230A (en) * | 2011-08-18 | 2012-01-04 | 中兴通讯股份有限公司 | Service transmission method and device |
CN102573122A (en) * | 2012-01-20 | 2012-07-11 | 中国科学院上海微系统与信息技术研究所 | Combined multifunctional node of wireless sensor network module |
US20130247073A1 (en) * | 2012-03-14 | 2013-09-19 | General Electric Company | Systems and methods for enhancing firmware |
CN104156335A (en) * | 2014-08-08 | 2014-11-19 | 成都联星微电子有限公司 | Method for multiplexing multiple UART interfaces |
CN109002405A (en) * | 2018-06-08 | 2018-12-14 | 北京东土科技股份有限公司 | A kind of industrial field bus virtualization system, method and apparatus |
Non-Patent Citations (1)
Title |
---|
黄亭宇: "面向嵌入式操作系统微内核的硬件抽象层开发方法研究", 《中国优秀硕士学位论文全文数据库 信息科技辑》 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11500682B1 (en) | Configurable logic platform with reconfigurable processing circuitry | |
US20230231809A1 (en) | Dynamic load balancing for multi-core computing environments | |
CN109976925B (en) | Method and system based on mixed multi-system inter-core real-time communication | |
CN1981484B (en) | Hierarchal scheduler with multiple scheduling lanes and scheduling method | |
US8635388B2 (en) | Method and system for an OS virtualization-aware network interface card | |
US20060129699A1 (en) | Network interface adapter with shared data send resources | |
EP2814214B1 (en) | A system for providing multi-cell support with a single symmetric multi-processing, smp, partition in a telecommunications network | |
US5247671A (en) | Scalable schedules for serial communications controller in data processing systems | |
US7415540B2 (en) | Scheduling processing threads | |
TWI408934B (en) | Network interface techniques | |
WO2005083984A1 (en) | Protocol stack with modification facility | |
KR20150024845A (en) | Offloading virtual machine flows to physical queues | |
CN102523153B (en) | Load balancing method under virtual environment | |
WO2010039167A1 (en) | Multi-core system with central transaction control | |
US20040015979A1 (en) | System and method for efficiently exchanging data among processes | |
WO2021130828A1 (en) | Intra-server delay control device, intra-server delay control method, and program | |
US9612877B1 (en) | High performance computing in a virtualized environment | |
CN114363269B (en) | Message transmission method, system, equipment and medium | |
CN112231074A (en) | Single-channel multi-task sharing multiplexing method | |
CN110868364B (en) | Bandwidth isolation device and method | |
US10671430B2 (en) | Execution priority management for inter-process communication | |
CN104636206A (en) | Optimization method and device for system performance | |
US20110296434A1 (en) | Techniques for Dynamically Sharing a Fabric to Facilitate Off-Chip Communication for Multiple On-Chip Units | |
CN115098430B (en) | Inter-core communication priority scheduling method based on AMP architecture | |
CN111756647B (en) | HQoS service transmission method, device and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20210115 |
|
WW01 | Invention patent application withdrawn after publication |