CN117692100A - Data transmission method, device and system and engineering machinery - Google Patents

Data transmission method, device and system and engineering machinery Download PDF

Info

Publication number
CN117692100A
CN117692100A CN202311630830.8A CN202311630830A CN117692100A CN 117692100 A CN117692100 A CN 117692100A CN 202311630830 A CN202311630830 A CN 202311630830A CN 117692100 A CN117692100 A CN 117692100A
Authority
CN
China
Prior art keywords
data transmission
state
data
slave
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311630830.8A
Other languages
Chinese (zh)
Inventor
陈志华
童晓斌
廖滔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan Sany Intelligent Control Equipment Co Ltd
Original Assignee
Hunan Sany Intelligent Control Equipment Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan Sany Intelligent Control Equipment Co Ltd filed Critical Hunan Sany Intelligent Control Equipment Co Ltd
Priority to CN202311630830.8A priority Critical patent/CN117692100A/en
Publication of CN117692100A publication Critical patent/CN117692100A/en
Pending legal-status Critical Current

Links

Landscapes

  • Communication Control (AREA)

Abstract

The invention provides a data transmission method, a device, a system and engineering machinery, wherein the method comprises the following steps: under the condition that a preset signal used for representing the completion of the previous data transmission is detected, the data transmission state of the slave machine is adjusted to be a first preset state, and the first preset state is the slave machine state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the first preset accuracy rate; the data transmission state of the register is adjusted to be a second preset state, the register is used for forwarding data of the host computer and the slave computer, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the second preset accuracy rate; and receiving a control instruction sent by the host, and sending the first target data and/or receiving the second target data sent by the host based on the control instruction. Based on the preset signal, the slave can be adjusted to a first preset state, the register can be adjusted to a second preset state, the probability of data error transmission can be reduced, and the reliability and efficiency of data transmission can be improved.

Description

