A message collaborative normalization processing method based on the multi-source control application layer of Linux system

By adopting the message collaborative normalization processing method of the multi-source control application layer in the Linux system, and using semaphores and thread isolation communication interfaces, the problem of data exception handling of multi-source control equipment is solved, and the product research and development efficiency and reliability are improved.

CN114238147BActive Publication Date: 2025-08-08TONG FANG ELECTRONICS SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111655619.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-08-08
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

In Linux operating systems, data exception handling of multiple communication interfaces is difficult to quickly track and locate, affecting the product development cycle.

Method used

The multi-source control application layer based on Linux system is adopted to define a two-dimensional data cache pool, semaphore and multiple threads to isolate the communication interface and the processing link, and use semaphore and inter-thread communication to quickly locate abnormal data sources.

Benefits of technology

It realizes effective isolation of communication interface data, quickly locates the causes of abnormalities, shortens the product development cycle, and improves design efficiency, robustness and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114238147B_ABST
    Figure CN114238147B_ABST
Patent Text Reader

Abstract

The present invention discloses a message collaborative normalization processing method based on the multi-source control application layer of the Linux system. According to the threads and semaphores provided by the Linux system, a one-to-one mapping relationship between communication interfaces and threads is realized, reception processing is completed by an independent thread, and a processing response bridge is established through semaphores. The data reception, content analysis and corresponding processing links of the communication source are effectively isolated from each other. When data of multiple communication interfaces are abnormal, it is convenient to quickly lock the location and find the cause of the problem, shortening the product research and development cycle and significantly improving the design efficiency, robustness and reliability of the product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of embedded operating systems and relates to a message collaborative normalization processing method based on a multi-source control application layer of a Linux system. Background Art

[0002] Embedded devices are typically designed for external control and utilize a variety of common communication interfaces, including Ethernet, parallel, and serial ports. To provide a rich set of control interfaces, these devices typically employ multiple control sources, often referred to as multi-source control. During device design, the use of identical or similar protocols minimizes redundancy in device control protocols and enables efficient protocol reuse. Ethernet ports transmit data in the form of Ethernet frames, while serial ports transmit data in the form of single-byte streams. These multiple control inputs operate concurrently and are often random. However, the Linux operating system has limited debugging capabilities. When data processing from multiple communication interfaces is anomalies, it can be difficult to quickly track and locate the issue, impacting product development cycles. Currently, no effective solutions have been proposed for these technical issues. Summary of the Invention

[0003] In response to the above technical problems in related technologies, the present invention proposes a method for collaborative normalization of messages based on the multi-source control application layer of the Linux system, which can overcome the shortcomings of the above-mentioned existing technologies. It includes the following steps:

[0004] S1, variable assignment, including: defining n two-dimensional data buffer pools Buff and processing identifier F, defining a semaphore S and defining a total of n+1 threads T (T1~Tn+1);

[0005] S2, initialize the serial port and network port;

[0006] S3. Set the initial states of n+1 threads T to blocked.

[0007] S4, judge when the network port x or serial port x receives external control data, thread T is open, the corresponding thread T x Respond and store data in the corresponding Buff x In the example, set the flag F x is 1; the semaphore S is enabled through the sem_post function;

[0008] S5. When the semaphore is in a valid state, determine which communication interface the x in the thread Tn+1 comes from;

[0009] S6, Mark F xWhen the value of is equal to 0, it means that there is no data to be processed on this interface, and the value of the next identifier F is judged. The value of x is cycled from 1 to n times. When there is still no data at the nth identifier F, the entire normalization processing thread ends and the thread enters a blocked state.

[0010] S7, when the value of the flag Fx is equal to 1, the data in the corresponding Buff is taken out and parsed according to the protocol format. After the parsing is completed, the Buff data is cleared and the flag F is set to 0;

[0011] Furthermore, x is the serial number of the external communication interface, x≥1 and x≤n.

[0012] Furthermore, the n is a positive integer, which is equal to the serial number of the external communication interface; the serial number of the external communication interface corresponds to the thread program number one by one.

[0013] Furthermore, the external communication interface includes a network port and a serial port. When any communication interface among the multiple network ports or serial ports receives new communication control data, S4 is executed.

[0014] The beneficial effects of the present invention are: the data reception, content analysis and corresponding processing links of the communication source are effectively isolated from each other. When abnormalities occur in the data of multiple communication interfaces, it is convenient to quickly lock the location and find the cause of the problem, shortening the product development cycle and significantly improving the design efficiency, robustness and reliability of the product. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0016] Figure 1 Flowchart of the treatment method.

[0017] Figure 2 Schematic diagram of the processing model. DETAILED DESCRIPTION

