Disclosure of Invention
In view of the above, it is necessary to provide a message processing apparatus, a message processing method, and a communication system, which are directed to the problem that it is difficult for a conventional communication device to achieve both of the hardware cost of the system and the reliability of communication.
In order to achieve the above object, an embodiment of the present invention provides a message processing apparatus, including a buffer pool, a message receiving unit, an inquiry response unit, and a report message processing unit; the buffer pool comprises a plurality of buffer areas;
the message receiving unit is used for caching the report message transmitted by the slave equipment to a buffer area;
the inquiry response unit is used for blocking the operation of the message receiving unit according to an inquiry command sent by the master equipment and waiting for receiving the data transmitted by the slave equipment; the data comprises a response message and a reporting message; the data processing device is also used for processing the response message when detecting that the data is the response message; when the data is detected to be a report message, caching the report message into a buffer area;
and the report message processing unit is used for reading the report message from the buffer area and processing the read report message.
In one embodiment, the message receiving unit is further configured to apply for a buffer area with an idle status from the buffer pool according to the report message, and buffer the report message to the buffer area; and when the buffer of the report message is finished, changing the state of the buffer into a ready state.
In one embodiment, the query response unit is further configured to, when it is detected that the data is a report message, buffer the report message to a buffer area whose state is idle, and change the state of the buffer area to a ready state when the buffer of the report message is completed.
In one embodiment, the report message processing unit is further configured to read a report message from a buffer in a ready state, and process the read report message.
In one embodiment, the message receiving unit is further configured to acquire a receive lock before buffering a report message transmitted from the device in the buffer; the receiving lock is used for representing the authority of receiving the message; after the report message transmitted by the slave equipment is cached in the buffer area, releasing the receiving lock;
the inquiry response unit is also used for acquiring a receiving lock before the blocking message receiving unit operates; after detecting that the data is a response message, the receive lock is released.
In one embodiment, the message receiving unit is further configured to release the receiving lock if the report message is not received within a preset time after the receiving lock is acquired.
In one embodiment, the message receiving unit is further configured to acquire a buffer lock before buffering a report message transmitted from the device in the buffer; the buffer lock is used for representing the authority of caching the message into the buffer; after the report message transmitted by the slave equipment is cached to the buffer area, releasing the buffer area lock;
the query response unit is also used for acquiring a buffer lock before the report message is cached to the buffer; and releasing the buffer lock after the report message is cached in the buffer.
In one embodiment, the message receiving unit is further configured to change a state of the buffer area to a busy state when the report message is cached in the buffer area;
and the inquiry response unit is also used for buffering the received data to a buffer area with busy state after waiting for receiving the data transmitted from the equipment.
In one embodiment, the query response unit is further configured to acquire a buffer lock before buffering the received data in a buffer with a busy status; after buffering the received data to a buffer that is busy, the buffer lock is released.
In one embodiment, the report message processing unit is further configured to empty the buffer and change the state of the buffer into an idle state after the read report message is processed.
In one embodiment, the report message processing unit is further configured to acquire a buffer lock before the buffer is emptied; after changing the state of the buffer to an idle state, the buffer lock is released.
In one embodiment, the query response unit is further configured to feed back a query failure message to the master device when the response message is not detected within a preset time.
On the other hand, an embodiment of the present invention further provides a message processing method, including the following steps:
caching a report message transmitted from the equipment to a buffer area by using a message receiving unit;
using the query response unit to block the operation of the message receiving unit according to the query command sent by the master device and wait for receiving the data transmitted by the slave device; the data comprises a response message and a reporting message; processing the response message when detecting that the data is the response message; when the data is detected to be a report message, caching the report message into a buffer area;
and reading the report message from the buffer area by using a report message processing unit, and processing the read report message.
On the other hand, the embodiment of the invention also provides a communication system, which comprises a master device and a slave device connected with the master device;
the master device is used for executing the steps of the message processing method.
In one embodiment, the master device connects to the slave device through a serial interface.
In another aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the steps of the message processing method.
One of the above technical solutions has the following advantages and beneficial effects:
when the slave equipment generates the report message, the slave equipment can actively transmit the report message to the master equipment by operating the message receiving unit and the report message processing unit, and then the master equipment can process the report message in time; specifically, the message receiving unit may buffer the report message transmitted by the slave device to the buffer, and the report message processing unit reads and processes the report message in the buffer, so that the master device may process the report message actively reported by the slave device in time. When the master device needs to inquire the slave device, the master device can actively acquire the response message of the slave device by operating the inquiry response unit; specifically, the query response unit may block the message receiving unit from operating according to the query command, and wait to receive data transmitted from the device; processing the response message when detecting that the data is the response message; when the data is detected to be the report message, the report message is cached to the buffer area, and then the report message in the buffer area can be read and processed through the report message processing unit, so that the report message of the slave equipment can be received in time in the process that the master equipment acquires the response message, the report message is prevented from being lost, and the communication reliability is improved; in addition, the message processing device can be realized in a communication interface with low reliability, and the cost of a hardware system is greatly reduced.
Detailed Description
To facilitate an understanding of the present application, the present application will now be described more fully with reference to the accompanying drawings. Preferred embodiments of the present application are shown in the drawings. This application may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
In one embodiment, as shown in fig. 1, a message processing apparatus is provided, which includes a buffer pool 110, a message receiving unit 120, a query response unit 130, and a report message processing unit 140; the buffer pool 110 includes a plurality of buffers.
The message receiving unit 120 is configured to buffer the report message transmitted from the device into a buffer.
A query response unit 130, configured to block the message receiving unit from operating according to a query command sent by the master device, and wait for receiving data transmitted by the slave device; the data comprises a response message and a reporting message; the data processing device is also used for processing the response message when detecting that the data is the response message; and when the data is detected to be the report message, caching the report message into a buffer area.
And a report message processing unit 140, configured to read a report message from the buffer, and process the read report message.
The buffer pool 110 refers to a buffer for buffering data, and the buffer can be used for classifying and buffering report messages. The buffer pool 110 may include a plurality of buffers, which may be used to buffer the report messages. The reporting message refers to a reporting message which is actively sent to the master device by the slave device; for example, when the slave device generates an exception, a report message indicating that the exception is generated may be generated. The master device may be a communication device; the slave device may be a communication device. The message receiving unit 120 may be configured to receive a report message; in one example, at system initialization, the message receiving unit may be started, and the report message may be received in real time by the message receiving unit 120. The report message processing unit 140 can be used to process the report message. The query response unit 130 is configured to receive data (including a response message and a report message), process the received response message, and buffer the received report message; in one example, when the master device needs to actively query the slave device, the query response unit 130 may be started, and the query response process is processed by the query response unit 130. The query command refers to a query instruction; in one example, the master device may send the generated query command to the slave device, and the slave device feeds back a response message to the master device according to the query command.
Specifically, when the slave device generates a report message and needs to report the report message to the master device, the report message transmitted by the slave device may be cached in the buffer by starting the message receiving unit 120, so that the slave device actively transmits the report message to the master device; by starting the report message processing unit 140, reading and processing the report message in the buffer, the urgent report message of the slave device can be processed in time. When the master device needs to query the slave device, the query response unit 130 is started, and the message receiving unit is blocked from operating according to the query command sent by the master device and waits for receiving the data transmitted by the slave device; after receiving data transmitted by the slave equipment, judging the type of the data, and processing the response message when detecting that the data is the response message, so as to realize that the master equipment actively acquires the response message of the slave equipment; when the data is detected to be the report message, the report message is cached in the buffer area, and then the report message in the buffer area can be read and processed through the report message processing unit 140, so that the report message of the slave device can be received in time in the process that the master device acquires the response message, the loss of the report message is prevented, and the communication reliability is improved.
Further, when the system is initialized, the message receiving unit 120 and the report message processing unit 140 may be started, and the message receiving unit 120 detects whether the report message of the slave device is received, and if the report message is received, the report message is cached in the buffer; if the report message is not received, whether the report message is received or not is continuously detected. The report message processing unit 140 may traverse each buffer in the buffer pool, read the report message from the buffer, and process the read report message, so as to implement timely processing of the report message of the slave device. In the system operation process, if the master device actively sends a query command to the slave device, the query response unit 130 can be started, and the message receiving unit is blocked by the query response unit 130, so that the message receiving unit is temporarily stopped from operating and cannot be scheduled; after sending the query command to the slave device, the master device enters a waiting stage and waits for receiving the data transmitted by the slave device. In the waiting phase, the query response unit 130 may detect whether the received data is a response message in real time, and if the data is detected to be the response message, directly process the response message; if the detected data is a report message, the report message is cached in the buffer area, and then the report message can be read and processed by the report message processing unit 140, so as to realize the high-reliability communication of the system.
It should be noted that the message receiving unit 120, the query responding unit 130, and the report message processing unit 140 may be configured on the master device.
It should be noted that, at a time node, only the message receiving unit 120 or the query responding unit 130 operates, that is, the message receiving unit 120 or the query responding unit 130 cannot operate simultaneously.
Based on the embodiment, when the slave device generates the report message, the slave device can actively transmit the report message to the master device by operating the message receiving unit and the report message processing unit, and then the master device can process the report message in time; when the master device needs to inquire the slave device, the master device can receive the data transmitted by the slave device by operating the inquiry response unit, so that the master device can actively acquire the response message of the slave device and buffer the received reported message in time; the real-time communication of the master device and the slave device can be realized in a communication interface with low reliability, the cost of a hardware system is greatly reduced, the real-time processing of the report message and the response message is realized, the conflict caused by the processing of the response message and the report message is prevented, the loss of the report message is prevented, and the reliability of the communication is improved.
In an embodiment, as shown in fig. 1, the message receiving unit 120 is further configured to apply for a buffer with an idle status from the buffer pool according to the report message, and buffer the report message to the buffer; and when the buffer of the report message is finished, changing the state of the buffer into a ready state.
The buffer area is in an idle state and can be used for indicating that the report message is not cached in the buffer area at the current moment; the state of the buffer is ready state, which can indicate that the buffer has the report message buffered at the current time.
Specifically, when receiving the report message, the message receiving unit 120 may apply for a buffer with an idle status from the buffer pool 110 according to the received report message, and buffer the received report message into the buffer. After the report message is buffered, the state of the buffer can be changed to a ready state, so that the report message processing unit 140 can read the report message. By setting the buffer state in the buffer area, the message receiving unit can buffer the report message in a classified manner, so that the conflict of processing is prevented from being eliminated.
In an embodiment, as shown in fig. 1, the query response unit 130 is further configured to buffer the report message into a buffer with a free state when detecting that the data is the report message, and change the state of the buffer into a ready state when the buffer of the report message is finished.
Specifically, when detecting that the data transmitted from the device is the report message, the query response unit 130 may apply for a buffer with a free status from the buffer pool, and buffer the report message into the buffer. After the report message is buffered, the state of the buffer can be changed to a ready state, so that the report message processing unit 140 can read the report message. By acquiring the report message in time in the process of query response, the report message can be prevented from being lost; by setting the buffer state in the buffer area, the query response unit can buffer the report message in a classified mode, and the conflict of processing is prevented from being eliminated.
In an embodiment, as shown in fig. 1, the report message processing unit 140 is further configured to read a report message from a buffer with a ready status, and process the read report message.
Specifically, the report message processing unit 140 may query the status of each buffer area in the buffer pool 110, and if the status of the buffer area is the ready status, read the report message from the buffer area in the ready status, and process the read report message, so as to implement timely processing of the report message.
In an embodiment, as shown in fig. 1, the message receiving unit 120 is further configured to obtain a receiving lock before buffering the report message transmitted from the device in the buffer; the receiving lock is used for representing the authority of receiving the message; and releasing the receiving lock after buffering the report message transmitted from the equipment to the buffer.
The query response unit 130 is further configured to acquire a receiving lock before the blocking message receiving unit operates; after detecting that the data is a response message, the receive lock is released.
The receiving lock can be used for indicating the authority of receiving the report message and can also be used for indicating the authority of receiving the response message. The authority for receiving the reported message can be obtained by obtaining the receiving lock; by releasing the receiving lock, the authority for receiving the reported message can be released, so that other units (such as a message receiving unit) can acquire the receiving lock.
Specifically, when the slave device generates a report message and needs to report the report message to the master device, the receiving lock may be acquired by starting the message receiving unit 120; according to the obtained receiving lock, the reporting message transmitted by the slave equipment can be cached in the buffer area, and after the buffering of the reporting message is finished, the receiving lock can be released, so that the message receiving process of the current round is completed. The slave device actively transmits the report message to the master device. When the master device needs to query the slave device, the receiving lock can be acquired by starting the query response unit 130; after the receiving lock is obtained, the operation of the message receiving unit 120 can be further blocked according to the query command sent by the master device, and the receiving of the data transmitted by the slave device is waited; when the data is detected to be the response message, the receiving lock can be released, the response message is processed, and the master device actively acquires the response message of the slave device; by setting the receiving lock, the conflict of message transmission can be prevented, and the communication reliability is improved.
Further, before the message receiving unit 120 receives the report message, the receiving lock may be acquired; after the buffer of the reported message is finished and the state of the buffer area is changed into the ready state, the receiving lock can be released, and the message receiving of the current round is completed.
In one example, the master device is connected with the slave device through the serial interface, and by setting a mechanism of a receiving lock, the message is not lost when the master device and the slave device communicate on the serial interface, so that the communication reliability is improved.
In an embodiment, as shown in fig. 1, the message receiving unit 120 is further configured to release the receiving lock if the report message is not received within a preset time after the receiving lock is acquired.
Specifically, after the message receiving unit 120 obtains the receiving lock, if the report message is not received within the preset time, that is, if the message reception is overtime, it indicates that the report message is not received in the current round, the receiving lock is released, and the message reception in the current round is ended, so that the message receiving unit 120 is prevented from occupying the receiving lock when the slave device does not generate the report message for a long time or the message reception is abnormal, and the reliability of communication is improved.
In an embodiment, as shown in fig. 1, the message receiving unit 120 is further configured to obtain a buffer lock before buffering the report message transmitted from the device into the buffer; the buffer lock is used for representing the authority of caching the message into the buffer; and releasing the buffer lock after buffering the report message transmitted from the equipment to the buffer.
The query response unit 130 is further configured to obtain a buffer lock before the report message is cached in the buffer; and releasing the buffer lock after the report message is cached in the buffer.
Wherein the buffer lock is operable to indicate the authority of the buffer; the buffer zone authority comprises read, write, erase and other authorities, wherein the read authority can be used for reading the message of the buffer zone; write permissions may be used to cache messages to a buffer; the erase authority may be used to empty the buffer.
Specifically, when the slave device generates a report message and needs to report the report message to the master device, the buffer lock may be acquired by starting the message receiving unit 120; according to the acquired buffer lock, the report message transmitted from the equipment can be cached to the buffer; after the report message is cached in the buffer area, the buffer area lock is released, the message caching of the current round is realized, the data conflict in the data caching process is prevented, and the message synchronization and the mutual exclusion are realized in the process that the slave device actively transmits the report message to the master device. When the master device needs to inquire the slave device, if the data is detected to be the report message, the buffer lock can be acquired, the report message can be cached in the buffer, and after the buffer caching is finished, the buffer lock can be released, so that the current round of report message caching is completed. And the master device receives the reported message of the slave device in time in the process of acquiring the response message, so that data conflict in the process of message caching is prevented, and the communication reliability is improved.
In an embodiment, as shown in fig. 1, the message receiving unit 120 is further configured to change the state of the buffer to a busy state when the message buffer is reported to the buffer.
The query response unit 130 is further configured to buffer the received data into a buffer with a busy status after waiting for receiving the data transmitted from the device.
The buffer status is busy status, which can indicate that the buffer is buffering the report message at the current moment, and the report message is not buffered completely.
Specifically, when receiving the report message, the message receiving unit 120 may apply for a buffer with an idle status from the buffer pool 110 according to the received report message, and buffer the received report message into the buffer. When the reporting message starts to be cached, the state of the buffer area can be changed into a busy state, and the busy state of the buffer area is set so as to indicate that the reporting message is in the caching process. The query response unit 130 blocks the operation of the message receiving unit, and waits for receiving data transmitted from the device, and if a buffer with a busy state exists in the current buffer pool, it indicates that the buffer with the busy state is caching a report message, that is, the data received by the query response unit 130 is a report message at this time, and further buffers the received data (i.e., the report message) to the buffer with the busy state, so as to prevent the report message from being lost in the query response process.
In one embodiment, as shown in fig. 1, the query response unit 130 is further configured to obtain a buffer lock before buffering the received data into a buffer with a busy status; after buffering the received data to a buffer that is busy, the buffer lock is released.
Specifically, when the query response unit 130 blocks the operation of the message receiving unit and waits for receiving data transmitted from the device, if a buffer with a busy state exists in the current buffer pool 110, it indicates that the buffer with the busy state is caching a report message, and then obtains a buffer lock, and further caches the received data (i.e., the report message) to the buffer with the busy state based on the obtained buffer lock; after the data is cached, the buffer lock is released, so that the reported message is timely received in the query response process, and the reported message is prevented from being lost in the query response process.
In an embodiment, as shown in fig. 1, the report message processing unit 140 is further configured to empty the buffer and change the state of the buffer into an idle state after the read report message is processed.
Specifically, after reading the report message from the buffer and processing the report message, the report message processing unit 140 clears the buffer, and changes the state of the buffer into an idle state, so as to reinitialize the buffer corresponding to the report message after processing the report message, so as to be used in subsequent message buffers, thereby improving the utilization rate of the buffers. In other embodiments, the report message processing unit 140 may empty the buffer after reading the report message in the buffer and change the state of the buffer into an idle state between processing the report message.
It should be noted that, in an example, the report message processing unit 140 may obtain the buffer lock before reading the report message from the buffer, and further may read the report message from the buffer according to the read permission of the buffer lock. After reading the reporting message from the buffer, the buffer lock is released. In another example, the report message processing unit 140 can also directly read the report message from the buffer without first acquiring the buffer lock.
In an embodiment, as shown in fig. 1, the report message processing unit 140 is further configured to obtain a buffer lock before the buffer is emptied; after changing the state of the buffer to an idle state, the buffer lock is released.
Specifically, the report message processing unit 140 may obtain a buffer lock after reading the report message from the buffer and processing the report message; clearing the buffer area based on the acquired buffer area lock, and changing the state of the buffer area into an idle state; after the state of the buffer area is changed into an idle state, releasing the buffer area lock, and after the reported message is processed, re-initializing the buffer area corresponding to the reported message; by setting the buffer lock, the reliability of communication is improved.
In one embodiment, as shown in fig. 1, the query response unit 130 is further configured to feed back a query failure message to the master device when the response message is not detected within a preset time.
Wherein the query failure message may be used to indicate a query result response timeout.
Specifically, when the master device needs to query the slave device, the query response unit 130 may be started, and wait for the master device to send a query command; if the main equipment is not detected to send the query command within the preset time, the query response is considered to be overtime, a query failure message is fed back to the main equipment, and the query response process of the round is received.
The embodiment can be realized in a communication interface with low reliability, greatly reduces the cost of a hardware system, avoids the conflict easily caused by processing the report message and the response message in the communication process, and improves the reliability of communication.
In one embodiment, as shown in fig. 2, it is a work flow diagram of a message receiving unit, and the specific work process of the message receiving unit is as follows:
when the slave equipment generates a report message and needs to report the report message to the master equipment, a receiving lock can be obtained by starting the message receiving unit; judging whether a report message is received within a preset time, if the report message is not received, indicating that the message is received overtime, releasing a receiving lock, and finishing the message receiving of the current round; if the report message is received, applying for a buffer area with an idle state from the buffer pool, acquiring a buffer area lock, and caching the received report message into the buffer area based on the acquired buffer area lock; when the report message is cached, changing the state of the buffer area into a busy state to indicate that the buffer area is receiving the report message; after the report message is received, the state of the buffer area is changed into a ready state, which indicates that the report message of the buffer area is completely buffered and can be used by the report message processing unit.
As shown in fig. 3, it is a work flow diagram of the query response unit, and the specific work process of the query response unit is as follows:
when the master equipment needs to inquire the slave equipment, the receiving lock can be obtained by starting the inquiry response unit; according to the query command sent by the master device, the message receiving unit is blocked from running and waits for receiving the data transmitted by the slave device; when waiting to receive data transmitted by slave equipment, detecting whether a buffer area with busy state exists in a buffer pool, if so, acquiring a buffer area lock, continuing to cache the received data in the buffer area with busy state, and releasing the buffer area lock after the data caching is finished; when receiving data transmitted from the equipment, judging whether the detected data is a response message; if the data is detected to be the response message, releasing the receiving lock, and processing the response message to realize that the master device actively acquires the response message of the slave device; if the data is detected to be the report message, obtaining a buffer lock, applying for a buffer with a free state from the buffer pool, and caching the report message to the buffer with the free state; after the buffer of the report message is finished, the buffer lock is released, so that the report message of the slave equipment is received in time in the process of acquiring the response message by the master equipment, the report message is prevented from being lost, and the communication reliability is improved.
As shown in fig. 4, which is a working flow diagram of the report message processing unit, the specific working process of the report message processing unit is as follows:
buffering the report message into a buffer pool, and after the buffer of the report message is finished, changing the state of the buffer area into a ready state; the report message processing unit can judge whether a buffer zone with busy state exists in the buffer pool by traversing each buffer zone in the buffer pool, if so, the report message of the buffer zone is read, and the report message is reported; after the processing of the report message is finished, the buffer lock can be acquired, the buffer corresponding to the report message is emptied, and the state of the buffer is changed into an idle state, i.e. the buffer is reinitialized for subsequent message reception to continue using the buffer.
It should be noted that, when the message receiving unit applies for a buffer with a free status from the buffer pool, it may record an ID (identification code) of the buffer, and may be used to subsequently determine whether there is a report message that is not received at the current time by recording the ID of the buffer, and may also be used to determine whether there is a buffer with a busy status in traversing the buffer.
Based on the embodiment, a high-reliability double-end communication mechanism can be realized in a low-reliability communication interface, so that the master device on the bus can actively receive the response message and can also receive the burst report data of the slave device at any time.
In one embodiment, as shown in FIG. 5, a message processing method is provided. The method comprises the following steps:
step S510, the message receiving unit is used to buffer the report message transmitted from the device into the buffer.
Step S520, the query response unit is used for blocking the operation of the message receiving unit according to the query command sent by the master device and waiting for receiving the data transmitted by the slave device; the data comprises a response message and a reporting message; processing the response message when detecting that the data is the response message; and when the data is detected to be the report message, caching the report message into a buffer area.
Step S530, the report message processing unit is used to read the report message from the buffer area and process the read report message.
The specific content processes of step S510, step S520, and step S530 may refer to the content described above for the message processing apparatus, and are not described herein again.
Specifically, when the slave device generates the report message, the slave device can actively transmit the report message to the master device by operating the message receiving unit and the report message processing unit, and the master device can process the report message in time; when the master device needs to inquire the slave device, the master device can actively acquire the response message of the slave device by operating the inquiry response unit, and the report message of the slave device is timely received in the process of acquiring the response message by the master device, so that the loss of the report message is prevented, and the communication reliability is improved; in addition, the message processing device can be realized in a communication interface with low reliability, and the cost of a hardware system is greatly reduced.
It should be understood that, although the steps in the flowchart of fig. 5 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps in fig. 5 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 6, a communication system is provided. The system includes a master device 610 and a slave device 620 connected to the master device 610.
The master device 610 may be configured to perform the following steps:
caching a report message transmitted from the equipment to a buffer area by using a message receiving unit;
using the query response unit to block the operation of the message receiving unit according to the query command sent by the master device and wait for receiving the data transmitted by the slave device; the data comprises a response message and a reporting message; processing the response message when detecting that the data is the response message; when the data is detected to be a report message, caching the report message into a buffer area;
and reading the report message from the buffer area by using a report message processing unit, and processing the read report message.
Based on the embodiment, high-reliability communication can be realized in the communication interface with low reliability, the cost of a hardware system is greatly reduced, and an effective and reliable communication mechanism is provided for the communication system of a low-cost product. Therefore, the master device on the bus can actively receive the response message and can also receive the burst reported data of the slave device at any time.
In one embodiment, as shown in fig. 7, a communication system is provided, comprising a master device 710 and a slave device 720 connected to the master device 710; wherein the master device 710 is connected to the slave device 720 through a serial interface.
The master device 710 may be used to perform the following steps:
caching a report message transmitted from the equipment to a buffer area by using a message receiving unit;
using the query response unit to block the operation of the message receiving unit according to the query command sent by the master device and wait for receiving the data transmitted by the slave device; the data comprises a response message and a reporting message; processing the response message when detecting that the data is the response message; when the data is detected to be a report message, caching the report message into a buffer area;
and reading the report message from the buffer area by using a report message processing unit, and processing the read report message.
Based on the embodiment, high-reliability communication can be realized in the serial interface with low reliability, the cost of a hardware system is greatly reduced, and an effective and reliable communication mechanism is provided for a communication system of a low-cost product. Therefore, the master device on the bus can actively receive the response message and can also receive the burst reported data of the slave device at any time.
For the specific definition of the communication system, reference may be made to the above definition of the message processing apparatus, which is not described herein again.
It should be noted that the master device may operate the message processing apparatus, for example, the master device may configure the message processing apparatus, and implement high-reliability communication by processing the message receiving unit, the query response unit, and the report message processing unit through a thread.
It should be noted that, when a plurality of slave devices are connected to the corresponding master device for communication, a specific communication process is similar to that when the master device is connected to one slave device for communication, and details are not described herein again.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
caching a report message transmitted from the equipment to a buffer area by using a message receiving unit;
using the query response unit to block the operation of the message receiving unit according to the query command sent by the master device and wait for receiving the data transmitted by the slave device; the data comprises a response message and a reporting message; processing the response message when detecting that the data is the response message; when the data is detected to be a report message, caching the report message into a buffer area;
and reading the report message from the buffer area by using a report message processing unit, and processing the read report message.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the division methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.