Protocol self-adaption method, device and equipment of electric energy meter and storage medium
By implementing the protocol adaptive method in the power meter, the verification bit is automatically set according to the verification method negotiated by both parties of the communication and selecting the appropriate protocol, the verification method of the power meter cannot support the different verification methods of the DL/T645-2007 and MODBUS protocols. Communication issues improve system universality and data transmission efficiency.
Patent Information
- Application Number
- CN202411580013.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2044-11-07
AI Technical Summary
The existing power meters cannot support the two verification methods of the DL/T645-2007 protocol and the MODBUS protocol at the same time, resulting in inconsistent communication, requiring manual switching of the protocol, which is inconvenient.
By implementing the protocol adaptive method in the power meter, the verification bit is automatically set according to the verification method negotiated by both parties of the communication, and selecting the appropriate communication protocol for data processing by analyzing the verification method in the data frame, the two types of communication are realized Compatibility of the protocol.
It realizes that the power meter supports the use of multiple communication protocols at the same time, avoids manual switching, improves the universality and flexibility of the system, and enhances the efficiency and reliability of data transmission.
Smart Images

Figure CN119094631A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication transmission technology, and in particular to a protocol self-adaptation method, device, equipment and storage medium for an electric energy meter. Background Art
[0002] The application scenarios of energy meters are very wide. In household electricity consumption, energy meters are mainly used to measure the power consumption of household appliances, lighting, air conditioning and other equipment. In smart buildings, industrial fields, and commercial electricity consumption, energy meters are used to monitor power usage, optimize energy consumption, improve energy efficiency, and reduce operating or production costs.
[0003] The widely used communication protocol in the field of electric energy meters is the DL / T645-2007 protocol, which can be used to exchange data with electric energy meters. In the industrial field, automation field, and manufacturing field, the widely used communication protocol is the MODBUS protocol. Therefore, while the electric energy meter supports the DL / T645-2007 protocol, it is also very necessary to support the MODBUS protocol. The check bit of each data in the DL / T645-2007 protocol is fixed to even check, while the check bit of each data in the MODBUS protocol can be set to odd check, even check, or no check. Therefore, the communication formats of the DL / T645-2007 protocol and the MODBUS protocol are inconsistent.
[0004] Under normal circumstances, the energy meter acts as a slave, and the master station needs to interact with the energy meter, and the check bits must be consistent for normal communication. The MCU in the energy meter has a built-in data transmission and reception (Universal Asynchronous Receiver / Transmitter, UART) function. The principle of UART receiving 1 byte of data is as follows: data is received on a single line with a width of 1 bit, and 1 byte of data is divided into 1 start bit (low level), 8 data bits, 0 / 1 check bits, and 1 stop bit (high level), which are received in sequence at the transition edge of the UART clock.
[0005] If the check bit settings are inconsistent, for example, the energy meter is set to no check, and the master station is set to even check, then when receiving the stop bit, the check bit sent by the master station device will be received, and data reception will be misaligned; for example, the energy meter is set to odd check, and the master station is set to even check, then when receiving the check bit, the check bits of both parties will be inconsistent.
[0006] At present, the electric energy meters that support these two communication protocols usually use key switching or sending to switch the communication protocol. When the DL / T645-2007 protocol is needed, the parity bit inside the electric energy meter is switched to even parity; when the MODBUS communication protocol is needed, the parity bit inside the electric energy meter is uniformly set to odd parity, even parity or no parity according to the prior negotiation between the two communicating parties. That is, after the communication protocol is set, only one communication protocol can be used to communicate with the electric energy meter at the same time. When you want to use another communication protocol, you need to switch manually. The two communication protocols are not adaptive, which is inconvenient to use. Summary of the invention
[0007] In view of this, the present invention provides a protocol adaptation method, device, equipment and storage medium for an electric energy meter to solve the technical problem in the prior art that the electric energy meter cannot support two communication protocols with different verification methods for communication at the same time.
[0008] In a first aspect, the present invention provides a protocol adaptation method for an electric energy meter, comprising: receiving a data frame transmitted by a communication object based on a first communication protocol uniformly negotiated by both communicating parties, wherein, when communicating with the communication object, the check bit of the electric energy meter data sent and received is set to be consistent with the negotiated check method, and the check bit of the first communication protocol includes an even check and a preset check; when the negotiated check method is an even check, parsing the received data frame to determine the communication protocol corresponding to the data frame, and performing data processing on the received data frame according to the corresponding communication protocol, wherein the corresponding communication protocols include the first communication protocol and the second communication protocol, and the check bit of the second communication protocol is fixed to an even check; when the negotiated check method is a preset check, judging whether each byte in the received data frame conforms to the preset check or conforms to the even check, and selecting the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame conforms to the preset check or conforms to the even check.
[0009] A protocol adaptation method for an electric energy meter of the present invention sets the check bit of the electric energy meter data transmission and reception to be consistent with a negotiated check method when communicating with a communication object, receives a data frame transmitted by the communication object based on a first communication protocol uniformly negotiated by both communication parties, and when the negotiated check method is an even check, parses the received data frame to determine the communication protocol corresponding to the data frame, performs data processing on the received data frame according to the corresponding communication protocol, and when the negotiated check method is a preset check, determines whether each byte in the received data frame complies with the preset check or complies with the even check, selects the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with the preset check or complies with the even check, and even if the check methods of the first communication protocol and the second communication protocol are different, it is possible to use the uniformly negotiated first communication protocol for communication while also using the second communication protocol for communication at the same time, without the need for manual switching, and is easy to use.
[0010] Optionally, the preset check includes odd check and no check; correspondingly, when the negotiated check mode is the preset check, determine whether each byte in the received data frame complies with the preset check or complies with the even check, and select the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with the preset check or complies with the even check, including: when the negotiated check mode is odd check, determine whether each byte in the received data frame complies with odd check or complies with even check, and select the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with odd check or complies with even check; when the negotiated check mode is no check, determine whether each byte in the received data frame complies with no check or complies with even check, and select the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with no check or complies with even check.
[0011] In this manner, the received data is processed respectively according to the preset check as odd check and no check, allowing the electric energy meter to communicate with devices using different check methods, thereby enhancing the versatility and flexibility of the system.
[0012] Optionally, judging whether each byte in the received data frame conforms to odd parity or even parity includes: after receiving any byte in the data frame, generating an interrupt and jumping to the interrupt execution location, reading the check status bit of the currently received byte at the interrupt execution location, judging whether the currently received byte conforms to odd parity through the check status bit, and counting the number of bytes that do not conform to odd parity in the received data frame through a check bit error counter; after receiving the data frame, if the value of the check bit error counter is equal to zero, then each byte in the received data frame conforms to odd parity, and if the value of the check bit error counter is equal to the number of bytes of the received data frame, then each byte in the received data frame conforms to even parity.
[0013] In this mode, the check mode is directly determined by checking the status bit, so that transmission errors can be quickly identified and processed, thereby improving the efficiency and reliability of data transmission.
[0014] Optionally, judging whether each byte in the received data frame conforms to odd parity or even parity, comprises: after receiving any byte in the data frame, generating an interrupt and jumping to the interrupt execution location, calculating the number of bits with a value of 1 among the 8 data bits and the parity check bit of the currently received byte at the interrupt execution location, judging whether the currently received byte conforms to odd parity according to the number of bits with a value of 1 among the 8 data bits and the parity check bit of the currently received byte, and counting the number of bytes that do not conform to odd parity in the received data frame through a check bit error counter; after receiving the data frame, if the value of the check bit error counter is equal to zero, then each byte in the received data frame conforms to odd parity, and if the value of the check bit error counter is equal to the number of bytes of the received data frame, then each byte in the received data frame conforms to even parity.
[0015] In this method, the check mode is determined by using the 8 data bits of the current received byte and the number of bits with a value of 1 in the parity check bit. This method is applicable to the case where there is no check status bit, thus broadening the scope of application.
[0016] Optionally, judging whether each byte in the received data frame complies with no check or even check, comprises: reading the pin level after receiving 1 start bit, 8 data bits and 1 stop bit of any byte in the data frame, judging whether the currently received byte complies with even check by the number of bits with the value of 1 in the 8 data bits and the pin level, and judging whether the pin level is a high level, and counting the number of bytes in the received data frame that comply with even check and the number of bytes with the pin level being a high level by an even check counter and a high level counter respectively; after receiving the data frame, if the value of the high level counter is equal to the number of bytes in the received data frame, then each byte in the received data frame complies with no check, and if the value of the even check counter is equal to the number of bytes in the received data frame, then each byte in the received data frame complies with even check.
[0017] In this method, the verification mode is judged by the number of bits with a value of 1 in the 8-bit data bit and the pin level and whether the pin level is a high level, so that it can be accurately determined whether the verification mode is no verification or even verification, thereby providing a reference for subsequent processing.
[0018] Optionally, after processing the received data frame through the second communication protocol, it also includes: setting the check bit of the electric energy meter data sent and received to even check, replying data to the communication object in an even check manner, and after the reply is completed, restoring the check bit of the electric energy meter data sent and received to a preset check.
[0019] In this manner, after processing the data through the second communication protocol, the check bit is set to even check for reply, and then the preset check is restored, thereby ensuring the accuracy of the reply data, maintaining the consistency of the communication protocol, and enhancing the stability of the communication.
[0020] Optionally, the first communication protocol is the MODBUS protocol, and the second communication protocol is the DL / T645-2007 protocol; correspondingly, parsing the received data frame to determine the communication protocol corresponding to the data frame includes: dividing the received data frame into an address field, a function code, data, and a CRC check according to the MODBUS protocol, and judging in turn whether the address field, the function code, and the CRC check are correct; if the address field, the function code, and the CRC check are correct, then the communication protocol corresponding to the data frame is the MODBUS protocol; dividing the received data frame into an address field, a function code, data, and a CRC check according to the DL / T645-2007 protocol The received data frame is divided into 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H. Whether 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H are correct are judged in turn. If 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H are all correct, the communication protocol corresponding to the data frame is the DL / T645-2007 protocol.
[0021] In this method, it is clarified that the first communication protocol is the MODBUS protocol and the second communication protocol is the DL / T645-2007 protocol. The MODBUS protocol is a widely used industrial communication protocol with high compatibility and reliability. Therefore, the electric energy meter can easily communicate with a variety of industrial automation equipment, improving the system's integration and practicality.
[0022] In a second aspect, the present invention provides a protocol adaptive device for an electric energy meter, comprising: a data receiving module, for receiving a data frame transmitted by a communication object based on a first communication protocol uniformly negotiated by both communicating parties, wherein, when communicating with the communication object, the check bit of the electric energy meter data transmission and reception is set to be consistent with the negotiated check mode, and the check bit of the first communication protocol includes an even check and a preset check; an even check processing module, for parsing the received data frame to determine the communication protocol corresponding to the data frame when the negotiated check mode is an even check, and performing data processing on the received data frame according to the corresponding communication protocol, wherein the corresponding communication protocol includes the first communication protocol and the second communication protocol, and the check bit of the second communication protocol is fixed to an even check; a preset check processing module, for judging whether each byte in the received data frame complies with the preset check or whether it complies with the even check when the negotiated check mode is the preset check, and judging whether each byte in the received data frame complies with the preset check or whether it complies with the even check when the negotiated check mode is the preset check, and selecting the corresponding communication protocol to perform data processing on the received data frame based on whether each byte in the received data frame complies with the preset check or complies with the even check.
[0023] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the protocol adaptation method of the electric energy meter according to the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0024] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the protocol adaptation method for an electric energy meter according to the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0026] Figure 1 is a flow chart of a protocol self-adaptation method for an electric energy meter according to an embodiment of the present invention; Figure 2 It is a flow chart of the analysis of the MODBUS protocol of an embodiment of the present invention; Figure 3 It is a parsing flow chart of the DL / T645-2007 protocol of an embodiment of the present invention; Figure 4 is a flow chart of judging even check and odd check according to an embodiment of the present invention; Figure 5 1 is a schematic diagram of pin levels of even parity and no parity during interruption according to an embodiment of the present invention; Figure 6 is a flow chart of judging even check and no check according to an embodiment of the present invention; Figure 7 is a structural block diagram of a protocol adaptive device for an electric energy meter according to an embodiment of the present invention; Figure 8 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0028] At present, the electric energy meter needs to support the MODBUS protocol while supporting the DL / T645-2007 protocol. The check bit of each data in the DL / T645-2007 protocol is fixed to even check, while the check bit of each data in the MODBUS protocol can be set to odd check, even check or no check. Therefore, the communication formats of the DL / T645-2007 and MODBUS protocols are inconsistent.
[0029] Usually, the energy meter acts as a slave, and the master station needs to interact with the energy meter, and the check bits must be consistent for normal communication. The MCU in the energy meter has a built-in data transmission and reception (Universal Asynchronous Receiver / Transmitter, UART) function. The principle of UART receiving 1 byte of data is as follows: data is received on a single line with a width of 1 bit, and 1 byte of data is divided into 1 start bit (low level), 8 data bits, 0 / 1 check bits, and 1 stop bit (high level), which are received in sequence one bit at a time at the transition edge of the UART clock.
[0030] (1) 1-bit start bit: When idle, the level on the receive pin is high. The UART has its own clock. When the edge of the clock jumps from high level to low level, it is considered that the start bit is received.
[0031] (2) 8 data bits: At each clock transition edge, 8 data bits are received one bit at a time in sequence.
[0032] (3) 0 / 1 check bit: If both parties agree that there is no check bit, then jump directly to (4); if both parties agree that there is a parity check bit, receive 1 check bit when the clock edge jumps. Odd check means that in each frame of data, the number of 1s in all 9 bits, including data bits and parity check bits, must be an odd number. If the number of 1s in the 8-bit data bits is an odd number, then the check bit must be filled with 0. If the number of 1s in the 8-bit data bits is an even number, then the check bit must be filled with 1. Even check means that in each frame of data, the number of 1s in all 9 bits, including data bits and parity check bits, must be an even number. If the number of 1s in the 8-bit data bits is an odd number, then the check bit must be filled with 1. If the number of 1s in the 8-bit data bits is an even number, then the check bit must be filled with 0.
[0033] (4) 1 stop bit: The stop bit is fixed at a high level, and the 1 stop bit is received when the clock edge jumps. Then, when the high level changes to a low level, it is considered the start bit of the next byte and jumps to (1) again.
[0034] (5) Idle bits: Between bytes, there may be several bits of high-level idle bits, which are not processed by UART.
[0035] If the check bit is not set consistently, for example, the meter is set to no check, while the master is set to even check, then when receiving the stop bit, the check bit sent by the master will be received, and data reception will be misplaced; for example, if the meter is set to odd check, while the master is set to even check, then when receiving the check bit, the check bits of both parties will be inconsistent. Currently, the meter that supports these two communication protocols usually uses key switching or sending to switch the communication protocol. Only one communication protocol can be used to communicate with the meter at the same time. When you want to use another communication protocol, you need to switch manually. The two communication protocols are not adaptive, which is inconvenient to use.
[0036] Based on this, an embodiment of the present invention provides an embodiment of a protocol adaptation method for an electric energy meter. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0037] In this embodiment, a protocol adaptation method for an electric energy meter is provided, which can be used in an electric energy meter intelligent terminal, such as various types of processors, single-chip microcomputers, etc. Figure 1 As shown, the process includes the following steps: Step S101, receiving a data frame transmitted by a communication object based on a first communication protocol uniformly negotiated by both communicating parties, wherein, when communicating with the communication object, the check bit of the electric energy meter data transmission and reception is set to be consistent with the negotiated check method, and the check bit of the first communication protocol includes an even check and a preset check.
[0038] Specifically, the first communication protocol is a MODBUS protocol, and the MODBUS protocol includes even parity, no parity, and odd parity.
[0039] The communicating parties are the electric energy meter and the master station.
[0040] The MCU in the energy meter has a built-in UART function. The receiving pin of the UART has a data receiving function. The energy meter uses the first protocol agreed upon by both parties by default. The check bit of the UART is set to be consistent with the check bit of the first communication protocol. While mainly communicating with the first communication protocol, the second communication protocol can also be assisted. The UART is set to receive data in an interrupt mode. When a byte of data is received, the MCU will automatically generate an interrupt and jump to the interrupt execution location to process the received data.
[0041] Step S102, when the negotiated check mode is even check, the received data frame is parsed to determine the communication protocol corresponding to the data frame, and the received data frame is processed according to the corresponding communication protocol, wherein the corresponding communication protocol includes a first communication protocol and a second communication protocol, and the check bit of the second communication protocol is fixed to even check.
[0042] Specifically, the second communication protocol adopts the DL / T645-2007 protocol, and its check bit is fixed to an even check.
[0043] When both parties agree that the first communication protocol is even parity communication, UART is also set to even parity, because the second communication protocol is fixed to even parity, the communication formats of the two are consistent, data can be directly received, and data parsing can be performed after receiving a whole data frame. Because the contents of the MODBUS protocol and the DL / T645-2007 protocol are different, the method of parsing each byte can be used to identify which protocol the data frame belongs to. First parse according to the first communication protocol. If the whole data frame conforms to the first communication protocol, then process the data according to the first communication protocol. If the whole data frame does not conform to the first communication protocol, then parse the data according to the second communication protocol. If the whole data frame conforms to the second communication protocol, then process the data according to the second communication protocol.
[0044] Step S103, when the negotiated check method is the preset check, determine whether each byte in the received data frame complies with the preset check or whether it complies with the even check, and select the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with the preset check or complies with the even check.
[0045] Specifically, after determining whether each byte in the received data frame complies with the preset check or whether it complies with the even check, the received data frame is parsed to determine the communication protocol corresponding to the data frame. If each byte in the received data frame complies with the preset check and the corresponding communication protocol is the first communication protocol, the received data frame is processed through the first communication protocol. If each byte in the received data frame complies with the even check and the corresponding communication protocol is the second communication protocol, the received data frame is processed through the second communication protocol.
[0046] In one example, the preset parity includes no parity and odd parity.
[0047] When the first communication protocol and UART are set to odd parity, data parsing is performed after receiving a whole piece of data. If the parity bit of each byte of data is correct, data parsing is performed according to the first communication protocol. If the parity bit of each byte of data is wrong, data parsing is performed according to the second communication protocol.
[0048] When the first communication protocol and UART are set to no check, after receiving a byte of data, the interrupt automatically triggered by the MCU is used to immediately read and record the level of the current receiving pin at the interrupt. According to this method, after receiving a whole piece of data, it is parsed. If the level recorded at each interrupt is not all high level, it is parsed according to the second communication protocol, and after the data frame is parsed to conform to the format of the second communication protocol, the received data is processed by the second communication protocol. If the level recorded at each interrupt is all high level, it means that each byte conforms to no check, and it is parsed according to the first communication protocol, and after the data frame is parsed to conform to the format of the first communication protocol, the received data is processed by the first communication protocol.
[0049] A protocol adaptation method for an electric energy meter in an embodiment of the present invention sets the check bit of the electric energy meter data sent and received to be consistent with a negotiated check method when communicating with a communication object, receives a data frame transmitted by the communication object based on a first communication protocol uniformly negotiated by both communication parties, and when the negotiated check method is an even check, parses the received data frame to determine the communication protocol corresponding to the data frame, and processes the received data frame according to the corresponding communication protocol; when the negotiated check method is a preset check, determines whether each byte in the received data frame complies with the preset check or complies with the even check, and selects the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with the preset check or complies with the even check; even if the check methods of the first communication protocol and the second communication protocol are different, it is possible to communicate using the uniformly negotiated first communication protocol while also using the second communication protocol at the same time, without the need for manual switching, and is easy to use.
[0050] In some embodiments, the first communication protocol is the MODBUS protocol, and the second communication protocol is the DL / T645-2007 protocol. Correspondingly, in step S102, the received data frame is parsed to determine the communication protocol corresponding to the data frame, including: Step S1021, dividing the received data frame into an address field, a function code, data and a CRC check according to the MODBUS protocol, and determining in turn whether the address field, the function code and the CRC check are correct. If the address field, the function code and the CRC check are all correct, the communication protocol corresponding to the data frame is the MODBUS protocol; Step S1022, divide the received data frame into 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H according to the DL / T645-2007 protocol, and judge whether 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H are correct in turn. If 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H are all correct, the communication protocol corresponding to the data frame is the DL / T645-2007 protocol.
[0051] See also Figure 2 and Figure 3 , when both parties agree that the MODBUS protocol is even parity communication, the UART is also set to even parity, because the DL / T645-2007 protocol is fixed to even parity, the communication formats of the two are consistent, and data can be directly received. After receiving a whole data frame, data parsing can be performed. Because the contents of the MODBUS protocol and the DL / T645-2007 protocol are different, the method of parsing each byte can be used to identify which protocol the data frame belongs to. First parse according to the MODBUS protocol, the format of the MODBUS protocol is:
[0052] First determine whether the address code is correct, then determine whether the function code is correct. There are many types of function codes. According to each function code, determine whether the corresponding data is correct, and then determine whether the CRC check is correct. If the entire data frame conforms to the MODBUS protocol, then the data is processed according to the MODBUS protocol. If the entire data frame does not conform to the MODBUS protocol, then it is parsed according to the DL / T645-2007 protocol. The format of the DL / T645-2007 protocol is:
[0053] First determine whether the first 68H in the frame header is correct, then determine whether the 6-byte communication address A0A1A2A3A4A5 is correct, then determine whether the second 68H is correct, then determine whether the control code C is correct, then determine whether the data field length L of N1...Nm is correct, then determine whether the checksum CS is correct, and then determine whether the end mark 16H is correct. If the entire data frame conforms to the DL / T645-2007 protocol, then perform data processing according to the DL / T645-2007 protocol.
[0054] In this method, it is clarified that the first communication protocol is the MODBUS protocol and the second communication protocol is the DL / T645-2007 protocol. The MODBUS protocol is a widely used industrial communication protocol with high compatibility and reliability. Therefore, the electric energy meter can easily communicate with a variety of industrial automation equipment, improving the system's integration and practicality.
[0055] In some embodiments, optionally, the preset check includes odd check and no check; correspondingly, in step S103, when the negotiated check mode is the preset check, it is determined whether each byte in the received data frame complies with the preset check or whether each byte complies with the even check, and based on whether each byte in the received data frame complies with the preset check or each byte complies with the even check, a corresponding communication protocol is selected to perform data processing on the received data frame, including: Step S1031, when the negotiated check mode is odd check, determine whether each byte in the received data frame conforms to odd check or whether each byte conforms to even check, and select the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame conforms to odd check or even check.
[0056] There are two implementation schemes for determining whether each byte in the received data frame complies with odd parity or even parity, and one scheme includes the following steps: Step a1, after receiving any byte in the data frame, an interrupt is generated and jumps to the interrupt execution location, at which the check status bit of the currently received byte is read, and whether the currently received byte conforms to odd parity is determined by the check status bit, and the number of bytes that do not conform to odd parity in the received data frame is counted by the check bit error counter; Step a2, after receiving the data frame, if the value of the check bit error counter is equal to zero, each byte in the received data frame conforms to odd parity; if the value of the check bit error counter is equal to the number of bytes of the received data frame, each byte in the received data frame conforms to even parity.
[0057] This solution directly determines the verification mode through the verification status bit, which can quickly identify and handle transmission errors, thereby improving the efficiency and reliability of data transmission.
[0058] Another approach includes the following steps: Step b1, after receiving any byte in the data frame, an interrupt is generated and jumps to the interrupt execution location, at which the number of bits whose values are 1 among the 8 data bits and the parity check bit of the current received byte is calculated, and whether the current received byte conforms to odd parity is determined according to the number of bits whose values are 1 among the 8 data bits and the parity check bit of the current received byte, and the number of bytes that do not conform to odd parity in the received data frame is counted through a check bit error counter; Step b2, after receiving the data frame, if the value of the check bit error counter is equal to zero, each byte in the received data frame conforms to odd parity; if the value of the check bit error counter is equal to the number of bytes of the received data frame, each byte in the received data frame conforms to even parity.
[0059] In this method, the check mode is determined by using the 8 data bits of the current received byte and the number of bits with a value of 1 in the parity check bit. This method is applicable to the case where there is no check status bit, thus broadening the scope of application.
[0060] See also Figure 4 , take the first communication protocol as MODBUS protocol and the second communication protocol as DL / T645-2007 protocol as an example, when both parties agree that the MODBUS protocol is odd parity communication, UART is also set to odd parity, and can normally receive MODBUS protocol odd parity data, but DL / T645-2007 is fixed to even parity, and the parity bits of the two are just opposite. However, when UART is set to odd parity, it can receive even parity data, but there will be a check bit error prompt. Define a check bit error counter ERRCNT.
[0061] At present, there are two main ways to receive the UART check bit. The first one is to have a parity check status bit. When the parity check is incorrect, the check status bit will be automatically set to 1. When a byte of data is received, the energy meter MCU will automatically generate an interrupt and jump to the interrupt execution. The check status bit is read at the interrupt execution. If the check status bit is 1, it means that the odd check is incorrect, and the check bit error counter ERRCNT is increased by 1. The check status bit is manually cleared to 0. If the check status bit is 0, it means that the odd check is correct, and the check bit error counter ERRCNT is not increased by 1.
[0062] The second type is a reception bit with a check bit. The parity bit can be received normally, and the check bit can be read manually for verification. After receiving a byte, the number of 1s in the 8 data bits and parity bits of each byte is manually calculated at the interrupt execution point. If it is an even number, it means that the odd check is incorrect, and the check bit error counter ERRCNT increases by 1. If it is an odd number, it means that the odd check is correct, and the check bit error counter ERRCNT does not increase by 1.
[0063] After receiving a whole frame, if the check bit error counter ERRCNT is equal to 0, it means that the check bit of each byte of the whole frame meets the odd check. The MODBUS protocol is parsed according to the method in the above step S102. If the whole data meets the MODBUS protocol, the data is processed according to the MODBUS protocol.
[0064] If the check bit error counter ERRCNT is equal to the number of bytes in the entire frame, it means that the check bits of each byte of data are wrong and conform to even parity. Then, DL / T645-2007 protocol parsing is performed according to the method in the above step S102, and the entire data conforms to the DL / T645-2007 protocol, then data processing is performed according to the DL / T645-2007 protocol.
[0065] Step S1032, when the negotiated check mode is no check, determine whether each byte in the received data frame complies with no check or whether each byte complies with even check, and select the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with no check or even check.
[0066] The step of judging whether each byte in the received data frame complies with no check or even check includes: Step c1, after receiving 1 start bit, 8 data bits and 1 stop bit of any byte in the data frame, read the pin level, judge whether the current received byte meets the even parity check through the 8 data bits and the number of bits with the value of 1 in the pin level, and judge whether the pin level is a high level, and count the number of bytes meeting the even parity check and the number of bytes with the pin level being a high level in the received data frame through an even parity counter and a high level counter respectively; Step c2, after receiving the data frame, if the value of the high level counter is equal to the number of bytes of the received data frame, then each byte in the received data frame complies with no check; if the value of the even check counter is equal to the number of bytes of the received data frame, then each byte in the received data frame complies with even check.
[0067] See also Figure 5 and Figure 6, take the first communication protocol as MODBUS protocol and the second communication protocol as DL / T645-2007 protocol as an example, when both parties agree that the MODBUS protocol is non-check communication, UART is also set to non-check, and can normally receive non-check data, but DL / T645-2007 protocol is fixed to even check, and the check bits of the two are inconsistent. However, when UART is set to no check, it can receive data with even check, that is, it will treat the check bit as a stop bit, and some MCUs may have error prompts, which can be ignored, but because UART has no check bit at this time, it is necessary to manually capture the check bit and calculate whether it meets the even check.
[0068] After receiving the check bit, UART will treat the high-level stop bit as a high-level idle bit. Because the start bit starts from a high level to a low level, it does not affect the normal reception of the next byte. Define an even parity counter ECNT and a high-level counter HCNT. After receiving 1 start bit, 1 byte (8 bits) of data bits, and 1 stop bit, an interrupt will be generated immediately. The receiving pins of the UART of the energy meter MCU also have the function of a normal input port. When an interrupt is generated immediately, each bit level has a certain width and holding time. The level of the receiving pin (that is, the level of the bit that triggers the interrupt) continues to remain unchanged. Because it is unknown which protocol is currently being transmitted, the level of the bit may be a check bit or a stop bit. The method of immediately capturing and reading the level of the current receiving pin is used to determine whether the bit meets the even parity or is a high level. If the number of the bit and the 8-bit data bit 1 is an even number, which meets the even parity, the even parity counter ECNT is increased by 1. If the pin level is high, the high level counter HCNT is increased by 1. After receiving a whole piece of data, the data is parsed. If the high-level counter HCNT is equal to the number of bytes in the whole frame, it is considered that the bit of each byte is a stop bit, and the MODBUS protocol is parsed according to the method in step S102. If the whole piece of data conforms to the MODBUS protocol, the data is processed according to the MODBUS protocol. If the even parity counter ECNT is equal to the number of bytes in the whole frame, it is considered that the bit that triggers the interruption of each byte is an even parity bit, and the DL / T645-2007 protocol is parsed according to the method in step S102. If the whole piece of data conforms to the DL / T645-2007 protocol, the data is processed according to the DL / T645-2007 protocol.
[0069] By judging the verification mode through the 8-bit data bit, the number of bits with the value of 1 in the pin level, and whether the pin level is high, it is possible to accurately determine whether the verification mode is no verification or even verification, thereby providing a reference for subsequent processing.
[0070] The embodiment of the present invention processes the received data respectively according to the preset check as odd check and no check, allowing the electric energy meter to communicate with devices using different check methods, thereby enhancing the versatility and flexibility of the system.
[0071] In some embodiments, in step S103, after the received data frame is processed by the second communication protocol, the method further includes: The check bit of the electric energy meter data transmission and reception is set to even check, and data is replied to the communication object in the even check mode. After the reply is completed, the check bit of the electric energy meter data transmission and reception is restored to the preset check.
[0072] Specifically, if the preset check bit is odd check, when data needs to be replied, because the sender of the second communication protocol is fixed to even check, the check bit of UART is set to even check, and the data is replied according to even check. After the reply is completed, the check bit of UART is restored to odd check.
[0073] If the preset check bit is no check, when data needs to be replied, because the sender of the DL / T645-2007 protocol is fixed to even check, at this time, the check bit of UART is set to even check, and the data is replied according to even check. After the reply is completed, the check bit of UART is restored to no check.
[0074] In this manner, after processing the data through the second communication protocol, the check bit is set to even check for reply, and then the preset check is restored, thereby ensuring the accuracy of the reply data, maintaining the consistency of the communication protocol, and enhancing the stability of the communication.
[0075] The embodiment of the present invention also provides a protocol adaptive device for an electric energy meter, such as Figure 7 As shown, including: The data receiving module 701 is used to receive the data frame transmitted by the communication object based on the first communication protocol uniformly negotiated by the communication parties, wherein when communicating with the communication object, the check bit of the electric energy meter data transmission and reception is set to be consistent with the negotiated check method, and the check bit of the first communication protocol includes an even check and a preset check; An even parity processing module 702 is used to parse the received data frame to determine the communication protocol corresponding to the data frame when the negotiated parity mode is even parity, and perform data processing on the received data frame according to the corresponding communication protocol, wherein the corresponding communication protocol includes a first communication protocol and a second communication protocol, and the parity bit of the second communication protocol is fixed to even parity; The preset check processing module 703 is used to determine whether each byte in the received data frame complies with no check or whether each byte complies with even check when the negotiated check method is no check, and select the corresponding communication protocol to perform data processing on the received data frame based on whether each byte in the received data frame complies with no check or even check.
[0076] The protocol adaptive device of the electric energy meter in the embodiment of the present invention sets the check bit of the electric energy meter data transmission and reception to be consistent with the negotiated check method when communicating with the communication object, receives the data frame transmitted by the communication object based on the first communication protocol uniformly negotiated by the communication parties, and when the negotiated check method is even check, parses the received data frame to determine the communication protocol corresponding to the data frame, and processes the received data frame according to the corresponding communication protocol; when the negotiated check method is no check, determines whether each byte in the received data frame complies with no check or even check, and selects the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with no check or even check. Even if the check methods of the first communication protocol and the second communication protocol are different, it is possible to communicate using the uniformly negotiated first communication protocol while also using the second communication protocol at the same time, without the need for manual switching, and is easy to use.
[0077] Further, the preset check includes odd check and no check; correspondingly, the preset check processing module 703 includes: An odd parity processing module is used to determine whether each byte in the received data frame conforms to odd parity or even parity when the negotiated parity mode is odd parity, and select a corresponding communication protocol to perform data processing on the received data frame based on whether each byte in the received data frame conforms to odd parity or even parity; The no-check module is used to determine whether each byte in the received data frame complies with no-check or even-check when the negotiated check mode is no-check, and select the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with no-check or even-check.
[0078] Furthermore, the odd parity processing module includes: A first check bit error counting module is used to generate an interrupt and jump to the interrupt execution location after receiving any byte in the data frame, read the check status bit of the current received byte at the interrupt execution location, determine whether the current received byte conforms to odd check by the check status bit, and count the number of bytes that do not conform to odd check in the received data frame by the check bit error counter; The first odd parity check judgment module is used to, after receiving the data frame, if the value of the check bit error counter is equal to zero, then each byte in the received data frame complies with odd parity check; if the value of the check bit error counter is equal to the number of bytes of the received data frame, then each byte in the received data frame complies with even parity check.
[0079] Furthermore, the odd parity processing module includes: A second check bit error counting module is used to generate an interrupt and jump to the interrupt execution location after receiving any byte in the data frame, calculate the number of bits with a value of 1 among the 8 data bits and the parity check bit of the current received byte at the interrupt execution location, determine whether the current received byte conforms to odd check according to the number of bits with a value of 1 among the 8 data bits and the parity check bit of the current received byte, and count the number of bytes that do not conform to odd check in the received data frame through a check bit error counter; The second odd parity check judgment module is used to, after receiving the data frame, if the value of the check bit error counter is equal to zero, then each byte in the received data frame complies with odd parity check; if the value of the check bit error counter is equal to the number of bytes of the received data frame, then each byte in the received data frame complies with even parity check.
[0080] Furthermore, the no-check processing module includes: A high level and even parity counting module is used to read the pin level after receiving 1 start bit, 8 data bits and 1 stop bit of any byte in the data frame, judge whether the current received byte meets the even parity through the 8 data bits and the number of bits with the value of 1 in the pin level, and judge whether the pin level is a high level, and count the number of bytes meeting the even parity in the received data frame and the number of bytes with the pin level being a high level through the even parity counter and the high level counter respectively; The no-check judgment module is used to, after receiving the data frame, if the value of the high-level counter is equal to the number of bytes of the received data frame, then each byte in the received data frame complies with the no-check, and if the value of the even-check counter is equal to the number of bytes of the received data frame, then each byte in the received data frame complies with the even-check.
[0081] Furthermore, the protocol adaptive device of the electric energy meter also includes: The data reply module is used to set the check bit of the electric energy meter data transmission and reception to even check, reply data to the communication object in even check mode, and after the reply is completed, restore the check bit of the electric energy meter data transmission and reception to the preset check.
[0082] Further, the first communication protocol is the MODBUS protocol, and the second communication protocol is the DL / T645-2007 protocol; correspondingly, the even parity processing module includes: The MODBUS protocol parsing module is used to divide the received data frame into the address field, function code, data and CRC check according to the MODBUS protocol, and judge whether the address field, function code and CRC check are correct in turn. If the address field, function code and CRC check are all correct, the communication protocol corresponding to the data frame is the MODBUS protocol; The DL / T645-2007 protocol parsing module is used for dividing the received data frame into 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H according to the DL / T645-2007 protocol, and judging whether 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H are correct in turn. If 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H are all correct, the communication protocol corresponding to the data frame is the DL / T645-2007 protocol.
[0083] The embodiment of the present invention also provides a schematic diagram of the structure of a computer device, such as Figure 8 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 8 A processor 10 is taken as an example.
[0084] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0085] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0086] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0087] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0088] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0089] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device may be a touch screen.
[0090] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0091] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0092] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the accompanying drawings.
Claims
1. A protocol adaptation method for an electric energy meter, characterized in that: include: Receiving a data frame transmitted by a communication object based on a first communication protocol uniformly negotiated by both parties, wherein, when communicating with the communication object, a check bit of the electric energy meter data transmission and reception is set to be consistent with the negotiated check method, and the check bit of the first communication protocol includes an even check and a preset check; When the negotiated check mode is even check, parsing the received data frame to determine the communication protocol corresponding to the data frame, and performing data processing on the received data frame according to the corresponding communication protocol, wherein the corresponding communication protocol includes the first communication protocol and the second communication protocol, and the check bit of the second communication protocol is fixed to even check; When the negotiated check method is the preset check, determine whether each byte in the received data frame complies with the preset check or whether it complies with the even check, and select the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with the preset check or complies with the even check.
2. The protocol self-adaptation method of electric energy meter according to claim 1, characterized in that: The preset check includes odd check and no check; Correspondingly, when the negotiated check mode is the preset check, it is determined whether each byte in the received data frame complies with the preset check or whether each byte complies with the even check, and based on whether each byte in the received data frame complies with the preset check or complies with the even check, a corresponding communication protocol is selected to perform data processing on the received data frame, including: When the negotiated check mode is odd check, determine whether each byte in the received data frame complies with odd check or even check, and select a corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with odd check or even check; When the negotiated check mode is no check, determine whether each byte in the received data frame complies with no check or whether it complies with even check, and select the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with no check or even check.
3. The protocol self-adaptation method of electric energy meter according to claim 2, characterized in that: Determine whether each byte in the received data frame conforms to odd parity or even parity, including: After receiving any byte in the data frame, an interrupt is generated and jumps to the interrupt execution location, at which the check status bit of the currently received byte is read, whether the currently received byte conforms to odd parity is determined by the check status bit, and the number of bytes that do not conform to odd parity in the received data frame is counted by a check bit error counter; After receiving the data frame, if the value of the check bit error counter is equal to zero, each byte in the received data frame conforms to odd parity; if the value of the check bit error counter is equal to the number of bytes of the received data frame, each byte in the received data frame conforms to even parity.
4. The protocol self-adaptation method of electric energy meter according to claim 2, characterized in that: Determine whether each byte in the received data frame conforms to odd parity or even parity, including: After receiving any byte in the data frame, an interrupt is generated and jumps to the interrupt execution location, where the number of bits with a value of 1 among the 8 data bits and the parity check bit of the current received byte is calculated, and whether the current received byte meets the odd check is determined according to the number of bits with a value of 1 among the 8 data bits and the parity check bit of the current received byte, and the number of bytes that do not meet the odd check in the received data frame is counted through the check bit error counter; After receiving the data frame, if the value of the check bit error counter is equal to zero, each byte in the received data frame conforms to odd parity; if the value of the check bit error counter is equal to the number of bytes of the received data frame, each byte in the received data frame conforms to even parity.
5. The protocol self-adaptation method of electric energy meter according to claim 2, characterized in that: Determine whether each byte in the received data frame complies with no parity or even parity, including: After receiving 1 start bit, 8 data bits and 1 stop bit of any byte in the data frame, read the pin level, judge whether the current received byte meets the even parity check through the 8 data bits and the number of bits with the value of 1 in the pin level, and judge whether the pin level is a high level, and count the number of bytes meeting the even parity check in the received data frame and the number of bytes with the pin level being a high level through the even parity counter and the high level counter respectively; After receiving the data frame, if the value of the high level counter is equal to the number of bytes of the received data frame, each byte in the received data frame complies with no check; if the value of the even check counter is equal to the number of bytes of the received data frame, each byte in the received data frame complies with even check.
6. The protocol self-adaptation method of electric energy meter according to claim 1, characterized in that: After performing data processing on the received data frame by using the second communication protocol, the method further includes: The check bit of the electric energy meter data transmission and reception is set to even check, and data is replied to the communication object in the even check mode. After the reply is completed, the check bit of the electric energy meter data transmission and reception is restored to the preset check.
7. The protocol self-adaptation method of electric energy meter according to claim 1, characterized in that: The first communication protocol is the MODBUS protocol, and the second communication protocol is the DL / T645-2007 protocol; Correspondingly, parsing the received data frame to determine the communication protocol corresponding to the data frame includes: According to the MODBUS protocol, the received data frame is divided into the address field, function code, data and CRC check, and the address field, function code and CRC check are judged in turn whether they are correct. If the address field, function code and CRC check are all correct, the communication protocol corresponding to the data frame is the MODBUS protocol; According to the DL / T645-2007 protocol, the received data frame is divided into 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H, and whether 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H are correct are judged in turn. If 68H, A0, A1, A2, A3, A4, A5, 68H, C, L, N1, N2, ..., Nm, CS and 16H are all correct, the communication protocol corresponding to the data frame is the DL / T645-2007 protocol.
8. A protocol adaptive device for an electric energy meter, characterized in that: include: A data receiving module, used for receiving a data frame transmitted by a communication object based on a first communication protocol uniformly negotiated by both communication parties, wherein when communicating with the communication object, a check bit of the electric energy meter data transmission and reception is set to be consistent with the negotiated check method, and the check bit of the first communication protocol includes an even check and a preset check; an even parity processing module, configured to parse a received data frame to determine a communication protocol corresponding to the data frame when the negotiated parity mode is even parity, and perform data processing on the received data frame according to the corresponding communication protocol, wherein the corresponding communication protocol includes the first communication protocol and the second communication protocol, and the parity bit of the second communication protocol is fixed to even parity; The preset check processing module is used to determine whether each byte in the received data frame complies with the preset check or whether it complies with the even check when the negotiated check method is the preset check, and select the corresponding communication protocol to process the received data frame based on whether each byte in the received data frame complies with the preset check or complies with the even check.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the protocol adaptation method of the electric energy meter according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the protocol adaptation method for an electric energy meter according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method, apparatus and device for adjusting Baud rate and frame format of slave station
CN107147553A
Data acquisition control workstation and data transmission method thereof
CN110442096A
Asynchronous serial port communication protocol which is compatible with Modbus and is more efficient
CN111124986A
RS485-based hybrid communication method, data acquisition unit and system
CN115905089A
Messaging protocol for use in a telecommunications network
EP0837613A2