[0018] The following will be combined with the appended Figure 1-2 , the technical solution of the present invention is clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field belong to the scope of the present invention.

[0019] Example 1 discloses a method for collaborative normalization processing of messages based on a multi-source control application layer of a Linux system. Based on the threads and semaphores provided by the Linux system, communication and resource access between threads are implemented. All "communication sources" and processing and parsing share the same semaphore, thereby implementing an embodiment in which the same parsing and processing function completes the corresponding normalization processing. The method includes the following steps:

[0020] S1. After the Linux system is started, the application starts to start and completes the two-dimensional data buffer pool Buff1 ~ Buff for the "control source" data of multiple communication interfaces. n The processing flag Fn is initialized to 0. Where n is a positive integer, and its size is equal to the number of external communication interfaces. The following subscript n is not specifically explained and shall be interpreted in the same way;

[0021] S2, complete the serial port initialization, including: baud rate, check bit;

[0022] S3. Complete network port initialization, including: IP settings of the corresponding network card and the corresponding port number;

[0023] S4. Start creating the signal line S and use the sem_init function provided by the system to initialize the semaphore to complete its initialization;

[0024] S5, create thread T1~ T n+1 , use the pthread_create function provided by the system to complete thread creation and initialization, after which the thread is in a blocked state. Among them, threads T1~T n Thread T is used for receiving data from multiple communication ports. n+1 Used to realize the normalization processing function of data;

[0025] S6. When the network port x or serial port x receives external control data (where x represents the serial number of the communication interface of the device, x≥1 and x≤n), thread blocking is invalid. According to the corresponding communication interface number x, the corresponding thread T x Respond and store data in the corresponding Buff x In the example, set the flag F x Set to 1, and use the sem_post function provided by the system to enable the semaphore S;

[0026] S7, thread T n+1 When obtaining the signal quantity, determine which communication interface it comes from;

[0027] S8, if the mark F xThe value of is equal to 0, indicating that this interface has no data to be processed, and continues to judge the value of the next identifier F, where (x value is from 1 to n and loops n), until the subscript x is equal to n, there is still no data to be processed, then the entire normalization processing thread ends and enters the blocking state again; if F x If the value is equal to 1, it means that there is data to be processed, and go to step 9;

[0028] S9, extract the data content of the corresponding Buff, parse and process it according to the protocol format; after processing, clear the Buff data processed this time and set the flag F to 0;

[0029] S10. Continue to determine whether the next F value is greater than 0, and execute step 8.

[0030] The present invention is not limited to the above-mentioned optimal implementation mode. Anyone can derive other forms of products under the inspiration of the present invention. However, no matter what changes are made in the method, any technical solution that is the same or similar to that of the present application falls within the scope of protection of the present invention.

Claims

1. A message collaborative normalization processing method based on the multi-source control application layer of the Linux system, characterized in that: The following steps are involved: S1, variable assignment, including: defining n two-dimensional data buffer pools Buff and processing identifiers F, defining a semaphore S and defining a total of n+1 threads T, T1 to Tn+1; S2, initialize the serial port and network port; S3. Set the initial states of n+1 threads T to blocked. S4, when the network port x or serial port x receives external control data, set thread T to open state, the corresponding thread T x Respond and store data in the corresponding Buff x In the example, set the flag F x is 1; set the semaphore S to a valid state through the sem_post function; S5. When the semaphore is in a valid state, determine which communication interface the x in the thread Tn+1 comes from; S6, Mark F x When the value of is equal to 0, it means that there is no data to be processed on this interface, and the next value of F is judged. The value of x is cycled from 1 to n times. When the cycle reaches n and there is still no data on F, the entire normalization processing thread ends, and the thread is set to a blocked state. S7, Mark F x When the value is equal to 1, the data in the corresponding Buff is taken out and parsed according to the protocol format. After the parsing is completed, the Buff data is cleared and the flag F is set to 0.

2. The method for collaborative normalization of messages based on a multi-source control application layer of a Linux system according to claim 1, characterized in that: The x is the serial number of the communication interface, x≥1 and x≤n.

3. The method for collaborative normalization of messages based on the multi-source control application layer of a Linux system according to claim 1, characterized in that: The n is a positive integer, which is equal to the serial number of the communication interface; the serial number of the communication interface corresponds to the thread program number one by one.

4. The method for collaborative normalization of messages based on a multi-source control application layer of a Linux system according to claim 1, characterized in that: The communication interface includes a network port and a serial port. When either the network port or the serial port receives new communication control data, S4 is executed.

Citation Information

Patent Citations

  • Method, system and terminal for dynamically configuring communication parameters and computer readable storage medium

    CN108365967A

  • A response method and a system for dial test

    CN109471706A