Data transmission method, device and system and engineering machinery
Technical Field
The present invention relates to the field of information processing technologies, and in particular, to a data transmission method, device, system, and engineering machinery.
Background
Currently, data transmission based on a serial peripheral interface (Serial Peripheral Interface, SPI) is generally implemented by using a Master (Master) and a Slave (Slave) together, and combining with a direct memory access (Direct Memory Access, DMA) communication module. In the process of receiving and transmitting data, the slave side can have the problem of error transmission such as data misreporting or data dislocation and the like due to various reasons.
In order to improve reliability of SPI data transmission, data transmission in conventional SPI bus communication usually uses detection or verification of data to confirm whether the transmitted data is correct, and if a data transmission error is detected, retransmission or correction of the error data is performed to improve reliability of data transmission. When the data transmission is performed in this way, if frequent data transmission errors are detected, frequent data transmission or frequent data correction is required, which results in lower reliability and efficiency of data transmission.
Disclosure of Invention
The invention provides a data transmission method, a device, a system and engineering machinery, which are used for solving the defect of low reliability and efficiency of data transmission in the prior art and achieving the purpose of improving the reliability and efficiency of data transmission.
The invention provides a data transmission method, which is applied to a slave machine, and comprises the following steps:
under the condition that a preset signal used for representing the completion of the previous data transmission is detected, the data transmission state of the slave machine is adjusted to be a first preset state, and the first preset state is the slave machine state corresponding to the data transmission accuracy rate when the first preset accuracy rate is larger than or equal to the first preset accuracy rate;
the data transmission state of a register is adjusted to be a second preset state, the register is used for forwarding data of a host computer and the slave computer, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the second preset accuracy rate;
and receiving a control instruction sent by the host, and sending first target data to the host and/or receiving second target data sent by the host based on the control instruction, wherein the control instruction is received by the slave in the first preset state and the register in the second preset state.
According to the data transmission method provided by the invention, the preset signal comprises a signal for converting a chip selection signal from a low level to a high level.
According to the data transmission method provided by the invention, the data transmission state of the slave machine is adjusted to be a first preset state, and the method comprises the following steps:
And calling an interrupt service function in the slave machine, and executing at least one of the following operations to adjust the data transmission state of the slave machine to be a first preset state:
the sent data and/or the received data stored in the slave are emptied;
determining the storage space required by the data to be sent and/or the data to be received in the slave;
and obtaining the first target data sent to the host.
According to the data transmission method provided by the invention, before the slave machine has received data to be emptied, the method further comprises the following steps:
and backing up the received data.
According to the data transmission method provided by the invention, the data transmission state of the adjustment register is a second preset state, and the data transmission method comprises the following steps:
calling an interrupt service function in the slave machine, and reading a state parameter value of the register;
and under the condition that the state parameter value is not the parameter value corresponding to the second preset state, updating the state parameter value into the parameter value corresponding to the second preset state.
According to the data transmission method provided by the invention, the method further comprises the following steps:
when the slave is electrified, the data transmission state of the slave is adjusted to be the first preset state, and the data transmission state of the register is adjusted to be the second preset state.
According to the data transmission method provided by the invention, after the first target data is sent to the host based on the control instruction and/or the second target data sent by the host is received, the method further comprises:
storing the transmitted first target data and/or second target data, and checking the transmitted first target data and/or second target data;
acquiring a verification result of the transmitted first target data and/or second target data, wherein the verification result comprises that the first target data and/or the second target data pass the verification, or that the first target data and/or the second target data do not pass the verification;
and discarding the first target data and/or the second target data under the condition that the verification result comprises that the first target data and/or the second target data is not verified.
The invention also provides a data transmission device, comprising:
the data transmission device comprises an adjustment module, a data transmission module and a data transmission module, wherein the adjustment module is used for adjusting the data transmission state of the data transmission device to be a first preset state under the condition that a preset signal used for representing the completion of the previous data transmission is detected, and the first preset state is the slave state corresponding to the data transmission accuracy rate when the first preset accuracy rate is larger than or equal to the first preset accuracy rate;
The adjusting module is further configured to adjust a data transmission state of a register to be a second preset state, where the register is configured to forward data of the host and the data transmission device, and the second preset state is a register state corresponding to a data transmission accuracy rate when the data transmission accuracy rate is greater than or equal to a second preset accuracy rate;
the receiving and transmitting module is used for receiving a control instruction sent by the host, sending first target data to the host and/or receiving second target data sent by the host based on the control instruction, wherein the control instruction is received by the data transmission device in the first preset state and the register in the second preset state.
The invention also provides a data transmission system, which comprises a host computer and a slave computer, wherein the slave computer comprises a register, and the host computer is in communication connection with the slave computer;
the slave is used for adjusting the data transmission state of the slave to be a first preset state under the condition that a preset signal used for representing the completion of the previous data transmission is detected, and the first preset state is the slave state corresponding to the data transmission accuracy rate being greater than or equal to the first preset accuracy rate;
The slave is further configured to adjust a data transmission state of the register to a second preset state, where the register is configured to forward data of the master and the slave, and the second preset state is a register state corresponding to a data transmission accuracy rate being greater than or equal to a second preset accuracy rate;
the host is used for sending a control instruction to the slave;
the slave is further configured to send first target data to the host and/or receive second target data sent by the host based on the control instruction, where the control instruction is received by the slave in the first preset state and the register is received by the slave in the second preset state.
The invention also provides a construction machine, wherein the construction machine uses the data transmission method, or the construction machine comprises the data transmission device, or the construction machine comprises the data transmission system.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing any one of the data transmission methods described above when executing the program.
The invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a data transmission method as described in any of the above.
The invention also provides a computer program product comprising a computer program which, when executed by a processor, implements a data transmission method as described in any of the above.
The invention provides a data transmission method, a device, a system and engineering machinery, wherein the method is to adjust the data transmission state of a slave to a first preset state under the condition that a preset signal used for representing the completion of the previous data transmission is detected, and the first preset state corresponds to the slave state when the data transmission accuracy rate is greater than or equal to the first preset accuracy rate; the data transmission state of the register is adjusted to be a second preset state, the register is used for forwarding data of the host computer and the slave computer, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the second preset accuracy rate; and receiving a control instruction sent by the host, and sending first target data and/or second target data sent by the host to the host based on the control instruction, wherein the control instruction is received by the slave in a first preset state and the register in a second preset state. Therefore, based on the preset signal, the slave can actively adjust the data transmission state of the register to achieve a first optimal preset state before the next data transmission, and meanwhile, the slave can also adjust the data transmission state of the register to achieve a second optimal preset state. The data transmission states of the slave and the register are adjusted, so that possible error transmission risks during data transmission can be prevented in advance, when the data transmission states of the slave and the register are adjusted to be optimal, the anti-interference capacity of the slave and the register can be improved, the probability of data error transmission caused by interference factors can be effectively reduced, and the reliability of data transmission can be improved; meanwhile, the data transmission efficiency can be improved because frequent retransmission or frequent correction of the data are avoided.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a data transmission method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of branches of data transmission according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a data transmission device according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a data transmission system according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that, in the present invention, the numbers of the described objects, such as "first", "second", etc., are only used to distinguish the described objects, and do not have any sequence or technical meaning.
The data transmission mode based on SPI bus communication can influence normal data transmission due to interference factors existing in the environment. For example, when interference factors such as high temperature, low temperature, radiation, impact, static electricity or interference of other external devices exist in the SPI communication environment, the SPI data transmission may have packet loss, error checking or error transmission such as data dislocation, which affects normal data transmission.
In order to improve the reliability of data transmission, the existing scheme generally detects the transmitted data in time after the data is transmitted, judges whether the transmission is correct based on the detected result, discards the data which is wrong when the current transmission error is detected, and needs to retransmit or correct the transmitted data. The mode can only generate the effect of timely correction after error transmission, has hysteresis, and cannot prevent error transmission in advance during transmission, so that the effect of actively preventing error transmission cannot be achieved, and the reliability and the efficiency during data transmission are lower.
Aiming at the problems, the embodiment of the invention provides a data transmission method, which is applied to a slave machine, and the method is to adjust the data transmission state of the slave machine to be a first preset state under the condition that a preset signal used for representing the completion of the previous data transmission is detected, wherein the first preset state corresponds to the slave machine state when the data transmission accuracy is greater than or equal to the first preset accuracy; the data transmission state of the register is adjusted to be a second preset state, the register is used for forwarding data of the host computer and the slave computer, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the second preset accuracy rate; and receiving a control instruction sent by the host, and sending first target data and/or second target data sent by the host to the host based on the control instruction, wherein the control instruction is received by the slave in a first preset state and the register in a second preset state. Therefore, based on the preset signal, the slave can actively adjust the data transmission state of the register to achieve a first optimal preset state before the next data transmission, and meanwhile, the slave can also adjust the data transmission state of the register to achieve a second optimal preset state. The data transmission states of the slave and the register are adjusted, so that possible error transmission risks during data transmission can be prevented in advance, when the data transmission states of the slave and the register are adjusted to be optimal, the anti-interference capacity of the slave and the register can be improved, the probability of data error transmission caused by interference factors can be effectively reduced, and the reliability of data transmission can be improved; meanwhile, the data transmission efficiency can be improved because frequent retransmission or frequent correction of the data are avoided.
The following describes a data transmission method provided by an embodiment of the present invention with reference to fig. 1 and fig. 2. Fig. 1 is a flow chart of a data transmission method according to an embodiment of the present invention, where the data transmission method according to the embodiment of the present invention is applicable to a scenario based on SPI data transmission. The execution main body of the method can be a chip, a singlechip or specially designed electronic equipment such as data transmission equipment, or can be a data transmission device arranged in the electronic equipment, and the data transmission device can be realized by software, hardware or a combination of the two. As shown in fig. 1, the data transmission method includes steps 110 to 130.
Step 110, under the condition that a preset signal for representing the completion of the previous data transmission is detected, the data transmission state of the slave is adjusted to be a first preset state, and the first preset state is the slave state corresponding to the data transmission accuracy rate being greater than or equal to the first preset accuracy rate.
Specifically, the slave may be, for example, a slave chip, and the data transmission state of the slave may be understood as a state of the chip when the slave chip performs data transmission based on the SPI, including, for example, a state of reading data from the slave chip, a state of writing data, a state of managing a memory space, and the like. The preconditioning signal may be any signal that characterizes a single SPI data transmission has been completed, for example, it may be a level signal received from a pin of a chip, or the like.
The first preset state may be a slave state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is greater than or equal to the first preset accuracy rate, where the first preset accuracy rate may be a preset arbitrary accuracy rate, for example, the first preset accuracy rate is 80%, 90% or 95%, and the first preset accuracy rate is 95% where it is understood that 95 data are transmitted correctly in every 100 data transmitted by the slave.
For example, the data transmission accuracy corresponding to the slave machine in each state can be tested in advance for the slave machine in the application scene, and the slave machine state corresponding to the data accuracy greater than or equal to the first preset accuracy is determined as the first preset state.
Step 120, adjusting the data transmission state of the register to be a second preset state, where the register is used for forwarding the data of the master and the slave, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is greater than or equal to the second preset accuracy rate.
In particular, the register may be a storage medium for forwarding data of the master and the slave, and the slave may include the register. For example, when high-speed data transmission is implemented based on SPI in combination with a DMA communication module, a storage medium that provides storage services for a DMA channel may be a register for forwarding data of a master and a slave. The DMA communication module may be part of a slave, and the host may be, for example, a host chip, where the host chip may be in communication connection with the slave chip, and the host chip may be in communication connection with the register, and the slave chip may be in communication connection with the register.
The second preset state may be a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is greater than or equal to the second preset accuracy rate, where the second preset accuracy rate may be a preset arbitrary accuracy rate, for example, may be 80%, 90% or 95%, and the second preset accuracy rate may be the same as the first preset accuracy rate, or may be different from the first preset accuracy rate. For example, for a register in an application scenario, the data transmission accuracy corresponding to the register in each state may be tested in advance, and the register state corresponding to the data accuracy greater than or equal to the second preset accuracy may be determined as the second preset state.
And 130, receiving a control instruction sent by the host, and sending first target data to the host and/or receiving second target data sent by the host based on the control instruction, wherein the control instruction is received by the slave in a first preset state and the register is in a second preset state.
Specifically, in the case where the slave adjusts the data transmission state to the first preset state and the register adjusts the data transmission state to the second preset state, the slave may transmit the first target data to the host based on the received control instruction. The control instruction sent by the host may include an instruction for indicating to send data, for example, may include a Chip Select (CS) signal and a clock signal, where the first target data is data that is needed to be transmitted to the host by the slave at the present time, and the second target data is data that is needed to be transmitted to the slave by the host at the present time.
The data transmission method provided by the embodiment of the invention is that under the condition that a preset signal used for representing the completion of the previous data transmission is detected, the data transmission state of the slave machine is adjusted to be a first preset state, and the first preset state is the slave machine state corresponding to the data transmission accuracy rate being greater than or equal to the first preset accuracy rate; the data transmission state of the register is adjusted to be a second preset state, the register is used for forwarding data of the host computer and the slave computer, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the second preset accuracy rate; and receiving a control instruction sent by the host, and sending first target data and/or second target data sent by the host to the host based on the control instruction, wherein the control instruction is received by the slave in a first preset state and the register in a second preset state. Therefore, based on the preset signal, the slave can actively adjust the data transmission state of the register to achieve a first optimal preset state before the next data transmission, and meanwhile, the slave can also adjust the data transmission state of the register to achieve a second optimal preset state. The data transmission states of the slave and the register are adjusted, so that possible error transmission risks during data transmission can be prevented in advance, when the data transmission states of the slave and the register are adjusted to be optimal, the anti-interference capacity of the slave and the register can be improved, the probability of data error transmission caused by interference factors can be effectively reduced, and the reliability of data transmission can be improved; meanwhile, the data transmission efficiency can be improved because frequent retransmission or frequent correction of the data are avoided.
In practical application, when data transmission is performed based on SPI, the change of the chip selection signal can determine whether primary data transmission between the host and the slave is completed, so that the signal representing the change of the chip selection signal can be determined as a preset signal for finishing the previous data transmission.
In one example embodiment, the preconditioning signal includes a signal in which the chip select signal transitions from a low level to a high level.
Specifically, in the SPI communication protocol, it may be specified that the chip select signal is valid at a low level, that is, when the chip select signal is valid at a low level, data transmission between the master and slave units is possible, and when the chip select signal is converted from a low level to a high level, the completion of the data transmission can be represented when the chip select signal is converted from a low level to a high level, so that when the slave unit detects that the chip select signal is converted from a low level to a high level, that is, when the slave unit detects a pull-up signal edge of the CS signal, the slave unit detects the preset signal.
Illustratively, the preconditioning signal may also include a signal equivalent to a chip select signal that is level flipped. For example, when the CS signal changes when other signals are triggered when the level of the CS signal is inverted, the changed signal may be determined as the preset signal.
In this embodiment, the preconditioning signal includes a signal that the chip select signal is converted from a low level to a high level, so that the preconditioning signal can be effectively determined by detecting a change of the chip select signal, and further, the states of the slave and the register can be triggered to be adjusted based on the preconditioning signal, so that data transmission between the master and the slave is prepared for the next time, and the accuracy and the data transmission efficiency of the data transmission are improved.
In practical application, the data and the storage space of the slave machine can be processed based on the interrupt service function, so as to adjust the data transmission state of the slave machine to a first preset state.
In an example embodiment, the adjusting the data transmission state of the slave to the first preset state may be specifically implemented by the following manner:
calling an interrupt service function in the slave machine, and executing at least one of the following operations to adjust the data transmission state of the slave machine to be a first preset state: the transmitted data and/or the received data stored in the slave are emptied; determining the storage space required by the data to be sent and/or the data to be received in the slave; and acquiring first target data sent to the host.
Specifically, the interrupt service function may be a function to be executed after data transmission of the master-slave machine is interrupted, and the interrupt service function may be set at a pin corresponding to the slave machine. After the preset signal is detected, a task of calling the interrupt service function can be triggered, and corresponding operation can be executed by calling the interrupt service function, so that the data transmission state of the slave machine is adjusted to be a first preset state.
The transmitted data stored in the slave is emptied; or, the received data stored in the slave is emptied; or, the transmitted data and the received data stored in the slave are emptied. The sent data is the data that the slave has successfully sent to the host, and the received data is the data that the slave has successfully received the host. The operation can be understood as that after the successful transmission of the previous data is completed, the data transmitted by the previous time in the slave machine is cleaned, so that no redundant data is ensured in the storage space of the slave machine, and the preparation is made for the next data transmission, therefore, the data transmission state of the slave machine can be improved.
And determining the storage space required by the data to be transmitted and/or the data to be received in the slave, wherein the data to be transmitted is the data to be transmitted next by the slave, and the data to be received is the data to be received next by the slave. The storage space required by the data to be transmitted and/or the data to be received is determined, so that the enough storage space can be ensured when the slave machine acquires the data to be transmitted or received next time, the slave machine can be ensured to completely acquire the data to be transmitted or received, and the situations of data loss, data errors and the like are avoided. Optionally, the historical data stored in the slave machine can be cleaned based on the determined data to be sent and/or the storage space required by the data to be received, so that the storage space can meet the storage requirement of the next data. After the slave has enough storage space, the first target data sent to the host is timely acquired, so that the first target data is timely prepared in place. The first target data may be at least one data to be transmitted stored in the slave, and it is understood that the plurality of data to be transmitted are sequentially transmitted after being stored in advance.
In this embodiment, when the data transmission state of the slave is adjusted to a first preset state, an interrupt service function in the slave may be invoked to execute emptying of the sent data and/or the received data stored in the slave, and at least one operation of determining, in the slave, a storage space required for the data to be sent and/or the data to be received, and obtaining the first target data sent to the host, so as to adjust the data transmission state of the slave to the first preset state. Therefore, after the completion of the previous data transmission is detected, the data transmission state of the slave machine can be adjusted in time, so that the slave machine is in a state with higher transmission accuracy, the situation that the slave machine is in a poor data transmission state is prevented in advance, the occurrence of error transmission conditions such as packet loss and data dislocation is avoided, the reliability of data transmission is improved, and the efficiency of data transmission is improved.
In one embodiment, before the slave device empties the received data, the method further comprises: and backing up the received data.
Specifically, after the slave machine receives the second target data sent by the master machine, the second target data can be stored in the memory of the slave machine for backup, so that the slave machine can apply. After the slave receives the new second target data sent by the host, the slave can perform storage backup on the new second target data after the second target data received last time is emptied.
For example, when the received data is backed up, the backed up data may be batched or completely emptied after the backup duration reaches a certain period of time; or after the data volume of the backup reaches a certain threshold, the backup data is batched or completely emptied. Based on the method, the received data can be reasonably backed up and emptied according to the memory space resources of the slave and the actual application requirements of the data, and the application flexibility is improved.
In this embodiment, before the received data in the slave is emptied, the received data is backed up, so that the situation that the data is lost and the like affects the normal application of the data can be avoided, and the applicability of the method is improved.
In practical application, the data transmission state of the register can be adjusted by calling the interrupt service function, so that errors when data passes through the register for reading and writing are avoided, and the accuracy of data transmission is improved.
In an exemplary embodiment, the adjusting the data transmission state of the register to the second preset state may be specifically implemented by:
calling an interrupt service function in the slave machine, and reading a state parameter value of a register; and under the condition that the state parameter value is not the parameter value corresponding to the second preset state, updating the state parameter value to the parameter value corresponding to the second preset state.
Specifically, the interrupt service function may be the same interrupt service function in the above embodiment, and call the interrupt service function set by the corresponding pin of the slave machine, so that corresponding operations may be executed to read and write the state parameter value of the register.
By way of example, the state parameter values of the registers may be various types of parameter values that control the operation of the registers, such as values that characterize the state of the memory address to which the DMA corresponds. And calling an interrupt service function in the slave machine, and reading the state parameter values of the register, wherein the current state parameter value of the register is rewritten to be updated to the parameter value corresponding to the second preset state under the condition that at least one value in the state parameter values is not the parameter value corresponding to the second preset state.
For example, when the data transmission accuracy corresponding to each state of the register is tested in advance, a state parameter value corresponding to the second preset state can be obtained, where the state parameter value is a target value for rewriting the state parameter value of the register by calling the interrupt service function. After updating each parameter value of the register to be the state parameter value corresponding to the second preset state, the data transmission state of the register can be adjusted to the second preset state.
In this embodiment, when the data transmission state of the register is adjusted to be the second preset state, an interrupt service function in the slave machine may be called, and the state parameter value of the register may be read; and under the condition that the state parameter value is not the parameter value corresponding to the second preset state, updating the state parameter value to the parameter value corresponding to the second preset state. Based on the method, the data transmission state of the register can be adjusted in time, so that the register is in a state with higher transmission accuracy, errors caused when the host computer and the slave computer read and write the register are prevented, the situations of packet loss or data errors and the like during data transmission are avoided, the reliability of the data transmission is improved, and the efficiency of the data transmission can be improved.
In practical application, in order to enable the master-slave machine to avoid transmitting error data during the first data transmission, the data transmission states of the slave machine and the register may be optimized before the first data transmission.
In an example embodiment, the method further comprises: when the slave is powered on, the data transmission state of the slave is adjusted to be a first preset state, and the data transmission state of the register is adjusted to be a second preset state.
Specifically, when the slave is powered on, the data transmission states of the slave and the register can be respectively adjusted in an initializing mode.
For example, when the slave is powered up, the slave performs an initialization operation to initialize the slave and the register, where the initialization operation may include adjusting the data transmission states of the slave and the register. For example, when the initializing operation is performed, the slave may perform at least one operation, such as emptying a storage space of the slave, determining, in the slave, a storage space required for data to be transmitted and/or data to be received, acquiring first target data sent to the host, and so on, to adjust a data transmission state of the slave to a first preset state; and reading the state parameter value of the register, and updating the state parameter value to the parameter value corresponding to the second preset state under the condition that the state parameter value is not the parameter value corresponding to the second preset state so as to adjust the data transmission state of the register to be the second preset state.
In this embodiment, when the slave is powered on, the data transmission state of the slave is adjusted to be a first preset state, and the data transmission state of the register is adjusted to be a second preset state. Based on the method, the host and the slave can avoid transmitting error data when the data is transmitted for the first time, the reliability of each data transmission of the master and the slave is ensured, and the data transmission efficiency is improved.
In practical application, in order to further improve reliability of data transmission, the first target data and/or the second target data may be checked after the data transmission, and whether the transmitted data is available is determined according to a check result of the data, so as to ensure that correct data is used when the data is applied.
In an example embodiment, after the first target data is sent to the host and/or the second target data sent by the host is received based on the control instruction, the method further includes:
storing the transmitted first target data and/or second target data, and checking the transmitted first target data and/or second target data; acquiring a verification result of the transmitted first target data and/or second target data, wherein the verification result comprises that the first target data and/or second target data pass the verification, or that the first target data and/or second target data do not pass the verification; and discarding the first target data and/or the second target data under the condition that the verification result comprises that the first target data and/or the second target data is not verified.
Specifically, the data verification may be performed on the first target data and/or the second target data that are transmitted at this time, for example, the first target data and/or the second target data may be verified by at least one of data verification methods such as a verification bit of the verification data and a verification data length, so as to obtain a verification result that includes that the first target data and/or the second target data pass, or that the first target data and/or the second target data fail. In the case that the verification result includes that the first target data and/or the second target data are not verified, the first target data and/or the second target data may be erroneous data, and the first target data and/or the second target data may be discarded.
Fig. 2 is a schematic diagram of each branch of data transmission provided in the embodiment of the present invention, as shown in fig. 2, when a master and a slave perform data transmission based on SPI, data storage, data detection and data application may be performed on target data to be transmitted through two branches of branch 1 and branch 2. On the basis, a branch 3 can be added in the slave machine to detect the CS signal, and when the CS signal is detected to be converted from low level to high level, the interrupt is transmitted, namely, an interrupt service function is called to reset and adjust the data transmission states of the data and the SPI.
Specifically, the pulled up signal edge of the CS signal is a trigger signal, i.e., a preconditioning signal, as a function of port interrupt service. The preset signal can be detected through the interrupt service function of the slave after each data transmission is completed, and when the preset signal is detected, the interrupt service function is called to adjust the data transmission states of the slave and the register. Branch 3 may be understood as a process branch where data reliability guarantees are made before the SPI next starts transmitting. When the CS signal is detected to be converted from low to high level when the prior SPI communication is finished, the data and the state of the DMA and the SPI are processed in the interrupt service function of the corresponding pin, so that the state and the data can be ensured to be the optimal state in the next data transmission; when the next time the host sends the SPI interaction data signal, the slave and the register set the state to be the best, so that the accuracy and reliability of the SPI data can be ensured; the CS signal detection and the interruption service function call execution are repeated, so that the reliability of data in the whole SPI communication process can be ensured, and the data in the whole working period is prevented from losing packets.
By applying the method provided by the embodiment of the invention to various control devices in the engineering machinery industry, the reliability of the devices can be effectively improved, and the interaction time delay of the devices can be reduced. The prior art cannot perform data guarantee and communication guarantee processing before SPI data communication, so that the target data may be in error during data detection, a certain number of error data packets exist in the whole operation period, and the efficiency of data transmission can be affected by frequent processing of the error data packets. The method of the embodiment of the invention can pre-adjust the data transmission states of the slave and the register and reduce the probability of generating error data packets, thereby improving the data transmission efficiency, effectively improving the reliability of the equipment and reducing the interaction delay of the equipment.
When the transmission of the current SPI data packet is completed, detecting an exit point corresponding to a CS signal at a slave terminal, namely converting the CS signal from a low level to a high level, and binding the signal into an interrupt service function of the slave terminal to trigger the interrupt service function; in the interrupt service function, processing the received data and the data to be sent of the next packet, and processing the DMA channel and SPI states related to transmission, so as to ensure that the data, the DMA and the SPI are all in the optimal state required by the next communication; when the data transmission is completed, the data can be checked and detected through the steps shown in the branch 1 and the branch 2, so that the error data can be ensured not to enter the data application end.
In this embodiment, after the first target data and/or the second target data sent by the host are sent to the host based on the control instruction, the first target data and/or the second target data may be stored and checked, and a check result of the first target data and/or the second target data is obtained; and discarding the first target data and/or the second target data under the condition that the verification result comprises that the first target data and/or the second target data is not verified. Thus, erroneous data can be avoided, and reliability in applying the data can be improved, and applicability of the method is also improved.
The data transmission device provided by the embodiment of the present invention is described below, and the data transmission device described below and the data transmission method described above may be referred to correspondingly.
Fig. 3 is a schematic structural diagram of a data transmission device according to an embodiment of the present invention, and referring to fig. 3, a data transmission device 300 includes:
an adjustment module 310, configured to adjust a data transmission state of the data transmission device 300 to a first preset state when a preset signal for representing completion of a previous data transmission is detected, where the first preset state is a slave state corresponding to a data transmission accuracy rate being greater than or equal to the first preset accuracy rate;
the adjusting module 310 is further configured to adjust a data transmission state of a register to be a second preset state, where the register is configured to forward data of the host and the data transmission device 300, and the second preset state is a register state corresponding to a data transmission accuracy rate when the data transmission accuracy rate is greater than or equal to the second preset accuracy rate;
the transceiver module 320 is configured to receive a control instruction sent by the host, and send the first target data and/or the second target data sent by the host to the host based on the control instruction, where the control instruction is received by the data transmission device 300 in a first preset state and the register is in a second preset state.
In one example embodiment, the preconditioning signal includes a signal in which the chip select signal transitions from a low level to a high level.
In an example embodiment, the adjustment module 310 is specifically configured to:
calling an interrupt service function in the slave machine, and executing at least one of the following operations to adjust the data transmission state of the slave machine to be a first preset state:
the transmitted data and/or the received data stored in the slave are emptied;
determining the storage space required by the data to be sent and/or the data to be received in the slave;
and acquiring first target data sent to the host.
In an example embodiment, the data transmission apparatus 300 further includes a backup module;
and the backup module is used for backing up the received data.
In an example embodiment, the adjustment module 310 is specifically configured to:
calling an interrupt service function in the slave machine, and reading a state parameter value of a register;
and under the condition that the state parameter value is not the parameter value corresponding to the second preset state, updating the state parameter value to the parameter value corresponding to the second preset state.
In an example embodiment, the adjustment module 310 is further to:
when the slave is powered on, the data transmission state of the slave is adjusted to be a first preset state, and the data transmission state of the register is adjusted to be a second preset state.
In an example embodiment, the data transmission apparatus 300 further includes a verification module and an acquisition module;
the verification module is used for storing the transmitted first target data and/or second target data and verifying the transmitted first target data and/or second target data;
the acquisition module is used for acquiring the verification result of the transmitted first target data and/or second target data, wherein the verification result comprises that the first target data and/or second target data pass the verification, or the first target data and/or second target data do not pass the verification;
and the verification module is also used for discarding the first target data and/or the second target data under the condition that the verification result comprises that the first target data and/or the second target data are not verified.
The apparatus of the present embodiment may be used to execute the method of any one of the embodiments of the data transmission method side, and its specific implementation process and technical effects are similar to those of the embodiments of the data transmission method side, and specific reference may be made to the detailed description of the embodiments of the data transmission method side, which is not repeated herein.
Fig. 4 is a schematic structural diagram of a data transmission system according to an embodiment of the present invention, and referring to fig. 4, a data transmission system 400 includes a master 410 and a slave 420, the slave 420 includes a register 421, and the master 410 is communicatively connected to the slave 420;
The slave 420 is configured to adjust a data transmission state of the slave 420 to a first preset state when a preset signal for representing completion of a previous data transmission is detected, where the first preset state corresponds to a slave state when a data transmission accuracy rate is greater than or equal to the first preset accuracy rate;
the slave 420 is further configured to adjust a data transmission state of the register 421 to a second preset state, where the register 421 is configured to forward data of the master 410 and the slave 420, and the second preset state is a register state corresponding to a data transmission accuracy rate being greater than or equal to the second preset accuracy rate;
a master 410 for transmitting a control instruction to a slave 420;
the slave 420 is further configured to send the first target data to the host 410 and/or receive the second target data sent by the host 410 based on a control instruction, where the control instruction is received by the slave 420 in a first preset state and the register 421 is in a second preset state.
The data transmission system of the present embodiment may be used for executing any data transmission method executed by the slave in the data transmission method side embodiment, and its specific implementation process and technical effects are similar to those of the data transmission method side embodiment, and specific reference may be made to the detailed description in the data transmission method side embodiment, which is not repeated herein.
The embodiment of the invention also provides a construction machine, which uses the data transmission method provided in any embodiment, or comprises the data transmission device provided in the embodiment, or comprises the data transmission system provided in the embodiment. The data transmission method comprises the following steps: under the condition that a preset signal used for representing the completion of the previous data transmission is detected, the data transmission state of the slave machine is adjusted to be a first preset state, and the first preset state is the slave machine state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the first preset accuracy rate; the data transmission state of the register is adjusted to be a second preset state, the register is used for forwarding data of the host computer and the slave computer, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the second preset accuracy rate; and receiving a control instruction sent by the host, and sending first target data and/or second target data sent by the host to the host based on the control instruction, wherein the control instruction is received by the slave in a first preset state and the register in a second preset state.
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, as shown in fig. 5, the electronic device may include: processor 510, communication interface (Communications Interface) 520, memory 530, and communication bus 540, wherein processor 510, communication interface 520, memory 530 complete communication with each other through communication bus 540. Processor 510 may invoke logic instructions in memory 530 to perform a data transfer method comprising: under the condition that a preset signal used for representing the completion of the previous data transmission is detected, the data transmission state of the slave machine is adjusted to be a first preset state, and the first preset state is the slave machine state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the first preset accuracy rate; the data transmission state of the register is adjusted to be a second preset state, the register is used for forwarding data of the host computer and the slave computer, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the second preset accuracy rate; and receiving a control instruction sent by the host, and sending first target data and/or second target data sent by the host to the host based on the control instruction, wherein the control instruction is received by the slave in a first preset state and the register in a second preset state.
Further, the logic instructions in the memory 530 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, an embodiment of the present invention further provides a non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor, is implemented to perform a data transmission method provided by the above methods, the method including: under the condition that a preset signal used for representing the completion of the previous data transmission is detected, the data transmission state of the slave machine is adjusted to be a first preset state, and the first preset state is the slave machine state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the first preset accuracy rate; the data transmission state of the register is adjusted to be a second preset state, the register is used for forwarding data of the host computer and the slave computer, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the second preset accuracy rate; and receiving a control instruction sent by the host, and sending first target data and/or second target data sent by the host to the host based on the control instruction, wherein the control instruction is received by the slave in a first preset state and the register in a second preset state.
In yet another aspect, embodiments of the present invention further provide a computer program product, the computer program product including a computer program, the computer program being storable on a non-transitory computer readable storage medium, the computer program, when executed by a processor, being capable of performing the data transmission method provided by the methods above, the method comprising: under the condition that a preset signal used for representing the completion of the previous data transmission is detected, the data transmission state of the slave machine is adjusted to be a first preset state, and the first preset state is the slave machine state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the first preset accuracy rate; the data transmission state of the register is adjusted to be a second preset state, the register is used for forwarding data of the host computer and the slave computer, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the second preset accuracy rate; and receiving a control instruction sent by the host, and sending first target data and/or second target data sent by the host to the host based on the control instruction, wherein the control instruction is received by the slave in a first preset state and the register in a second preset state.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A data transmission method, applied to a slave, comprising:
under the condition that a preset signal used for representing the completion of the previous data transmission is detected, the data transmission state of the slave machine is adjusted to be a first preset state, and the first preset state is the slave machine state corresponding to the data transmission accuracy rate when the first preset accuracy rate is larger than or equal to the first preset accuracy rate;
the data transmission state of a register is adjusted to be a second preset state, the register is used for forwarding data of a host computer and the slave computer, and the second preset state is a register state corresponding to the data transmission accuracy rate when the data transmission accuracy rate is larger than or equal to the second preset accuracy rate;
And receiving a control instruction sent by the host, and sending first target data to the host and/or receiving second target data sent by the host based on the control instruction, wherein the control instruction is received by the slave in the first preset state and the register in the second preset state.
2. The data transmission method of claim 1, wherein the preconditioning signal comprises a signal in which a chip select signal transitions from a low level to a high level.
3. The method for data transmission according to claim 1, wherein the adjusting the data transmission state of the slave machine to be the first preset state includes:
and calling an interrupt service function in the slave machine, and executing at least one of the following operations to adjust the data transmission state of the slave machine to be a first preset state:
the sent data and/or the received data stored in the slave are emptied;
determining the storage space required by the data to be sent and/or the data to be received in the slave;
and obtaining the first target data sent to the host.
4. A data transmission method according to claim 3, wherein prior to flushing the slave machine of received data, the method further comprises:
And backing up the received data.
5. The method according to any one of claims 1-4, wherein the adjusting the data transmission state of the register to be the second preset state includes:
calling an interrupt service function in the slave machine, and reading a state parameter value of the register;
and under the condition that the state parameter value is not the parameter value corresponding to the second preset state, updating the state parameter value into the parameter value corresponding to the second preset state.
6. The method for data transmission according to any one of claims 1 to 4, further comprising:
when the slave is electrified, the data transmission state of the slave is adjusted to be the first preset state, and the data transmission state of the register is adjusted to be the second preset state.
7. The data transmission method according to claim 1, wherein after the first target data is transmitted to the host and/or the second target data transmitted by the host is received based on the control instruction, the method further comprises:
storing the transmitted first target data and/or second target data, and checking the transmitted first target data and/or second target data;
Acquiring a verification result of the transmitted first target data and/or second target data, wherein the verification result comprises that the first target data and/or the second target data pass the verification, or that the first target data and/or the second target data do not pass the verification;
and discarding the first target data and/or the second target data under the condition that the verification result comprises that the first target data and/or the second target data is not verified.
8. A data transmission apparatus, comprising:
the data transmission device comprises an adjustment module, a data transmission module and a data transmission module, wherein the adjustment module is used for adjusting the data transmission state of the data transmission device to be a first preset state under the condition that a preset signal used for representing the completion of the previous data transmission is detected, and the first preset state is the slave state corresponding to the data transmission accuracy rate when the first preset accuracy rate is larger than or equal to the first preset accuracy rate;
the adjusting module is further configured to adjust a data transmission state of a register to be a second preset state, where the register is configured to forward data of the host and the data transmission device, and the second preset state is a register state corresponding to a data transmission accuracy rate when the data transmission accuracy rate is greater than or equal to a second preset accuracy rate;
The receiving and transmitting module is used for receiving a control instruction sent by the host, sending first target data to the host and/or receiving second target data sent by the host based on the control instruction, wherein the control instruction is received by the data transmission device in the first preset state and the register in the second preset state.
9. A data transmission system comprising a master and a slave, said slave comprising a register, said master and said slave being communicatively coupled;
the slave is used for adjusting the data transmission state of the slave to be a first preset state under the condition that a preset signal used for representing the completion of the previous data transmission is detected, and the first preset state is the slave state corresponding to the data transmission accuracy rate being greater than or equal to the first preset accuracy rate;
the slave is further configured to adjust a data transmission state of the register to a second preset state, where the register is configured to forward data of the master and the slave, and the second preset state is a register state corresponding to a data transmission accuracy rate being greater than or equal to a second preset accuracy rate;
the host is used for sending a control instruction to the slave;
The slave is further configured to send first target data to the host and/or receive second target data sent by the host based on the control instruction, where the control instruction is received by the slave in the first preset state and the register is received by the slave in the second preset state.
10. A construction machine, characterized in that it uses the data transmission method according to any one of claims 1-7, or that it comprises the data transmission device according to claim 8, or that it comprises the data transmission system according to claim 9.
CN202311630830.8A 2023-11-30 2023-11-30 Data transmission method, device and system and engineering machinery Pending CN117692100A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311630830.8A CN117692100A (en) 2023-11-30 2023-11-30 Data transmission method, device and system and engineering machinery

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311630830.8A CN117692100A (en) 2023-11-30 2023-11-30 Data transmission method, device and system and engineering machinery

