Data interaction method, device, storage medium and electronic device
By separating the sequence type from the sequence generation function and thread, the data interaction and communication protocol are decoupled, which solves the problems of high coupling and poor flexibility in the existing technology, improves the flexibility and scalability of data interaction, and adapts to the sequence Type changes enhance the accuracy and compatibility of data transmission.
Patent Information
- Application Number
- CN202411069981.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-08-06
AI Technical Summary
In existing data interaction methods, data interaction and communication protocols are tightly coupled, resulting in high coupling, poor flexibility, difficulty in development and limited scalability, and cannot be easily changed or replaced.
By separating the sequence type from the sequence generation function and sequence generation thread, the data interaction and communication protocol are decoupled, allowing compatibility with multiple sequence types during the data interaction process, and adapting to sequence type changes by slightly modifying the sequence generation function and thread. .
It improves the flexibility and scalability of data interaction, reduces development difficulty, enables rapid adaptation when sequence types change, and enhances the accuracy and compatibility of data transmission.
Smart Images

Figure CN118585345B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data interaction; specifically, to a data interaction method, device, storage medium and electronic device. Background Art
[0002] In the field of communication technology, communication objects (i.e., data senders and data receivers) often need to interact with each other to implement business processing. During the data interaction process, communication protocols are needed to ensure successful interaction between communication objects.
[0003] Different communication protocols are used due to different communication objects and / or different types of interactive data; therefore, in traditional data interaction methods, data interaction is usually performed according to a specific communication protocol, which makes data interaction and communication protocol tightly coupled and cannot be easily changed, replaced or transplanted, resulting in high development difficulty and poor flexibility. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present application provide a data interaction method, device, storage medium and electronic device, which solve the problems of high coupling and poor flexibility in data interaction in related technologies. The present application separates the sequence generation function and the sequence generation thread through the sequence type, thereby decoupling the data interaction and the communication protocol, so that data of multiple sequence types can be compatible during the data interaction process; and when the sequence type changes, it can be applied by making a small amount of adaptive modifications to the sequence generation function and the sequence generation thread, with strong flexibility and extensibility and a wide range of application scenarios.
[0005] According to one aspect of an embodiment of the present application, a data interaction method is provided, which is applied to a data sending end, and the method includes: establishing a plurality of matching sequence generation functions and a plurality of sequence generation threads according to a sequence type defined in the data interaction, and setting a thread control key for the plurality of sequence generation threads; wherein at least one of the plurality of sequence generation functions is called in each sequence generation thread; when establishing a handshake link with a data receiving end, obtaining a target sequence type corresponding to currently received data; determining a corresponding target sequence generation thread from the plurality of sequence generation threads according to the target sequence type; when the target sequence generation thread obtains the thread control key, calling the corresponding target sequence generation function according to the target sequence type, and releasing the thread control key after the target sequence generation function generates data to be sent.
[0006] Optionally, when the multiple sequence generation functions include a data decoding function and a data descrambling function, obtaining the target sequence type corresponding to the currently received data includes: receiving serial data sent by the data receiving end through a first data interaction interface, and converting the serial data into parallel data; decoding the parallel data according to the data decoding function to obtain decoded data; descrambling the decoded data according to the data descrambling function to obtain the currently received data; and performing keyword positioning on the currently received data to obtain the target sequence type corresponding to the currently received data.
[0007] Optionally, releasing the thread control key after the target sequence generation function generates the data to be sent, including: establishing a data queue; the target sequence generation function generates the data to be sent and stores the data to be sent into the data queue; after waiting for a preset clock cycle, the target sequence generation thread releases the thread control key.
[0008] Optionally, the method further includes: establishing a transaction sending thread and a transaction queue, the transaction sending thread and the multiple sequence generation threads share the same thread control key; after successfully establishing a handshake link with the data receiving end, the transaction sending thread obtains the target transaction currently to be sent from the transaction queue; when the transaction sending thread obtains the thread control key, the target transaction is converted into a target data frame, and the target data frame is stored in the data queue.
[0009] Optionally, when the multiple sequence generation functions include a data encoding function, a data scrambling function and a data conversion function, the method further includes: establishing a data sending thread; the data sending thread determines whether there is data to be sent in the data queue; when there is data to be sent, scrambling the data to be sent according to the data scrambling function to generate scrambled data; encoding the scrambled data according to the data encoding function to generate encoded data; after converting the encoded data into serial data according to the data conversion function, sending the serial data to the data receiving end through the second data interaction interface.
[0010] Optionally, the sequence types include K sequence, IDLE sequence and Normal sequence, the multiple sequence generation functions include K sequence generation function, IDLE sequence generation function and Normal sequence generation function, the multiple sequence generation threads include K sequence generation thread, IDLE sequence generation thread and Normal sequence generation thread, and establish a handshake link with the data receiving end, including: when the sequence type corresponding to the received data obtained through the first data interaction interface is K sequence, triggering the K sequence generation thread to obtain the thread control key; when the K sequence generation thread obtains the thread control key, calling the K sequence generation function to generate the K sequence, and sending the K sequence to the data receiving end through the second data interaction interface; obtaining the sequence type corresponding to the received data through the first data interaction interface is When an IDLE sequence is generated, the IDLE sequence generation thread is triggered to obtain the thread control key; when the IDLE sequence generation thread obtains the thread control key, the IDLE sequence generation function is called to generate the IDLE sequence, and the IDLE sequence is sent to the data receiving end through the second data interaction interface; when the sequence type corresponding to the received data obtained through the first data interaction interface is a Normal sequence, the Normal sequence generation thread is triggered to obtain the thread control key; when the Normal sequence generation thread obtains the thread control key, the Normal sequence generation function is called to generate a Normal sequence, and after the Normal sequence is sent a preset number of times to the data receiving end through the second data interaction interface, the data sending end successfully establishes a handshake link with the data receiving end.
[0011] Optionally, the target data frame is stored in the data queue, and the method further includes: sending the target data frame to a data receiving end, so that the data receiving end parses the target data frame and sends it to a data receiving agent, and the data receiving agent converts the received parsed data into a test transaction; based on the comparison result of the test transaction and the target transaction, a verification result of the data transmission path is obtained.
[0012] According to one aspect of an embodiment of the present application, a data interaction device is provided, which is applied to a data sending end, and the device includes: a function and sequence establishment module, which is used to establish a plurality of matching sequence generation functions and a plurality of sequence generation threads according to a sequence type defined in data interaction, and set a thread control key for the plurality of sequence generation threads; wherein at least one of the plurality of sequence generation functions is called in each sequence generation thread; a sequence type acquisition module, which is used to acquire a target sequence type corresponding to currently received data when establishing a handshake link with a data receiving end; a generation thread determination module, which is used to determine a corresponding target sequence generation thread from the plurality of sequence generation threads according to the target sequence type; and a sending data generation module, which is used to call a corresponding target sequence generation function according to the target sequence type when the target sequence generation thread acquires the thread control key, and release the thread control key after the target sequence generation function generates data to be sent.
[0013] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the data interaction method in the above technical solution is implemented.
[0014] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the executable instructions so that the electronic device implements a data interaction method as in the above technical solution.
[0015] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the data interaction method in the above technical solution is implemented.
[0016] The technical solution provided by this application includes at least the following beneficial effects:
[0017] (1) This application establishes corresponding sequence generation functions and sequence generation threads through the sequence type defined by data interaction, and then generates corresponding data to be sent according to the received sequence type, so as to realize data interaction between the data receiving end and the data sending end; when the sequence type in the communication protocol is modified, added or deleted, only the changed sequence generation function and sequence generation thread need to be modified synchronously; therefore, the sequence generation function and the sequence generation thread are separated by the sequence type, so that the data interaction and the communication protocol are decoupled, so that data of multiple sequence types can be compatible during the data interaction process; and when the sequence type changes, it can be applied by making a small amount of adaptive modifications to the sequence generation function and the sequence generation thread, so that the code has strong flexibility and extensibility and a wide range of application scenarios.
[0018] (2) The present application can improve the processing efficiency of complex data by establishing multiple sequence generation threads and selecting the corresponding sequence generation thread to perform sequence generation processing according to the target sequence type corresponding to the received data; in addition, the thread control key is used to control the time-sharing and orderly processing of multiple sequence generation threads, thereby avoiding the problem of data disorder caused by the simultaneous execution of multiple sequence generation threads, thereby improving the accuracy of sent data.
[0019] (3) The interaction logic between different types of sequences in this application is the same, and the corresponding threads are used to call the corresponding sequence generation functions. Different types of sequences can be developed separately by multiple people working together, which improves development efficiency while reducing development difficulty and error rate. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0021] Figure 1 The figure is a flow chart of a data interaction method provided in an embodiment of the present application;
[0022] Figure 2 The figure shows a schematic diagram of an application scenario of a data interaction method provided in an embodiment of the present application;
[0023] Figure 3 The figure is a flow chart of another data interaction method provided in an embodiment of the present application;
[0024] Figure 4 The figure shows a schematic diagram of function and thread encapsulation provided by an embodiment of the present application;
[0025] Figure 5 The figure is a schematic diagram of the structure of a data interaction device provided in an embodiment of the present application;
[0026] Figure 6 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0027] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0028] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0029] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0030] It should also be noted that the "multiple" mentioned in this application refers to two or more than two. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship.
[0031] Figure 1 FIG. 1 is a flow chart of a data interaction method provided in an embodiment of the present application; Figure 1 As shown, the method specifically comprises the following steps:
[0032] Step S10: establishing a plurality of matching sequence generation functions and a plurality of sequence generation threads according to the sequence type defined by the data interaction, and setting thread control keys for the plurality of sequence generation threads.
[0033] It should be noted that the sequence type defined in the data interaction includes at least one of the sequence type described in the communication protocol and the custom sequence type; the communication protocol of this embodiment takes the A-PHY (Serializer-Deserializer Physical Layer Specification for Automobiles) protocol as an example, and the sequence types include idle sequence, K sequence, IDLE sequence, Normal sequence and data sequence, and the custom sequence type includes sequences defined according to application scenarios and transmission requirements; wherein, sequences between different sequence types have different data structures, and each sequence is distinguished by a specific key field.
[0034] In this embodiment, one sequence type corresponds to one sequence generation function, the sequence generation function is used to generate a corresponding sequence, and the sequence generation thread is used to process the generation process of the corresponding sequence; for example, the multiple sequence generation functions include a K sequence generation function for generating a K sequence, an IDLE sequence generation function for generating an IDLE sequence, a Normal sequence generation function for generating a Normal sequence, an idle sequence generation function for generating an idle sequence, and a data sequence generation function for generating a data sequence.
[0035] In this embodiment, at least one of the multiple sequence generation functions is called in each sequence generation thread, that is, one sequence generation function may be called in one sequence generation thread, or two or more calling functions may be called, and the setting is performed according to the actual application scenario and communication requirements. In this embodiment, one sequence generation thread calls one sequence generation function as an example, and the multiple sequence generation threads include a K sequence generation thread that processes a K sequence generation process, an IDLE sequence generation thread that processes an IDLE sequence generation process, a Normal sequence generation thread that processes a Normal sequence generation process, an idle sequence generation thread that processes an idle sequence generation process, and a data sequence generation thread that processes a data sequence generation process.
[0036] It should be noted that the multiple sequence generation functions may be set in the same class, and the association between the sequence generation function and the sequence generation thread is achieved by calling the class name and the function name in the sequence generation thread.
[0037] In this embodiment, the multiple sequence generation threads are controlled by one thread control key, that is, only one sequence generation thread can process the sequence generation process at the same time.
[0038] Step S20: when establishing a handshake link with the data receiving end, obtaining the target sequence type corresponding to the currently received data.
[0039] Figure 2 The figure is a schematic diagram of an application scenario of a data interaction method provided in an embodiment of the present application. The data interaction method provided in this embodiment is mainly applied to: Figure 2The data sending agent and the physical layer receiving end shown in the figure, wherein the data sending end includes the data sending agent; this embodiment verifies the design of the A-PHY physical layer receiving end through a verification environment composed of a data sending agent, a data receiving agent, and a comparison module. The specific verification process is as follows: ① the data sending agent sends a verification transaction to the A-PHY physical layer receiving end and the comparison module; ② the A-PHY physical layer receiving end parses the received verification transaction and sends it to the data receiving agent; ③ the monitoring module of the data receiving agent converts the received data into a test transaction and sends it to the comparison module; ④ the comparison module converts the verification transaction sent by the data sending end into a test transaction. The verification transaction is compared with the test transaction sent by the monitoring module of the data receiving agent to verify whether the transactions transmitted by the two communication lines are consistent. In addition, a verification path is also provided, in which the verification transaction is sent to the A-PHY physical layer receiving end and the comparison module through the data receiving agent. The A-PHY physical layer receiving end parses the received verification transaction and sends it to the data sending agent. The monitoring module of the data sending agent converts the received data into a test transaction and sends it to the comparison module. The comparison module compares the verification transaction sent by the data sending end with the test transaction sent by the monitoring module of the data receiving agent to verify whether the transactions transmitted by the two communication lines are consistent.
[0040] It should be noted that based on Figure 2 Before verifying the application scenario, the data sender and the data receiver need to establish a handshake link. Currently, this is achieved by building corresponding program codes through a fixed communication protocol. When the sequence type in the communication protocol changes (including addition, modification and deletion), the handshake program must be rebuilt, resulting in problems of high development difficulty and poor scalability.
[0041] In order to solve the above problem, the data sending end and the data receiving end in this embodiment obtain the target sequence type corresponding to the current received data through the monitoring module when establishing a handshake link; wherein the current received data is sent by the data receiving end, and the target sequence type is one of the idle sequence, K sequence, IDLE sequence, Normal sequence, data sequence and custom sequence recorded in the above step S10.
[0042] Step S30: Determine a corresponding target sequence generation thread from the multiple sequence generation threads according to the target sequence type.
[0043] It should be noted that, after obtaining the target sequence type corresponding to the currently received data, the multiple sequence generation threads simultaneously determine whether the target sequence type belongs to their own processing scope. After determining the target sequence generation thread corresponding to the target sequence type, the target sequence generation thread obtains the thread control key; when the thread control key is being used by other threads, the target sequence generation thread waits for a certain period of time and continues to obtain until the thread control key is obtained.
[0044] Step S40: When the target sequence generation thread obtains the thread control key, the corresponding target sequence generation function is called according to the target sequence type, and the thread control key is released after the target sequence generation function generates the data to be sent.
[0045] It should be noted that when the target sequence generation thread obtains the thread control key, the target sequence generation function called in the target sequence generation thread is executed, so that the target sequence generation function generates a sequence of the corresponding type, wherein the sequence of the corresponding type is the data to be sent to the data receiving end; after the target sequence generation function generates the data to be sent, the target sequence generation thread releases the thread control key, so that other sequence generation threads can obtain the thread control key and then perform sequence generation operations.
[0046] In one embodiment, establishing a handshake link with the data receiving end specifically includes:
[0047] When the sequence type corresponding to the received data obtained through the first data interaction interface is a K sequence, the K sequence generation thread is triggered to obtain the thread control key; when the K sequence generation thread obtains the thread control key, the K sequence generation function is called to generate the K sequence, and the K sequence is sent to the data receiving end through the second data interaction interface; when the sequence type corresponding to the received data obtained through the first data interaction interface is an IDLE sequence, the IDLE sequence generation thread is triggered to obtain the thread control key; when the IDLE sequence generation thread obtains the thread control key, the IDLE sequence generation function is called to generate the IDLE sequence, and the IDLE sequence is sent to the data receiving end through the second data interaction interface; when the sequence type corresponding to the received data obtained through the first data interaction interface is a Normal sequence, the Normal sequence generation thread is triggered to obtain the thread control key; when the Normal sequence generation thread obtains the thread control key, the Normal sequence generation function is called to generate the Normal sequence, and after the Normal sequence is sent to the data receiving end a preset number of times through the second data interaction interface, the data sending end and the data receiving end successfully establish a handshake connection.
[0048] It should be noted that the first data interaction interface and the second data interaction interface are created for receiving and sending data between the data sending end and the data receiving end; Figure 2 For example, according to the communication protocol between the data receiving end and the data sending end, when establishing a handshake link, the data receiving end first sends a K sequence, and the monitoring module in the data receiving end obtains the received data through the first data interaction interface, and parses the received data to obtain that the sequence type of the received data is a K sequence, and the K sequence generation thread enters the thread control key acquisition state. When the K sequence generation thread obtains the thread control key, the K sequence generation thread calls the K sequence generation function to also generate a K sequence, and sends the generated K sequence to the data receiving end through the second data interaction interface; further, the data receiving end receives the K sequence sent by the data sending end at the receiving end. After the sequence, an IDLE sequence is issued. The monitoring module of the data receiving end obtains the received data through the first data interaction reception. When the sequence type of the received data is obtained by parsing the current received data as an IDLE sequence, the IDLE sequence generation thread enters the acquisition state of the thread control key. When the IDLE sequence generation thread obtains the thread control key, the IDLE sequence generation thread calls the IDLE sequence generation function to also generate an IDLE sequence, and sends the generated IDLE sequence to the data receiving end through the second data interaction interface; further, the data receiving end issues a Normal sequence after the IDLE sequence sent by the data sending end of the receiving end, and the monitoring module of the data receiving end receives the received data through the first data interaction interface. When the received data is obtained and the sequence type of the received data is obtained as a Normal sequence by parsing the current received data, the Normal sequence generation thread enters the acquisition state of the thread control key. When the Normal sequence generation thread obtains the thread control key, the Normal sequence generation thread calls the Normal sequence generation function to also generate a Normal sequence, and sends the generated Normal sequence to the data receiving end through the second data interaction interface; in addition, in order to ensure that the data receiving end can normally receive the Normal sequence, the data sending end in this embodiment can send the Normal sequence to the data receiving end multiple times, which indicates that the data sending end and the data receiving end have successfully established a handshake link.
[0049] The technical solution provided in this embodiment has at least the following beneficial effects:
[0050] (1) This application establishes corresponding sequence generation functions and sequence generation threads through the sequence type defined by data interaction, and then generates corresponding data to be sent according to the received sequence type, so as to realize data interaction between the data receiving end and the data sending end; when the sequence type in the communication protocol is modified, added or deleted, only the changed sequence generation function and sequence generation thread need to be modified synchronously; therefore, the sequence generation function and the sequence generation thread are separated by the sequence type, so that the data interaction and the communication protocol are decoupled, so that data of multiple sequence types can be compatible during the data interaction process; and when the sequence type changes, it can be applied by making a small amount of adaptive modifications to the sequence generation function and the sequence generation thread, so that the code has strong flexibility and extensibility and a wide range of application scenarios.
[0051] (2) The present application can improve the processing efficiency of complex data by establishing multiple sequence generation threads and selecting the corresponding sequence generation thread to perform sequence generation processing according to the target sequence type corresponding to the received data; in addition, the thread control key is used to control the time-sharing and orderly processing of multiple sequence generation threads, thereby avoiding the problem of data disorder caused by the simultaneous execution of multiple sequence generation threads, thereby improving the accuracy of sent data.
[0052] (3) The interaction logic between different types of sequences in this application is the same, and the corresponding threads are used to call the corresponding sequence generation functions. Different types of sequences can be developed separately by multiple people working together, which improves development efficiency while reducing development difficulty and error rate.
[0053] In one embodiment of the present application, when the multiple sequence generation functions include a data decoding function and a data descrambling function, obtaining the target sequence type corresponding to the currently received data includes: receiving serial data sent by the data receiving end through a first data interaction interface, and converting the serial data into parallel data; decoding the parallel data according to the data decoding function to obtain decoded data; descrambling the decoded data according to the data descrambling function to obtain the currently received data; and performing keyword positioning on the currently received data to obtain the target sequence type corresponding to the currently received data.
[0054] It should be noted that in order to ensure the security of data during transmission, the transmitted data needs to be encoded and scrambled. Therefore, the multiple sequence generation functions include not only sequence generation functions corresponding to sequence types one by one, but also data decoding functions for decoding received data and data descrambling functions for descrambling data. Therefore, when the serial data sent by the data receiving end is received through the first data interaction interface, the first data interaction interface determines the parallel data collection point by locating the K code to realize the operation of converting the serial data into parallel data. By calling the data decoding function, the 20-bit encoded data can be decoded into 16-bit decoded data, and the data descrambling function is called to descramble the decoded data to obtain the current received data. In addition, the target sequence type corresponding to the current received data is obtained by calling the keyword positioning function.
[0055] In one embodiment of the present application, the thread control key is released after the target sequence generation function generates the data to be sent, including: establishing a data queue; the target sequence generation function generates the data to be sent and stores the data to be sent into the data queue; after waiting for a preset clock cycle, the target sequence generation thread releases the thread control key.
[0056] It should be noted that a data queue for storing a frame of sequence data is established. After the target sequence generation function generates the corresponding data to be sent, the data to be sent is stored in the data queue, waiting for the data sending process; in addition, after the data to be sent is stored in the data queue, the target sequence generation thread releases the thread control key after waiting for a preset clock cycle, wherein the preset clock cycle is the data sending duration, that is, it is necessary to wait for the data to be sent in the data queue to be sent out before releasing the thread control key, and then the data to be sent generated by other threads are stored in the data queue again, which can effectively prevent the problem of crosstalk between data.
[0057] Figure 3 FIG. 2 is a flow chart of another data interaction method provided in an embodiment of the present application; Figure 3 As shown, the data interaction method provided in this embodiment also includes the following steps:
[0058] Step S100: The target sequence generation function generates data to be sent.
[0059] Step S210: Establish a transaction sending thread and a transaction queue.
[0060] The transaction sending thread and the multiple sequence generating threads share the same thread control key.
[0061] Step S220: After successfully establishing a handshake link with the data receiving end, the transaction sending thread obtains the target transaction to be sent from the transaction queue.
[0062] Step S230: When the transaction sending thread obtains the thread control key, the target transaction is converted into a target data frame.
[0063] Step S310: store the data to be sent and the target data frame into a data queue.
[0064] Before storing the data to be sent and the target data frame into the data queue, a data queue needs to be established.
[0065] Step S320, the data sending thread determines whether there is data to be sent in the data queue, and executes step S330 when there is data to be sent, and continues to execute step S320 when there is no data to be sent.
[0066] Among them, before the data sending thread determines whether there is data to be sent in the data queue, it is necessary to establish a data sending thread specifically used for sending data. The data sending thread does not have a thread control key, that is, the data sending thread is processing the data sending task in real time. As long as there is data in the data queue, the following steps are executed. If there is no data, the judgment continues; in addition, the data to be sent in this step includes the data to be sent generated in step S100 and the target data frame converted in step S230.
[0067] Step S330: Scramble the data to be sent according to the data scrambling function to generate scrambled data.
[0068] Step S340: Encode the scrambled data according to the data encoding function to generate encoded data.
[0069] Step S350: After converting the encoded data into serial data according to the data conversion function, the serial data is sent to the data receiving end through the second data interaction interface.
[0070] It should be noted that the data interaction in this embodiment includes a handshake phase between the data sending end and the data receiving end, and a transaction verification phase after the handshake link is successful; the data to be sent generated by the sequence generation function in the handshake phase is stored in the data queue, and in the transaction verification phase, the target transaction to be sent is converted into a target data frame and is also stored in the data queue, that is, no matter in which phase, the data stored in the data queue needs to be sent to the data receiving end; therefore, the data to be sent in the data queue is scrambled, encoded, and processed by the data sending thread, and then sent to the data receiving end through the second interactive interface, thereby realizing data interaction between the data sending end and the data receiving end. In this embodiment, the handshake phase and the transaction verification phase share a data queue and a data sending thread, which reduces the difficulty of developing interactive programs and the redundancy of codes.
[0071] In one embodiment of the present application, Figure 4 As shown, the multiple sequence generation functions are encapsulated in a function class. When other functions need to be used, they are called by referencing the function class name and the function name. When the function changes, only the corresponding function in the function class needs to be modified. Other threads that call the function also make adaptive modifications without making changes. Further, when receiving received data, a data listening thread is also established and encapsulated in the listening class. The data listening thread calls the data decoding function and the data descrambling function, and the target sequence type corresponding to the currently received data is sent to the driver class, so that the multiple sequence generation threads in the driver class simultaneously determine whether the target sequence type matches the current thread. When it matches, the thread control key is obtained to generate the corresponding sequence data and then stored in the data queue. Finally, the data sending thread calls the data encoding function, the data scrambling function and the data conversion function to send the data in the data queue to the data receiving end.
[0072] In one embodiment of the present application, the target data frame is stored in the data queue, and the method further includes: sending the target data frame to a data receiving end, so that the data receiving end parses the target data frame and sends it to a data receiving agent, and the data receiving agent converts the received parsed data into a test transaction; based on the comparison result of the test transaction and the target transaction, a verification result of the data transmission path is obtained.
[0073] It should be noted that, when the target transaction to be sent is obtained, the present embodiment sends the target transaction through two paths. One is to send the target transaction directly to the comparison module, and the other path is to convert the target transaction into a target data frame and store it in a data queue. Then, the target data frame is sent to the physical layer of the data receiving end through the data sending thread. The physical layer of the data receiving end then sends the target data frame to the data receiving agent after performing operations such as data type analysis. The agent converts the received parsed data into a corresponding test transaction and sends it to the comparison module. Finally, the comparison module compares the target transaction and the test transaction for consistency. When the data of the target transaction and the test transaction are exactly the same, it indicates that the data transmission path is good. Otherwise, it indicates that there is an abnormality in the data transmission path. Therefore, by verifying the data transmission path, the stability of data transmission can be improved.
[0074] It should be noted that the transaction and sequence in this embodiment are different in data structure, and the purpose of converting a data frame or sequence into a transaction is to facilitate comparison of data consistency.
[0075] Figure 5 FIG. 1 is a schematic diagram of a data interaction device provided in an embodiment of the present application; Figure 5 As shown, the device comprises:
[0076] The function and sequence establishment module 510 is used to establish a plurality of matching sequence generation functions and a plurality of sequence generation threads according to the sequence type defined by the data interaction, and set thread control keys for the plurality of sequence generation threads; wherein each sequence generation thread calls at least one of the plurality of sequence generation functions;
[0077] The sequence type acquisition module 520 is used to acquire the target sequence type corresponding to the currently received data when establishing a handshake link with the data receiving end;
[0078] A generation thread determination module 530, configured to determine a corresponding target sequence generation thread from the plurality of sequence generation threads according to the target sequence type;
[0079] The sending data generation module 540 is used to call the corresponding target sequence generation function according to the target sequence type when the target sequence generation thread obtains the thread control key, and release the thread control key after the target sequence generation function generates the data to be sent.
[0080] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the data interaction method in the above technical solution is implemented.
[0081] Figure 6A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0082] It should be noted that Figure 6 The computer system 1000 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0083] like Figure 6 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1002 or the program loaded from the storage part 1008 to the random access memory (RAM) 1003, such as executing the method described in the above embodiment. Various programs and data required for system operation are also stored in the RAM 1003. The CPU 1001, the ROM 1002 and the RAM 1003 are connected to each other through the bus 1604. The input / output (I / O) interface 1005 is also connected to the bus 1004.
[0084] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0085] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 1009, and / or installed from a removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, various functions defined in the system of the present application are executed.
[0086] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: 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), a 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 of the above. In the present application, 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. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable computer program. 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 computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0087] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0088] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0089] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person skilled in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.
Claims
1. A data interaction method, characterized in that: Applied to a data sending end, the method comprises: Establish multiple matching sequence generation functions and multiple sequence generation threads according to the sequence type defined by data interaction, and set thread control keys for the multiple sequence generation threads; wherein at least one of the multiple sequence generation functions is called in each sequence generation thread; the sequence type defined by data interaction includes at least one of the sequence type described by the communication protocol and the user-defined sequence type; the multiple sequence generation functions include a data encoding function, a data scrambling function and a data conversion function; When establishing a handshake link with the data receiving end, obtain the target sequence type corresponding to the current received data; Determine a corresponding target sequence generation thread from the multiple sequence generation threads according to the target sequence type; When the target sequence generation thread obtains the thread control key, the corresponding target sequence generation function is called according to the target sequence type, and the thread control key is released after the target sequence generation function generates the data to be sent; Establishing a transaction sending thread, a data sending thread, a transaction queue and a data queue, wherein the transaction sending thread and the plurality of sequence generating threads share a same thread control key; After successfully establishing a handshake link with the data receiving end, the transaction sending thread obtains the target transaction to be sent from the transaction queue; When the transaction sending thread obtains the thread control key, the target transaction is converted into a target data frame, and the target data frame is stored in the data queue; The data sending thread determines whether there is data to be sent in the data queue; When the data to be sent exists, scrambling the data to be sent according to the data scrambling function to generate scrambled data; Encoding the scrambled data according to the data encoding function to generate encoded data; After the encoded data is converted into serial data according to the data conversion function, the serial data is sent to a data receiving end through a second data interaction interface.
2. The method according to claim 1, characterized in that: When the multiple sequence generation functions include a data decoding function and a data descrambling function, obtaining a target sequence type corresponding to the currently received data includes: Receiving serial data sent by the data receiving end through the first data interaction interface, and converting the serial data into parallel data; Decoding the parallel data according to the data decoding function to obtain decoded data; Descrambling the decoded data according to the data descrambling function to obtain currently received data; Perform keyword positioning on the currently received data to obtain a target sequence type corresponding to the currently received data.
3. The method according to claim 1, characterized in that Releasing the thread control key after the target sequence generation function generates the data to be sent, comprising: The target sequence generation function generates data to be sent, and stores the data to be sent into a data queue; After waiting for a preset clock cycle, the target sequence generation thread releases the thread control key.
4. The method according to claim 1, characterized in that: The sequence types include K sequence, IDLE sequence and Normal sequence, the multiple sequence generation functions include K sequence generation function, IDLE sequence generation function and Normal sequence generation function, the multiple sequence generation threads include K sequence generation thread, IDLE sequence generation thread and Normal sequence generation thread, and establishing a handshake link with the data receiving end includes: When the sequence type corresponding to the received data obtained through the first data interaction interface is a K sequence, triggering a K sequence generation thread to obtain the thread control key; When the K sequence generation thread obtains the thread control key, it calls the K sequence generation function to generate a K sequence, and sends the K sequence to the data receiving end through the second data interaction interface; When the sequence type corresponding to the received data obtained through the first data interaction interface is an IDLE sequence, triggering the IDLE sequence generation thread to obtain the thread control key; When the IDLE sequence generation thread obtains the thread control key, the IDLE sequence generation function is called to generate an IDLE sequence, and the IDLE sequence is sent to the data receiving end through the second data interaction interface; When it is obtained through the first data interaction interface that the sequence type corresponding to the received data is a Normal sequence, triggering a Normal sequence generation thread to obtain the thread control key; When the Normal sequence generation thread obtains the thread control key, calls the Normal sequence generation function to generate a Normal sequence, and sends the Normal sequence to the data receiving end a preset number of times through the second data interaction interface, the data sending end successfully establishes a handshake link with the data receiving end.
5. The method according to claim 1, characterized in that Storing the target data frame in the data queue, the method further comprises: Sending the target data frame to a data receiving end, so that the data receiving end parses the target data frame and then sends it to a data receiving agent, and the data receiving agent converts the received parsed data into a test transaction; A verification result of the data transmission path is obtained according to the comparison result of the test transaction and the target transaction.
6. A data interaction device for implementing the data interaction method according to claim 1, characterized in that: Applied to a data transmitting end, the device comprises: A function and sequence establishment module, used to establish a plurality of matching sequence generation functions and a plurality of sequence generation threads according to the sequence type defined by the data interaction, and set thread control keys for the plurality of sequence generation threads; wherein each sequence generation thread calls at least one of the plurality of sequence generation functions; The sequence type acquisition module is used to obtain the target sequence type corresponding to the current received data when establishing a handshake link with the data receiving end; A generation thread determination module, configured to determine a corresponding target sequence generation thread from the plurality of sequence generation threads according to the target sequence type; The sending data generation module is used to call the corresponding target sequence generation function according to the target sequence type when the target sequence generation thread obtains the thread control key, and release the thread control key after the target sequence generation function generates the data to be sent.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data interaction method described in any one of claims 1 to 5 is implemented.
8. An electronic device, characterized in that: include: processor; as well as A memory for storing executable instructions of the processor; wherein the processor is configured to execute the executable instructions to enable the electronic device to implement the data interaction method as described in any one of claims 1 to 5.
