Data processing method and device, computer equipment, readable storage medium and program product
By implementing event monitoring and data processing methods on multiple serial ports, the problem of serial port multiplexing protocol relying on specific kernel versions in the prior art is solved, and the stability and migration of business functions are improved.
Patent Information
- Application Number
- CN202411895991.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-21
- Publication Date
- 2025-04-15
AI Technical Summary
When implementing the serial multiplexing protocol, the existing technology relies on specific Linux kernel versions, resulting in poor stability of business functions and requires adaptation and adjustments for different kernel versions, which increases complexity.
Through the preset event monitoring mechanism, multiple serial ports are monitored. After monitoring the readable events of the target serial port, the target data is read and processed according to the processing strategy to realize the serial port multiplexing protocol without relying on specific kernel drivers.
Improve the stability and migration of business functions, avoid adaptation and adjustment of different kernel versions, and realize the serial port multiplexing protocol on different operating system platforms.
Smart Images

Figure CN119829495A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] With the development and maturity of the Internet of Things and 5G technologies, communication modules have been widely integrated and applied in various intelligent terminal devices, and the types of business functions carried by communication modules are also increasing, such as AT (Attention) commands, SMS, voice and data services, etc. In order to realize the data transmission of the above business functions at a lower cost, serial port multiplexing technology is usually used to realize data transmission.
[0003] Based on serial port multiplexing technology, multiple data streams can share a physical channel. Currently, in some Linux kernel versions, the Linux kernel can enable the N_GSM driver, and implement the parsing and multiplexing capabilities of the GSM0710 protocol through the N_GSM driver. However, this method is too dependent on the Linux kernel version. Since the driver implementations of different kernel versions are different, when implementing the serial port multiplexing protocol, it is necessary to adapt and adjust the service functions for different kernel versions, resulting in poor stability of the service functions. Summary of the invention
[0004] Based on this, it is necessary to provide a data processing method, apparatus, computer device, computer-readable storage medium and computer program product to address the above technical issues.
[0005] In a first aspect, the present application provides a data processing method, comprising:
[0006] Through a preset event monitoring mechanism, multiple serial ports are monitored for readable events; the multiple serial ports include at least one physical serial port and a virtual serial port corresponding to the physical serial port;
[0007] When a readable event of a target serial port among the plurality of serial ports is detected, reading target data corresponding to the target serial port;
[0008] The target data is processed based on a processing strategy corresponding to the target serial port.
[0009] In one embodiment, the method further comprises:
[0010] The file descriptor of the physical serial port and the file descriptor of the virtual serial port are added to a preset monitoring queue.
[0011] In one embodiment, the processing of the target data based on the processing strategy corresponding to the target serial port includes:
[0012] When the target serial port is a physical serial port, the target data is stored in a preset buffer, and it is determined whether the data in the buffer satisfies a data verification condition;
[0013] If the data in the buffer satisfies the data verification condition, forwarding the data in the buffer to the virtual serial port;
[0014] If the data in the buffer does not meet the data verification condition, the data in the buffer is discarded.
[0015] In one embodiment, the determining whether the data in the buffer satisfies a data verification condition includes:
[0016] When the amount of data in the buffer is greater than or equal to a preset data amount threshold, parsing the data in the buffer and verifying the parsed data;
[0017] If the data in the buffer is parsed successfully and verified successfully, the data verification condition is met;
[0018] If the data in the buffer fails to be parsed or verified, the data verification condition is not met.
[0019] In one embodiment, the processing of the target data based on the processing strategy corresponding to the target serial port includes:
[0020] In the case where the target serial port is a virtual serial port, the target data is packaged to obtain data to be transmitted;
[0021] The data to be transmitted is forwarded to the physical serial port.
[0022] In one embodiment, the method further comprises:
[0023] In response to the termination signal, sending a close command through the control channel, wherein the close command is used to close the logical channel;
[0024] The resources of the virtual serial port and the resources of the associated process corresponding to the virtual serial port are released.
[0025] In a second aspect, the present application further provides a data processing device, the device comprising:
[0026] A monitoring module, used to monitor readable events on multiple serial ports through a preset event monitoring mechanism; the multiple serial ports include at least one physical serial port and a virtual serial port corresponding to the physical serial port;
[0027] A reading module, configured to read target data corresponding to a target serial port among the plurality of serial ports when a readable event of the target serial port is detected;
[0028] A processing module is used to process the target data based on a processing strategy corresponding to the target serial port.
[0029] In one embodiment, the device further comprises:
[0030] The adding module is used to add the file descriptor of the physical serial port and the file descriptor of the virtual serial port to a preset monitoring queue.
[0031] In one embodiment, the processing module is specifically used to:
[0032] When the target serial port is a physical serial port, the target data is stored in a preset buffer, and it is determined whether the data in the buffer satisfies a data verification condition;
[0033] If the data in the buffer satisfies the data verification condition, forwarding the data in the buffer to the virtual serial port;
[0034] If the data in the buffer does not meet the data verification condition, the data in the buffer is discarded.
[0035] In one embodiment, the processing module is specifically used to:
[0036] When the amount of data in the buffer is greater than or equal to a preset data amount threshold, parsing the data in the buffer and verifying the parsed data;
[0037] If the data in the buffer is parsed successfully and verified successfully, the data verification condition is met;
[0038] If the data in the buffer fails to be parsed or verified, the data verification condition is not met.
[0039] In one embodiment, the processing module is specifically used to:
[0040] In the case where the target serial port is a virtual serial port, the target data is packaged to obtain data to be transmitted;
[0041] The data to be transmitted is forwarded to the physical serial port.
[0042] In one embodiment, the device further comprises:
[0043] A sending module, used for sending a closing command through a control channel in response to a termination signal, wherein the closing command is used for closing a logical channel;
[0044] The release module is used to release the resources of the virtual serial port and the resources of the associated process corresponding to the virtual serial port.
[0045] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the method steps of the first aspect when executing the computer program.
[0046] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method steps of the first aspect when executed by a processor.
[0047] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, which implements the method steps of the first aspect when executed by a processor.
[0048] The above-mentioned data processing method, device, computer equipment, computer-readable storage medium and computer program product can monitor readable events of multiple serial ports through a preset event monitoring mechanism; the multiple serial ports include at least one physical serial port and a virtual serial port corresponding to the physical serial port; when a readable event of a target serial port among the multiple serial ports is monitored, the target data corresponding to the target serial port is read; based on the processing strategy corresponding to the target serial port, the target data is processed. In this solution, the serial port multiplexing protocol can be implemented through the event monitoring mechanism, without relying on a specific kernel driver, and without adapting and adjusting business functions for different kernel versions, thereby improving the stability of business functions. At the same time, since there is no need to rely on a specific kernel driver, this solution can implement the serial port multiplexing protocol on different operating system platforms, thereby improving portability. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 An application environment diagram of a data processing method in an embodiment;
[0051] Figure 2 is a flow chart of a data processing method in one embodiment;
[0052] Figure 3 A system framework diagram of data processing in one embodiment;
[0053] Figure 4 is a schematic diagram of an example flow chart of a data processing method in another embodiment;
[0054] Figure 5 is a structural block diagram of a data processing device in one embodiment;
[0055] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0057] The present application embodiment provides a data processing method, which can be applied to Figure 1 In the application environment shown. The application environment includes a terminal device and a wireless communication module, wherein the terminal device may be, but is not limited to, various smart phones, tablet computers, IoT devices, vehicle-mounted devices and portable wearable devices, and the IoT devices may be smart speakers, smart TVs, smart air conditioners, smart vehicle-mounted devices, projection devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The terminal device may have communication functions, such as SMS functions, voice functions, etc. The wireless communication module may be a low-orbit satellite communication module. The terminal device and the wireless communication module may be connected via a physical cable. A control process and multiple application processes may be running in the terminal device, and the application process and the control process may be connected to their corresponding virtual serial ports respectively, and transparently communicate with the corresponding processes in the wireless communication module.
[0058] The data transmission method provided by this application will be described in detail below in conjunction with specific implementation methods. Figure 2 As shown, the method can be applied to a terminal device, comprising the following steps:
[0059] Step 202: Monitor readable events on multiple serial ports through a preset event monitoring mechanism.
[0060] The multiple serial ports include at least one physical serial port and a virtual serial port corresponding to the physical serial port.
[0061] In an embodiment of the present application, after the terminal device is started, the corresponding physical serial port can be initialized through the serial port multiplexing process according to the serial port specification of the wireless communication module, and the file descriptor of the physical serial port can be obtained. Multiple virtual serial ports can also be created through the serial port multiplexing process, and the virtual serial port file descriptor can be obtained. Among them, one virtual serial port among the multiple virtual serial ports can be used to carry channel control commands, and other virtual serial ports can be used to carry logical channel data. In an example, a virtual serial port can be created by using openpty system calls and com0com drivers. The terminal device can also register a signal capture function. The signal capture function can be used to release all resources and exit the process when a termination signal is received. The signal capture function can use SIGINT, SIGTERM, SIGKILL, etc., or a custom signal can be used.
[0062] The terminal device can also initialize the wireless communication module through the serial port multiplexing process, and enter the multiplexed transmission mode by sending AT commands. In addition, according to the preset protocol, it can send control commands to the virtual serial port of the corresponding control channel to open the required logical channel. Then, the terminal device can monitor readable events on multiple serial ports through a preset event monitoring mechanism. Among them, the event monitoring mechanism can optionally adopt event-driven mechanisms provided by operating systems such as epoll, select, kqueue, IOCP (I / O Completion Port, I / O Completion Port). It can be understood that this solution can be executed by the serial port multiplexing process in the terminal device.
[0063] Step 204 , when a readable event of a target serial port among the multiple serial ports is detected, read the target data corresponding to the target serial port.
[0064] In an embodiment of the present application, when a terminal device needs to send data, an application process in the terminal device can perform data transmission through a virtual serial port, and the terminal device can monitor the virtual serial port to determine whether there is data to be sent, so as to send the data to the wireless communication module through the physical serial port for data transmission. When the wireless communication module receives the data sent to the terminal device, the wireless communication module can send the data to the physical serial port of the terminal device through the local physical serial port so that the terminal device can receive the data. Therefore, based on the above situation, the terminal device can monitor the readable event of the target serial port (i.e., the physical serial port and / or the virtual serial port), and can obtain the target data corresponding to the target serial port. It can be understood that both of the above scenarios exist in actual applications, and the terminal device can process the corresponding target data in sequence according to the monitoring time sequence of the readable event. If the readable events of the physical serial port and the virtual serial port occur at the same time, the terminal device can process the target data of the high-priority serial port according to the preset serial port priority, and then process the target data of the low-priority serial port. In one example, the priority of the physical serial port can be higher than the priority of the virtual serial port.
[0065] Step 206: Process the target data based on the processing strategy corresponding to the target serial port.
[0066] In the embodiment of the present application, different types of serial ports have different processing strategies. The terminal can determine the processing strategy corresponding to the type of the target serial port according to the type of the target serial port, and then process the target data based on the processing strategy. For example, when the target serial port is a physical serial port, the terminal device can forward the target data to the corresponding virtual serial port to transmit the target data to the corresponding application for processing through the virtual serial port; when the target serial port is a virtual serial port, the terminal device can forward the target data to the physical serial port to send the target data for processing through the physical serial port.
[0067] In this solution, the serial port multiplexing protocol can be implemented through the event monitoring mechanism, without relying on a specific kernel driver, and without adapting and adjusting business functions for different kernel versions, thereby improving the stability of business functions. At the same time, since there is no need to rely on a specific kernel driver, this solution can implement the serial port multiplexing protocol on different operating system platforms, thereby improving portability. In addition, this embodiment uses an independent serial port multiplexing process to manage the communication with the actual physical serial port, and the application process only needs to focus on the data transmission and reception of the logical channel, thereby realizing the separation of business logic and serial port multiplexing logic. Moreover, this embodiment implements event monitoring based on an event-driven mechanism, thereby avoiding the problems of large memory usage and frequent system calls in the multi-process / multi-thread monitoring method, and effectively saving the processing resources of the device.
[0068] Optionally, the method further includes: adding the file descriptor of the physical serial port and the file descriptor of the virtual serial port to a preset monitoring queue.
[0069] In the embodiment of the present application, when initializing the physical serial port and the virtual serial port, the terminal device can obtain the file descriptor of the physical serial port and the file descriptor of the virtual serial port. Then, the file descriptor of the physical serial port and the file descriptor of the virtual serial port can be added to the preset listening queue. The listening port in the terminal device can read the file descriptor from the listening queue, and then monitor the corresponding serial port based on the file descriptor, thereby monitoring the readable events of the serial port, and can wait for the event to occur in a loop.
[0070] In this solution, event monitoring can be implemented based on an event-driven mechanism, avoiding the problems of large memory usage and frequent system calls in multi-process / multi-thread monitoring methods, and effectively saving device processing resources.
[0071] Optionally, the target data is processed based on the processing strategy corresponding to the target serial port, including: when the target serial port is a physical serial port, the target data is stored in a preset buffer, and it is determined whether the data in the buffer meets the data verification condition; if the data in the buffer meets the data verification condition, the data in the buffer is forwarded to the virtual serial port; if the data in the buffer does not meet the data verification condition, the data in the buffer is discarded.
[0072] In the embodiment of the present application, after the terminal device is started, a buffer can also be initialized. The buffer can adopt a data structure such as a ring buffer, a linked list buffer, a queue buffer, etc. The buffer can be used to cache the received data. The buffer can be a first-in-first-out queue, which supports the binary data received by the physical serial port to be queued in sequence by byte, and can be dequeued by byte.
[0073] In the case where the target serial port is a physical serial port, the terminal device can read the target data received by the physical serial port, then store the target data in a preset buffer, and determine whether the amount of data in the buffer is greater than or equal to the preset data amount threshold. If the amount of data in the buffer is greater than or equal to the preset data amount threshold, determine whether the data in the buffer meets the data verification condition. If the data in the buffer meets the data verification condition, the data in the buffer is forwarded to the virtual serial port; if the data in the buffer does not meet the data verification condition, the data in the buffer is discarded. If the amount of data in the buffer is less than the preset data amount threshold, no processing is performed until the amount of data in the buffer is greater than or equal to the preset data amount threshold.
[0074] In this solution, the data can be verified and the verified data can be forwarded to the virtual serial port, which can ensure the correctness of the data and improve the reliability of data transmission.
[0075] Optionally, determining whether the data in the buffer satisfies a data verification condition includes: when the amount of data in the buffer is greater than or equal to a preset data amount threshold, parsing the data in the buffer and verifying the parsed data; if the data in the buffer is parsed successfully and verified successfully, the data verification condition is met; if the data in the buffer fails to be parsed or verified, the data verification condition is not met.
[0076] In an embodiment of the present application, when the amount of data in the buffer is greater than or equal to a preset data amount threshold, the terminal device can call the frame structure definition of a preset protocol (such as the GSM0710 protocol) to parse the buffer data. For example, data parsing can be performed using parsing methods such as finite state machines, regular expressions, and recursive descent. Then, the terminal device can verify the parsed data based on pre-configured verification rules. For example, the data can be checked for integrity or consistency, such as using a CRC8 checksum algorithm to calculate the checksum of the data header and compare it with the FCS field of the frame message. If the data in the buffer is parsed successfully and the verification is successful, the data verification condition is met; if the data in the buffer fails to be parsed or the verification fails, the data verification condition is not met. Then, the terminal device can loop event monitoring and continue to wait for a readable event to occur.
[0077] In this solution, in high-throughput scenarios, data caching and verification mechanisms can be implemented to determine whether the data is erroneous, tampered with, or complete, thereby ensuring data reliability and consistency.
[0078] Optionally, based on the processing strategy corresponding to the target serial port, the target data is processed, including: when the target serial port is a virtual serial port, the target data is packaged to obtain data to be transmitted; and the data to be transmitted is forwarded to the physical serial port.
[0079] In the embodiment of the present application, when the target serial port is a virtual serial port, the terminal device can package the target data according to the frame structure in the preset protocol (such as the GSM0710 protocol) to obtain the data to be transmitted, and then forward the packaged data to be transmitted to the physical serial port. Then, the terminal device can loop the event monitoring and continue to wait for the readable event to occur.
[0080] In this solution, by monitoring the readable events of the virtual serial port, the target data of the virtual serial port is packaged and processed to obtain the data to be transmitted, and then the data to be transmitted is forwarded to the physical serial port. The serial port multiplexing protocol can be implemented through the event monitoring mechanism, without relying on a specific kernel driver, and without adapting and adjusting business functions for different kernel versions, which improves the stability of business functions.
[0081] Optionally, the method further includes: in response to the termination signal, sending a close command through the control channel, the close command being used to close the logical channel; and releasing resources of the virtual serial port and resources of an associated process corresponding to the virtual serial port.
[0082] In the embodiment of the present application, after receiving the termination signal, the terminal device can exit the event monitoring loop. Then, the wireless communication module can be enabled through the serial port multiplexing process, and a close command can be sent through the control channel. The close command is a control command for closing other logical channels, thereby enabling the virtual serial port and the physical serial port, releasing the resources of the virtual serial port and the resources of the associated process corresponding to the virtual serial port.
[0083] In this solution, resources can be released after receiving the termination signal, thus avoiding system resource occupation and providing high resource utilization.
[0084] The present invention provides an example of a data processing method, which can be applied to Figure 3 In the system framework shown, the system framework includes an application process, a virtual serial port, a serial port multiplexing process and a physical serial port, and the physical serial port is connected to the wireless communication module through a cable. The method can be implemented by a serial port multiplexing process, and the serial port multiplexing process can manage more than one physical serial port device and corresponding multiple logical channels. Figure 4 As shown, the following steps are included:
[0085] Step 401, initialize the physical serial port, create a virtual serial port, and initialize the buffer.
[0086] Step 402, registering a signal capture function.
[0087] Step 403, initialize the wireless communication module, send an AT command on the physical channel, enable serial port multiplexing, and send a command to enable a logical channel on the control channel.
[0088] Step 404: monitor readable events on the physical serial port and the virtual serial port through a preset event monitoring mechanism.
[0089] Step 405, determining whether a termination signal is received.
[0090] If yes, execute step 413; otherwise, execute step 406.
[0091] Step 406, monitoring whether a readable event occurs.
[0092] If yes, when the target serial port is a physical serial port, execute step 407 ; when the target serial port is a virtual serial port, execute step 411 ; otherwise, execute step 404 .
[0093] Step 407: Store the target data corresponding to the physical serial port into a preset buffer.
[0094] Step 408, determining whether the amount of data in the buffer is greater than or equal to a preset data amount threshold.
[0095] If yes, execute step 409; otherwise, execute step 404.
[0096] Step 409, determine the parsing result of the data in the buffer and judge whether the verification passes.
[0097] If the data in the buffer is parsed successfully and verified, step 410 is executed; otherwise, the data in the buffer is discarded and step 404 is executed.
[0098] Step 410: forward the data in the buffer to the virtual serial port according to the analysis result.
[0099] Step 411, according to the current channel sequence number, the target data is packaged to obtain data to be transmitted.
[0100] Step 412: forward the data to be transmitted to the physical serial port.
[0101] Step 413, enabling the wireless communication module, and sending a close command on the control channel; the close command is used to close the logical channel.
[0102] Step 414 , enabling and removing the virtual serial port, releasing the resources of the virtual serial port and the resources of the associated process corresponding to the virtual serial port.
[0103] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0104] Based on the same inventive concept, the embodiment of the present application also provides a data processing device for implementing the data processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more data processing device embodiments provided below can refer to the limitations on the data processing method above, and will not be repeated here.
[0105] In an exemplary embodiment, Figure 5 As shown, a data processing device is provided, comprising:
[0106] The monitoring module 510 is used to monitor readable events on multiple serial ports through a preset event monitoring mechanism; the multiple serial ports include at least one physical serial port and a virtual serial port corresponding to the physical serial port;
[0107] The reading module 520 is used to read the target data corresponding to the target serial port when a readable event of the target serial port among the multiple serial ports is detected;
[0108] The processing module 530 is used to process the target data based on the processing strategy corresponding to the target serial port.
[0109] In one embodiment, the device further comprises:
[0110] The adding module is used to add the file descriptor of the physical serial port and the file descriptor of the virtual serial port to a preset monitoring queue.
[0111] In one embodiment, the processing module is specifically used to:
[0112] When the target serial port is a physical serial port, the target data is stored in a preset buffer, and it is determined whether the data in the buffer satisfies a data verification condition;
[0113] If the data in the buffer satisfies the data verification condition, forwarding the data in the buffer to the virtual serial port;
[0114] If the data in the buffer does not meet the data verification condition, the data in the buffer is discarded.
[0115] In one embodiment, the processing module is specifically used to:
[0116] When the amount of data in the buffer is greater than or equal to a preset data amount threshold, parsing the data in the buffer and verifying the parsed data;
[0117] If the data in the buffer is parsed successfully and verified successfully, the data verification condition is met;
[0118] If the data in the buffer fails to be parsed or verified, the data verification condition is not met.
[0119] In one embodiment, the processing module is specifically used to:
[0120] In the case where the target serial port is a virtual serial port, the target data is packaged to obtain data to be transmitted;
[0121] The data to be transmitted is forwarded to the physical serial port.
[0122] In one embodiment, the device further comprises:
[0123] A sending module, used for sending a closing command through a control channel in response to a termination signal, wherein the closing command is used for closing a logical channel;
[0124] The release module is used to release the resources of the virtual serial port and the resources of the associated process corresponding to the virtual serial port.
[0125] Each module in the above data processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0126] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a data processing method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0127] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0128] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above-mentioned data processing method steps when executing the computer program.
[0129] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method steps of the above data processing are implemented.
[0130] In one embodiment, a computer program product is provided, comprising a computer program, which implements the above-mentioned data processing method steps when executed by a processor.
[0131] It should be noted that the user information (including but not limited to user device identification, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0132] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0133] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0134] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A data processing method, characterized in that: The method comprises: Through a preset event monitoring mechanism, multiple serial ports are monitored for readable events; the multiple serial ports include at least one physical serial port and a virtual serial port corresponding to the physical serial port; When a readable event of a target serial port among the plurality of serial ports is detected, reading target data corresponding to the target serial port; The target data is processed based on a processing strategy corresponding to the target serial port.
2. The method according to claim 1, characterized in that The method further comprises: The file descriptor of the physical serial port and the file descriptor of the virtual serial port are added to a preset monitoring queue.
3. The method according to claim 1, characterized in that The processing of the target data based on the processing strategy corresponding to the target serial port includes: When the target serial port is a physical serial port, the target data is stored in a preset buffer, and it is determined whether the data in the buffer satisfies a data verification condition; If the data in the buffer satisfies the data verification condition, forwarding the data in the buffer to the virtual serial port; If the data in the buffer does not meet the data verification condition, the data in the buffer is discarded.
4. The method according to claim 3, characterized in that The determining whether the data in the buffer satisfies a data verification condition comprises: When the amount of data in the buffer is greater than or equal to a preset data amount threshold, parsing the data in the buffer and verifying the parsed data; If the data in the buffer is parsed successfully and verified successfully, the data verification condition is met; If the data in the buffer fails to be parsed or verified, the data verification condition is not met.
5. The method according to claim 1, characterized in that The processing of the target data based on the processing strategy corresponding to the target serial port includes: In the case where the target serial port is a virtual serial port, the target data is packaged to obtain data to be transmitted; The data to be transmitted is forwarded to the physical serial port.
6. The method according to claim 1, characterized in that The method further comprises: In response to the termination signal, sending a close command through the control channel, wherein the close command is used to close the logical channel; The resources of the virtual serial port and the resources of the associated process corresponding to the virtual serial port are released.
7. A data processing device, characterized in that: The device comprises: A monitoring module, used to monitor readable events on multiple serial ports through a preset event monitoring mechanism; the multiple serial ports include at least one physical serial port and a virtual serial port corresponding to the physical serial port; A reading module, configured to read target data corresponding to a target serial port among the plurality of serial ports when a readable event of the target serial port is detected; A processing module is used to process the target data based on a processing strategy corresponding to the target serial port.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Method and system for dynamically multiplexing serial port resources
CN121579394A