Publications (1)

Publication Number Publication Date
CN117692100A true CN117692100A (en) 2024-03-12

Family

ID=90131044

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311630830.8A Pending CN117692100A (en) 2023-11-30 2023-11-30 Data transmission method, device and system and engineering machinery

Country Status (1)

Country Link
CN (1) CN117692100A (en)

Similar Documents

Publication Publication Date Title
US7676617B2 (en) Posted memory write verification
CA1226371A (en) Communications method
US6804800B2 (en) Method and apparatus for detecting and recovering from errors in a source synchronous bus
WO2019136595A1 (en) Method for handling i2c bus deadlock, electronic device, and communication system
US20060179391A1 (en) Wireless identification protocol with confirmation of successful transmission
US9652322B2 (en) User station of a bus system and method for transmitting messages between user stations of a bus system
JP2004180295A (en) System and method for detecting lost message transmitted between modules in communication device
US20070061681A1 (en) Mechanism for error handling of corrupted repeating primitives during frame reception
CN103270497A (en) Method and system of live error recovery
CN104866454A (en) Write message prospect processing method and device facing board-level high-speed bus
US9780938B2 (en) Patch download with improved acknowledge mechanism
CN111224837B (en) Method and system for automatically identifying CAN communication baud rate of vehicle ECU
CN117692100A (en) Data transmission method, device and system and engineering machinery
CN112084137A (en) SerDes high-robustness transceiver circuit
US20030154288A1 (en) Server-client system and data transfer method used in the same system
US5003460A (en) Method for the transmission of connection data stored in a communication switching system to a data processing system
CN112217600A (en) Data frame receiving method and device, and communication method and system
CN112311502B (en) Data retransmission method, device, controller and medium based on optical fiber communication system
CN116743324B (en) Data transmission method, device, receiving end, storage medium, system and server
US20230305987A1 (en) Communication control apparatus and communication method
JPH09326782A (en) Serial communication method
CN115664599B (en) Data transmission method and device, electronic equipment and storage medium
US8291143B1 (en) Single line communication
CN118113207A (en) Data writing method, storage device and electronic equipment
WO2022086798A1 (en) Repeated in sequence packet transmission for checksum comparison

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination