Serial communication method, device and storage medium suitable for power communication
By allocating multiple high-speed serial ports and PCI devices in the real-time domain and isolating INTX interrupt processing, the real-time problem of real-time Linux system in power communication is solved, and the system's real-time response capability and performance stability are improved.
Patent Information
- Application Number
- CN202411376601.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-09-30
AI Technical Summary
The existing real-time Linux systems have poor real-time performance in power communication systems, especially when the system load is heavy, it is easy to lead to packet loss and performance degradation.
By allocating multiple high-speed serial ports to the real-time domain and isolating INTX interrupts to the real-time domain processing, using the device descriptor of the PCI bus device to allocate the PCI device to the real-time domain, using the RTOS system to process high-speed serial port data, avoiding the user layer to the system layer Switching to simplify interrupt processing.
It improves the system's real-time response capability, reduces the performance degradation caused by interrupt processing of Linux systems, and is suitable for frequent IO throughput scenarios.
Smart Images

Figure CN118916179B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of serial communication, and in particular to a serial communication method, device and storage medium suitable for power communication. Background Art
[0002] The distribution network automation system, as a complex and sophisticated system, has a complex hierarchical structure. First of all, the distribution master station, like the "brain" of the entire system, is located in the city dispatching center and is responsible for comprehensive monitoring and management of the operation of the entire distribution network. Distribution substations, these substations are often set up in 110kV / 35kV substations. They are like "sub-centers" responsible for monitoring tasks within their respective jurisdictions. The substations maintain close communication with the distribution terminal equipment in the area under their jurisdiction to ensure that every detail and every data can be accurately transmitted to the master station. The distribution terminals include feeder terminal equipment (FTU), opening and closing terminal equipment (DTU), distribution transformer terminal equipment (TTU), etc. These terminal equipment are like the "nerve endings" of the distribution network system, distributed in every corner, and always collect real-time data of the power grid, including key information such as voltage, current, and power. In addition, there are thousands of household meters, each of which needs to transmit data to the concentrator, and then the concentrator provides it to the upper-level equipment. For such a large number of devices, power communication mainly adopts bus communication, such as 485 bus.
[0003] In the process of implementing the present invention, the inventors found the following technical problems: In order to collect more device information, power gateways, data acquisition units (DPUs), TTUs and other devices will design multiple high-speed serial ports. For example, many TTUs encountered on site are designed as 32 serial ports or more. The baud rate of these serial ports communicating with the outside through the bus is very high, and the fastest reaches 2Mbps. This poses a great challenge to the real-time performance of the CPU and operating system, and it is very easy to cause problems such as packet loss. In addition, in addition to high-speed communication, these terminals and gateway devices are also responsible for other complex functions such as network communication, human-computer interaction, local telemetry, and log storage. Traditional solutions generally use real-time Linux systems as the operating systems of these terminal devices. However, the real-time performance of Linux itself is poor, and even after being corrected by real-time patches, it does not have hard real-time capabilities. Especially when the system load is heavy, the impact on real-time performance is more serious. Summary of the invention
[0004] The embodiments of the present invention provide a serial communication method, device and storage medium suitable for power communication, so as to solve the technical problem that the real-time performance of the power communication system is poor faced by the real-time Linux system in the prior art.
[0005] In a first aspect, an embodiment of the present invention provides a serial communication method applicable to power communication, comprising:
[0006] Allocating a real-time domain and a functional domain, and allocating multiple high-speed serial ports used for power communication to the real-time domain;
[0007] Isolate the INTX interrupts of multiple high-speed serial ports to the real-time domain for processing, and modify the INTX interrupt dependency to the CPU of the real-time domain;
[0008] Allocating the PCI bus data space corresponding to the high-speed serial port to the real-time domain;
[0009] The PCI device is allocated to the real-time domain by using the device descriptor of the PCI bus device.
[0010] In a second aspect, an embodiment of the present invention further provides a serial communication device suitable for power communication, comprising:
[0011] An allocation module, used for allocating the real-time domain and the functional domain, and allocating the multiple high-speed serial ports used for power communication to the real-time domain;
[0012] An isolation module is used to isolate the INTX interrupts of multiple high-speed serial ports to the real-time domain for processing, and to modify the INTX interrupt dependency to the CPU of the real-time domain;
[0013] A data space allocation module, used for allocating the PCI bus data space corresponding to the high-speed serial port to the real-time domain;
[0014] The device allocation module is used to allocate the PCI device to the real-time domain using the device descriptor of the PCI bus device.
[0015] In a third aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the serial communication method applicable to power communication as provided in the above embodiment.
[0016] The serial port communication method, device and storage medium applicable to power communication provided by the embodiment of the present invention allocate a real-time domain and a functional domain, and allocate multiple high-speed serial ports used for power communication to the real-time domain; isolate the INTX interrupts of the multiple high-speed serial ports to the real-time domain for processing, and modify the INTX interrupt dependency to the CPU of the real-time domain; allocate the PCI bus data space corresponding to the high-speed serial port to the real-time domain; and allocate the PCI device to the real-time domain using the device descriptor of the PCI bus device. The system is divided into a functional domain and a real-time domain through jailhouse, and the real-time domain is used to collect high-speed serial port data. And by setting, PCI resources are allocated to the real-time domain, so that the real-time domain can respond to PCI interrupts and receive serial port information, and the application domain does not need to intervene and process it. With the characteristics of the lightweight system of the real-time domain, each operation of the serial port device does not require switching from the user layer to the system layer, and the interrupt processing is relatively simple, which is more suitable for processing such frequent IO throughput scenarios, avoiding frequent interrupts of the Linux system caused by power communication, resulting in performance degradation. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0018] Figure 1 is a general flow chart of a serial communication method applicable to power communication provided in Embodiment 1 of the present invention;
[0019] Figure 2 It is a flowchart of a serial communication method applicable to power communication provided in Embodiment 1 of the present invention;
[0020] Figure 3 is a flow chart of a serial communication method applicable to power communication provided in Embodiment 2 of the present invention;
[0021] Figure 4 It is a structural diagram of a serial communication device suitable for power communication provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0022] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0023] Embodiment 1
[0024] Figure 1 is a general flow chart of a serial communication method applicable to power communication provided in Embodiment 1 of the present invention; Figure 2is a flow chart of a serial communication method applicable to power communication provided in the first embodiment of the present invention. This embodiment can be applied to the case where serial communication is implemented in a power communication application scenario. The method can be executed by a serial communication device applicable to power communication. Figure 1 and Figure 2 , specifically including the following steps:
[0025] Step 110, allocating a real-time domain and a functional domain, and allocating multiple high-speed serial ports used for power communication to the real-time domain.
[0026] The SOC system on chip can be used to implement serial communication for power communication. In the traditional way, a Linux system is provided in the SOC system to process the power information received by the serial port. Since the system on chip is provided with multiple CPUs, it can be divided into multiple systems. Exemplarily, the CPU, peripherals, memory and other hardware resources can be isolated and divided into different domains through jailhouse. They can be divided into real-time domain and functional domain respectively. Optionally, the real-time domain can adopt RTOS system and the functional domain can adopt Linux system. And jailhouse, isolate the hardware resources of the real-time domain from the Linux system. For example: multiple high-speed serial ports are allocated to the real-time domain.
[0027] Exemplarily, the allocation of real-time domains and functional domains may include: determining the computing performance and real-time performance of each CPU in the system; allocating CPUs whose real-time performance meets the real-time requirements to the real-time domain; and allocating CPUs whose computing performance meets the requirements to the functional domain.
[0028] This embodiment takes the TTU device in the power scenario as an example. The device contains 32 high-speed serial ports with a baud rate of up to 2M bps. The device hardware processor uses Feiteng e2000q, which has 4 cores, of which CPU0-1 is the FTC310 low-power processor core and CPU2-3 is the FTC664 high-performance processor core. The 32 high-speed serial ports are implemented by an FPGA expansion board, which is connected to the processor through a pcie interface and uses INTX interrupts (the traditional interrupt mechanism of PCI). RTOS uses freertos as the real-time domain system.
[0029] Since the FTC310 core has better real-time performance and low power consumption, CPU0 can be assigned to the real-time domain, and CPU1-3 with high computing power can be assigned to the functional domain.
[0030] Step 120, isolate the INTX interrupts of the multiple high-speed serial ports to the real-time domain for processing, and modify the INTX interrupt dependency to the CPU of the real-time domain.
[0031] PCI spec defines the INTX interrupt for each PCI device, which sends an interrupt request to the CPU in a level-triggered manner. Therefore, in this embodiment, it is necessary to isolate it to the real-time domain for processing to avoid excessive interrupts from interfering with the Linux system. At the same time, the INTX interrupt dependency can be modified to the CPU of the real-time domain so that the CPU of the real-time domain can process the INTX interrupt in a timely manner. After a serial port interrupt or a shared memory interrupt occurs, the interrupt is directly routed to CPU0 for processing, which improves processing efficiency.
[0032] Step 130, allocating the PCI bus data space corresponding to the high-speed serial port to the real-time domain.
[0033] In terms of memory, the hardware resources that the FreeRTOS system needs to operate, such as the shared memory address space, the PCIe data space corresponding to the high-speed serial port, and the FreeRTOS running memory space, are isolated to the real-time domain. Through jailhouse isolation to FreeRTOS, the system can be accessed normally, so that FreeRTOS can directly operate the high-speed serial port of the PCIe device without falling into the virtualization layer, which greatly improves the access efficiency.
[0034] Step 140: Allocate the PCI device to the real-time domain using the device descriptor of the PCI bus device.
[0035] In order to achieve the isolation of high-speed serial port PCIe devices, it is also necessary to add the device descriptor of the PCI device so that the jailhouse can assign the PCI device to the real-time domain. This is achieved through the jailhouse configuration file, and the description of the PCI device is added to the configuration file. For example, it can be achieved in the following way:
[0036] .pci_devices = {
[0037] {
[0038] .type = JAILHOUSE_PCI_TYPE_DEVICE,
[0039] .domain = 0,
[0040] .bdf = 0x2<<8,
[0041] .caps_start = 0,
[0042] .num_caps = 7,
[0043] .num_msi_vectors = 1,
[0044] .msi_64bits = 1,
[0045] .msi_maskable = 1,
[0046] .num_msix_vectors = 5,
[0047] .msix_region_size = 0x4000,
[0048] .msix_address = 0x58300000,
[0049] .bar_mask={0xfff00000, 0x00000000, 0x00000000, 0xffffc000,0x00000000, 0x00000000,},
[0050] },
[0051] },
[0052] .pci_caps = {
[0053] {.id=PCI_CAP_ID_PM, .start=0x40, .len=8, .flags=JAILHOUSE_PCICAPS_WRITE},
[0054] {.id=PCI_CAP_ID_MSI, .start=0x50, .len=32, .flags=JAILHOUSE_PCICAPS_WRITE},
[0055] {.id=PCI_CAP_ID_MSIX, .start=0x70, .len=12, .flags=JAILHOUSE_PCICAPS_WRITE},
[0056] {.id=PCI_CAP_ID_EXP, .start=0xa0, .len=60, .flags=JAILHOUSE_PCICAPS_WRITE},
[0057] {.id=PCI_EXT_CAP_ID_ERR, .start=0x100, .len=64, .flags=0},
[0058] {.id=PCI_EXT_CAP_ID_DSN, .start=0x140, .len=12, .flags=0},
[0059] {.id=PCI_EXT_CAP_ID_TPH, .start=0x1a0, .len=2, .flags=0},
[0060] },
[0061] Through the above method, the device information such as PCI device type, address, size and flag bit can be defined.
[0062] By allocating real-time domains and functional domains, and allocating multiple high-speed serial ports used for power communication to the real-time domain; isolating the INTX interrupts of multiple high-speed serial ports to the real-time domain for processing, and modifying the INTX interrupt dependency to the CPU of the real-time domain; allocating the PCI bus data space corresponding to the high-speed serial port to the real-time domain; using the device descriptor of the PCI bus device to allocate the PCI device to the real-time domain. The system is divided into functional domains and real-time domains through jailhouse, and the real-time domain is used to collect high-speed serial port data. And by setting up, PCI resources are allocated to the real-time domain, so that the real-time domain can respond to PCI interrupts and receive serial port information, and the application domain does not need to intervene or process it. Avoid frequent interruptions of the Linux system caused by power communication, resulting in performance degradation.
[0063] In a preferred implementation of this embodiment, before allocating the real-time domain and the functional domain, the method may further add the following step: using the functional domain to overclock the CPU allocated to the real-time domain. After adjusting the CPU0 frequency to the highest through Linux and then isolating it through jailhouse, it can ensure that FreeRTOS runs at the maximum main frequency, so that the real-time domain can have better real-time performance.
[0064] Embodiment 2
[0065] Figure 3This is a flow chart of a serial port communication method applicable to power communication provided by the second embodiment of the present invention. This embodiment is optimized based on the above embodiment, and the method can also add the following steps: the real-time domain receives information at the multi-channel high-speed serial port and generates a serial port interrupt; the real-time domain saves the interruption scene according to the serial port interruption, and closes the serial port interruption of the multi-channel high-speed serial port; wakes up the polling task according to the serial port interruption, and the polling task is used to determine whether there is data in the receiving queue of each serial port. When there is data, the data is taken out until the receiving queue is empty, and the data is written into the shared memory; when the free storage capacity of the shared memory is less than the preset threshold, the real-time domain sends a system SPI interrupt signal, so that the functional domain reads data from the shared memory according to the SPI interrupt signal and processes the data. The functional domain registers the spi interrupt triggered by the real-time domain as the interrupt processing function of the serial port driver layer; when the interrupt processing function is triggered, the serial port data is read from the shared memory; the read serial port data is transmitted to the virtual terminal device core layer; the line protocol layer is called to format the transmitted serial port data;
[0066] The formatted serial port data is sent to the read data buffer and copied to the functional domain application layer.
[0067] See also Figure 1 and Figure 3 , the serial communication method applicable to power communication comprises:
[0068] Step 210, allocate real-time domain and functional domain, allocate multiple high-speed serial ports used for power communication to the real-time domain, isolate the INTX interrupts of the multiple high-speed serial ports to the real-time domain for processing, and modify the INTX interrupt dependency to the CPU of the real-time domain.
[0069] Step 220, allocate the PCI bus data space corresponding to the high-speed serial port to the real-time domain, and allocate the PCI device to the real-time domain using the device descriptor of the PCI bus device.
[0070] Step 230: the real-time domain receives information from the multiple high-speed serial ports and generates a serial port interruption; the real-time domain saves the interruption scene according to the serial port interruption and closes the serial port interruption of the multiple high-speed serial ports.
[0071] In this embodiment, the multi-channel high-speed serial port can be a 32-channel high-speed serial port, and a serial port interrupt can be generated through a GIC (Generic Interrupt Controller, an interrupt controller in an ARM chip). In the aforementioned steps, the INTX interrupt dependency has been modified to the CPU of the real-time domain, so the interrupt is routed to the freertos system of CPU0 for processing. After receiving the interrupt, the interrupt scene is saved and the interrupt source, i.e., the 32-channel serial port, is closed.
[0072] Step 240, waking up the polling task according to the serial port interrupt, the polling task is used to determine whether there is data in each serial port receiving queue, and when there is data, taking out the data until the receiving queue is empty, and writing the data into the shared memory.
[0073] In this embodiment, the serial port interrupt wake-up polling task is a user task with the highest priority, and its execution opportunity is second only to the interrupt. This task is usually in a dormant state, and once it is awakened by an interrupt, it will immediately enter the polling polling. The polling will determine whether there is data in the serial port receiving queue of each serial port FIFO. If there is data, it will be read cyclically until the FIFO is empty, and then the read serial port data will be written to the shared memory. The shared memory is designed as 32 channels, each of which is a circular buffer with a size of 1024 bytes. Each channel corresponds to a serial port, and the channel id corresponds to the serial port id one by one. After polling all serial ports, a second polling is performed. After all serial port FIFOs are empty after the last polling, it means that the reception is over. The lower half will turn on the interrupt source and then fall into sleep again.
[0074] Step 250: When the free storage capacity of the shared memory is less than a preset threshold, the real-time domain sends a system SPI interrupt signal, so that the functional domain reads data from the shared memory according to the SPI interrupt signal and processes the data.
[0075] When the free storage capacity of the channel in the shared memory is less than a certain threshold, the real-time domain triggers the Soc system spi software interrupt to notify the functional domain Linux system to take away the data.
[0076] Step 260, the functional domain registers the spi interrupt triggered by the real-time domain as an interrupt processing function of the serial port driver layer, and reads the serial port data from the shared memory when the interrupt processing function is triggered. In the functional domain Linux system, a virtual serial port driver is written to indirectly perform serial port operations. The virtual serial port provides a device node of the / dev / ttyX class in the user space for application calls.
[0077] First, register the SPI interrupt triggered by CPU0, i.e. the real-time domain, as the interrupt processing function of the serial port driver layer of the functional domain. After the SPI interrupt is generated, the functional domain interrupt processing program no longer accesses the real serial port FIFO, but reads the serial port data from the corresponding shared memory channel. Exemplarily, the shared memory can be allocated as a channel corresponding to the serial port, each channel is allocated as a ring buffer, and the channel id corresponds to the serial port id one by one.
[0078] Step 270, the read serial port data is transmitted to the virtual terminal device core layer; the line specification layer is called to format the transmitted serial port data; the formatted serial port data is sent to the read data buffer area and copied to the functional domain application layer.
[0079] The virtual serial port is divided into tty core layer, line discipline layer, and serial port driver layer in the kernel space, providing a unified interface for users. The serial port data read from the corresponding shared memory channel is transmitted to the virtual terminal device core layer, the data is inserted into the buffer of the tty core layer, and then the line discipline is called to format the data, and finally the data is sent to read_buf and copied to the application layer.
[0080] In addition, the above method can also be used to send serial port information from the functional domain to the real-time domain, and then to the power equipment. Specifically, the reception of multiple high-speed serial ports is an asynchronous process, while the sending process is a synchronous process. Due to the data acquisition scenario, the lower computer provides a large amount of power operation data, which is passed to the control system through the high-speed serial port. In the command sending scenario, the amount of data sent is much smaller than the amount of data received. Therefore, the data sending process is relatively simple. The application layer calls the sending interface to pass the data to the serial port driver layer. The serial port driver layer writes the sending data to the corresponding shared memory channel, and then notifies CPU0 through the spi interrupt. CPU0 enters the serial port sending interrupt of freertos and writes the data to be sent into the serial port sending FIFO.
[0081] This embodiment adds the following steps: the real-time domain receives information from the multiple high-speed serial ports and generates a serial port interrupt; the real-time domain saves the interruption scene according to the serial port interruption and closes the serial port interruption of the multiple high-speed serial ports; wakes up the polling task according to the serial port interruption, and the polling task is used to determine whether there is data in the receiving queue of each serial port. When there is data, the data is taken out until the receiving queue is empty, and the data is written into the shared memory; when the free storage capacity of the shared memory is less than the preset threshold, the real-time domain sends a system SPI interrupt signal, so that the functional domain reads data from the shared memory according to the SPI interrupt signal and processes the data. The functional domain registers the SPI interruption triggered by the real-time domain as the interrupt processing function of the serial port driver layer; when the interrupt processing function is triggered, the serial port data is read from the shared memory; the read serial port data is transmitted to the virtual terminal device core layer; the line specification layer is called to format the transmitted serial port data; the formatted serial port data is sent to the read data buffer area and copied to the functional domain application layer. The real-time domain turns off hardware interrupts, polls each serial port, and then turns on hardware interrupts until all serial port data is processed. This makes the packet receiving mechanism more efficient. The remaining storage space is used to generate interrupt information. The Linux system only needs one system interrupt to obtain the same large amount of data as the actual serial port communication, which can improve system efficiency.
[0082] Embodiment 3
[0083] Figure 4 is a schematic diagram of the structure of a serial communication device suitable for power communication provided in Embodiment 3 of the present invention, see Figure 4 , the serial communication device suitable for power communication comprises:
[0084] An allocation module 310 is used to allocate a real-time domain and a functional domain, and allocate multiple high-speed serial ports used for power communication to the real-time domain;
[0085] An isolation module 320, for isolating INTX interrupts of multiple high-speed serial ports to the real-time domain for processing, and modifying the INTX interrupt dependency to the CPU of the real-time domain;
[0086] The data space allocation module 330 is used to allocate the PCI bus data space corresponding to the high-speed serial port to the real-time domain;
[0087] The device allocation module 340 is used to allocate the PCI device to the real-time domain using the device descriptor of the PCI bus device.
[0088] The serial port communication device suitable for power communication provided in this embodiment allocates real-time domain and functional domain, and allocates multiple high-speed serial ports used for power communication to the real-time domain; isolates the INTX interrupts of multiple high-speed serial ports to the real-time domain for processing, and modifies the INTX interrupt dependency to the CPU of the real-time domain; allocates the PCI bus data space corresponding to the high-speed serial port to the real-time domain; and allocates the PCI device to the real-time domain using the device descriptor of the PCI bus device. The system is divided into a functional domain and a real-time domain through jailhouse, and the real-time domain is used to collect high-speed serial port data. And by setting, PCI resources are allocated to the real-time domain, so that the real-time domain can respond to PCI interrupts and receive serial port information, and the application domain does not need to intervene or process it. With the characteristics of the lightweight system of the real-time domain, each operation of the serial port device does not require switching from the user layer to the system layer, and the interrupt processing is relatively simple, which is more suitable for handling the scene of frequent IO throughput of the power system, avoiding frequent interruptions of the Linux system caused by power communication, resulting in performance degradation.
[0089] Based on the above embodiments, the device further includes:
[0090] A generating module, used for enabling the real-time domain to receive information at the multi-channel high-speed serial port and generate a serial port interrupt;
[0091] A saving module, used to enable the real-time domain to save the interruption scene according to the serial port interruption, and to close the serial port interruption of the multiple high-speed serial ports;
[0092] A wake-up module is used to wake up the polling task according to the serial port interrupt, and the polling task is used to determine whether there is data in the receiving queue of each serial port, and when there is data, take out the data until the receiving queue is empty, and write the data into the shared memory;
[0093] The interrupt issuing module is used for the real-time domain to issue a system SPI interrupt signal when the free storage capacity of the shared memory is less than a preset threshold, so that the functional domain reads data from the shared memory according to the SPI interrupt signal and processes the data.
[0094] Based on the above embodiments, the device further includes:
[0095] The registration module is used to enable the functional domain to register the SPI interrupt triggered by the real-time domain as the interrupt processing function of the serial port driver layer;
[0096] A serial port data reading module, used for reading serial port data from the shared memory when the interrupt processing function is triggered;
[0097] The input module is used to input the serial port data read into the core layer of the virtual terminal device;
[0098] The formatting module is used to call the line specification layer to format the incoming serial port data;
[0099] The copy module is used to send the formatted serial port data into the read data buffer area and copy it to the functional domain application layer.
[0100] Based on the above embodiments, the device further includes:
[0101] The device node provides a module for providing a device node of a virtual serial port in the functional domain user space;
[0102] A unified interface providing module is used to provide a unified interface using a terminal device core layer composed of a virtual console, a serial port, and a pseudo terminal device;
[0103] Description module for describing the line specification layer in the tty_ldisc_N_TTY variable;
[0104] The hardware driver adding module is used to add the hardware driver layer of the virtual serial port device to the virtual serial port layer.
[0105] Based on the above embodiments, the interrupt issuing module includes:
[0106] The issuing unit is used to enable the real-time domain to issue a spi interrupt signal through the chip interrupt controller.
[0107] Based on the above embodiments, the allocation module includes:
[0108] A determination unit, used to determine the computing performance and real-time performance of each CPU in the system;
[0109] A first allocation unit is used to allocate a CPU whose real-time performance meets the real-time requirement to the real-time domain;
[0110] The second allocation unit is used to allocate the CPU whose computing performance meets the requirements to the functional domain.
[0111] Based on the above embodiments, the allocation module further includes:
[0112] The overclocking processing unit is used to perform overclocking processing on the CPU allocated to the real-time domain by using the functional domain.
[0113] Based on the above embodiments, the device further includes:
[0114] The channel allocation module is used to allocate the shared memory into channels corresponding to the serial ports. Each channel is allocated as a ring buffer, and the channel ID corresponds to the serial port ID one by one.
[0115] The serial port communication device applicable to power communication provided in the embodiment of the present invention can execute the serial port communication method applicable to power communication provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0116] Embodiment 4
[0117] Embodiment 4 of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, are used to execute any of the serial communication methods applicable to power communication provided in the above embodiments.
[0118] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device.
[0119] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0120] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0121] Computer program code for performing the operation of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or device. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0122] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A serial communication method suitable for power communication, characterized in that: include: Allocate the real-time domain and the functional domain through the jailhouse, and allocate the multiple high-speed serial ports used for power communication to the real-time domain; Isolate the INTX interrupts of multiple high-speed serial ports to the real-time domain for processing, and modify the INTX interrupt dependency to the CPU of the real-time domain; Allocating the PCI bus data space corresponding to the high-speed serial port to the real-time domain; The PCI device is allocated to the real-time domain by using the device descriptor of the PCI bus device, so that the real-time domain directly operates the high-speed serial port of the PCIE device; The real-time domain receives information from the multiple high-speed serial ports and generates a serial port interrupt; The real-time domain saves the interruption scene according to the serial port interruption, and closes the serial port interruption of the multiple high-speed serial ports; The polling task is woken up according to the serial port interrupt, and the polling task is used to determine whether there is data in each serial port receiving queue, and if there is data, take out the data until the receiving queue is empty, and write the data into the shared memory; When the free storage capacity of the shared memory is less than a preset threshold, the real-time domain sends a system SPI interrupt signal, so that the functional domain reads data from the shared memory according to the SPI interrupt signal and processes the data.
2. The method according to claim 1, characterized in that The method further comprises: The functional domain registers the spi interrupt triggered by the real-time domain as the interrupt processing function of the serial port driver layer; When the interrupt processing function is triggered, reading serial port data from the shared memory; The serial port data read is transmitted to the core layer of the virtual terminal device; Call the line discipline layer to format the incoming serial port data; the line sends the formatted serial port data to the read data buffer and copies it to the functional domain application layer.
3. The method according to claim 2, characterized in that The method further comprises: Provides a device node for a virtual serial port in the functional domain user space; Provide a unified interface using the terminal device core layer consisting of virtual consoles, serial ports, and pseudo-terminal devices; The line discipline layer is described in the tty_ldisc_N_TTY variable; Add a hardware driver layer for virtual serial port devices in the virtual serial port layer.
4. The method according to claim 1, characterized in that: The real-time domain sends a system SPI interrupt signal, including: The real-time domain sends out a SPI interrupt signal through the chip interrupt controller.
5. The method according to claim 1, characterized in that The allocation of real-time domain and functional domain includes: Determine the computing performance and real-time performance of each CPU in the system; Allocate the CPU whose real-time performance meets the real-time requirements to the real-time domain; Allocate CPUs with computing performance that meets the requirements to functional domains.
6. The method according to claim 5, characterized in that Before allocating the real-time domain and the functional domain, the method further comprises: Use the functional domain to overclock the CPU assigned to the real-time domain.
7. The method according to claim 2, characterized in that: The method further comprises: The shared memory is allocated as channels corresponding to the serial ports. Each channel is allocated as a ring buffer, and the channel id corresponds to the serial port id one by one.
8. A serial communication device suitable for power communication, characterized in that: include: The allocation module is used to allocate the real-time domain and the functional domain through the jailhouse. The real-time domain adopts the RTOS system, the functional domain adopts the Linux system, and the multi-channel high-speed serial ports used for power communication are allocated to the real-time domain; An isolation module is used to isolate the INTX interrupts of multiple high-speed serial ports to the real-time domain for processing, and to modify the INTX interrupt dependency to the CPU of the real-time domain; A data space allocation module, used for allocating the PCI bus data space corresponding to the high-speed serial port to the real-time domain; A device allocation module, used for allocating a PCI device to the real-time domain using a device descriptor of a PCI bus device, so that the real-time domain directly operates the high-speed serial port of the PCIE device; A generating module, used for enabling the real-time domain to receive information at the multi-channel high-speed serial port and generate a serial port interrupt; A saving module, used to enable the real-time domain to save the interruption scene according to the serial port interruption, and to close the serial port interruption of the multiple high-speed serial ports; A wake-up module is used to wake up the polling task according to the serial port interrupt, and the polling task is used to determine whether there is data in the receiving queue of each serial port, and when there is data, take out the data until the receiving queue is empty, and write the data into the shared memory; The interrupt issuing module is used for the real-time domain to issue a system SPI interrupt signal when the free storage capacity of the shared memory is less than a preset threshold, so that the functional domain reads data from the shared memory according to the SPI interrupt signal and processes the data.
9. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the serial communication method applicable to power communication as described in any one of claims 1 to 7 when executed by a computer processor.
Citation Information
Patent Citations
Serial port communication method and device, equipment and storage medium
CN113157624A
Real-time and time-sharing system data rapid exchange method
CN117931481A