A communication method and device, system and medium applied to an energy terminal

By employing a broad-spectrum search method in the drive module of the energy terminal, new devices are automatically identified and communication is established with the EMS module, solving the problem of poor adaptability of traditional EMS and realizing plug-and-play and efficient access for new devices.

CN121887750BActive Publication Date: 2026-06-19SHIJIAZHUANG KE ELECTRIC
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHIJIAZHUANG KE ELECTRIC
Filing Date
2026-03-20
Publication Date
2026-06-19

Smart Images

  • Figure CN121887750B_ABST
    Figure CN121887750B_ABST
Patent Text Reader

Abstract

This application provides a communication method, apparatus, system, and medium for energy terminals, belonging to the field of communication. The method includes: responding to a received connection request from a target device; calculating the instruction sending order of various probe instructions in an instruction library based on the connection request; and sequentially sending probe instructions to the target device according to the instruction sending order; stopping transmission upon receiving a response frame from the target device and performing anomaly detection on the response frame; and, if the anomaly detection result of the response frame is normal, sending a registration instruction to the EMS module based on the response frame to enable communication between the target device and the EMS module. The communication method, apparatus, system, and medium provided in this application for energy terminals can automatically identify newly added devices through a broad-spectrum probe method without modifying other functions of the EMS.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of communication technology, and more specifically, relates to a communication method, device, system, and medium applied to energy terminals. Background Technology

[0002] Traditional energy management systems (EMS) have poor adaptability. When a new device is connected, most of the time it is necessary to modify the EMS program and add relevant communication protocol encoding and decoding functions in order to communicate and interact with the new device and make the new device work properly. In some cases, the modification process may even affect other functions. Summary of the Invention

[0003] This application provides a communication method, device, system, and medium for energy terminals, which can automatically identify newly added devices through a broad-spectrum detection method without modifying other functions of the EMS, thus solving the problem of needing to modify the EMS program when connecting new devices.

[0004] To achieve the above objectives, the technical solutions provided in this application are as follows:

[0005] Firstly, a communication method for use in an energy terminal is provided. The energy terminal includes an EMS module and a drive module connected in communication. The communication method is applied to the drive module and includes:

[0006] In response to receiving a connection request from the target device, the system calculates the command sending order of each probe command in the command library based on the connection request, and sends the probe commands to the target device in sequence according to the command sending order;

[0007] Upon receiving a response frame from the target device, stop sending probe commands and perform anomaly detection on the response frame;

[0008] When the anomaly detection result of the response frame is determined to be normal, a registration command is sent to the EMS module based on the response frame so that the target device can establish communication with the EMS module.

[0009] Secondly, a communication device for use in an energy terminal is provided. The energy terminal includes an EMS module and a drive module connected in communication. The communication device is applied to the drive module and includes:

[0010] The instruction sending module is used to respond to the received connection request from the target device, calculate the instruction sending order of each exploration instruction in the instruction library based on the connection request, and send the exploration instructions to the target device in sequence according to the instruction sending order;

[0011] The anomaly detection module is used to stop sending probe commands when a response frame is received from the target device, and to perform anomaly detection on the response frame.

[0012] The registration communication module is used to send a registration command to the EMS module based on the response frame when the anomaly detection result of the response frame is normal, so that the target device can establish communication with the EMS module.

[0013] Thirdly, embodiments of this application also provide an energy system, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the communication method for an energy terminal provided by any possible implementation of the first aspect.

[0014] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the communication method for an energy terminal provided by any possible implementation of the first aspect.

[0015] The beneficial effects of the technical solution provided in this application are as follows:

[0016] The communication method, apparatus, system, and medium for energy terminals provided in this application embodiment, compared with related technologies, are executed by the driver module in an energy terminal architecture that includes a communication connection EMS module and a driver module. First, in response to a connection request from a target device, the driver calculates the instruction sending order of each probe instruction in the instruction library based on the request and sends probe instructions to the target device sequentially in this order. Second, upon receiving a response frame from the target device, the driver stops sending probe instructions and performs anomaly detection on the response frame. Finally, if the anomaly detection result of the response frame is determined to be normal, a registration instruction is sent to the EMS module based on the response frame, enabling the target device to establish communication with the EMS module. This allows for automatic identification of newly added devices through a broad-spectrum probe method without modifying other EMS functions. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.

[0018] Figure 1 A flowchart illustrating a communication method applied to an energy terminal, provided in an embodiment of this application;

[0019] Figure 2 A system architecture diagram of an energy terminal provided in an embodiment of this application;

[0020] Figure 3 A structural block diagram of a communication device applied to an energy terminal provided in an embodiment of this application;

[0021] Figure 4 A schematic block diagram of an energy system provided in an embodiment of this application. Detailed Implementation

[0022] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.

[0023] Those skilled in the art will understand that, unless otherwise stated, the singular forms “a,” “an,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.” When describing multiple (two or more) items, if the relationship between the multiple items is not explicitly defined, the multiple items can refer to one, several or all of the multiple items. For example, the description of "parameter A includes A1, A2, A3" can be implemented as parameter A includes A1 or A2 or A3, or it can be implemented as parameter A includes at least two of the three items A1, A2 and A3.

[0024] Traditional EMS systems have poor adaptability. Each time a new device is connected, the EMS program needs to be modified and related communication protocol encoding / decoding functions added for it to function properly. This modification process can even affect other functions. It cannot achieve modularity or plug-and-play functionality.

[0025] To address the aforementioned technical issues, this application provides a communication method for energy terminals. In this application embodiment, the EMS module in the energy terminal adopts a unified standard interface. When a new device is added, the driver module can automatically identify the newly added device through a broad-spectrum search method, without modifying other functions of the EMS module, especially the core code, to enable the access of the new device.

[0026] To make the objectives, technical solutions, and advantages of this application clearer, the following description will be provided in conjunction with the accompanying drawings and specific embodiments.

[0027] This application provides a communication method for an energy terminal, which includes an EMS module and a drive module connected by communication. The communication method is primarily applied to the drive module, such as... Figure 1 As shown, the method may include S101 to S103.

[0028] S101, in response to receiving a connection request from the target device, calculates the instruction sending order of each exploration instruction in the instruction library based on the connection request, and sends the exploration instructions to the target device in sequence according to the instruction sending order.

[0029] In the embodiments of this application, the target device is a new device that has not established a communication connection with the EMS module, which may be a power conversion system (PCS) device, a battery management system (BMS) device, or other intelligent electrical devices.

[0030] In this embodiment, the driver module has a built-in driver program that can be integrated into an application (APP) as an intelligent module that communicates with external intelligent electrical devices and EMS modules.

[0031] When the target device needs to connect to the EMS module for energy management, it can send a connection request to the drive module. The connection request can be sent through different communication interfaces, and the connection request can include the device information of the target device and the interface information of the connection communication interface.

[0032] After receiving a connection request from a target device, the driver module can roughly determine the type of device (BMS device, PCS device, or other intelligent electrical device) based on the connection request. Then, it can sort the various probe commands in the command library according to the device type, prioritizing matching probe commands that can be responded to, reducing matching time, and thus determining the command sending order. These probe commands can be broad-spectrum probe commands. Broad-spectrum probe commands are a type of general-purpose command sent by the driver to the target device to detect and identify the target device's communication protocol and capabilities. They are not customized for a specific device or protocol but have broad compatibility and can adapt to various types of energy terminal devices (such as BMS devices, PCS devices, and other intelligent electrical devices).

[0033] After obtaining the command transmission order, the driver module can send each probe command to the target device sequentially according to the transmission order, and check whether a corresponding response frame is received after each transmission. If no response frame is received, it indicates that the target device does not match the currently sent probe command, and the remaining probe commands can continue to be sent sequentially. If a response frame is received, it indicates that the target device matches the currently sent probe command, and the transmission of the remaining probe commands can be stopped.

[0034] In the embodiments of this application, the instruction library may include a certain number of general probe instructions of different types. If no response frame is received after all probe instructions in the instruction library have been sent, an alarm indicating that the device protocol is not covered is triggered, and instruction library optimization is performed subsequently. Simultaneously, access to the target device can be stopped, and manual access can be initiated.

[0035] For example, the command library can include 50 search commands. If there is still no response after sending all 50 commands, a "Device protocol not covered" alarm is triggered, which does not affect the adaptation of other devices. The original text of the abnormal response frame, error code, adjustment strategy, and execution result are recorded to provide data support for subsequent command pool optimization.

[0036] For example, the instruction library can be built into the driver module and can include 50 exploration instructions that reside in the private protocol. Each instruction specifies the exact byte values ​​of the frame header, instruction code, data segment, check segment, and frame tail.

[0037] For example, probe command 1 (read voltage and current) is 0xAA 0x55 0x01 0x00 0x00 0x02 0x800xBB, where the frame header is 0xAA 0x55, the command code is 0x01, the data segment is 0x00 0x00 0x02, the checksum is 0x80, and the frame trailer is 0xBB. The checksum of all probe commands is pre-calculated according to the corresponding protocol checksum rules to ensure that the command format is compliant.

[0038] S102, upon receiving a response frame from the target device, stop sending the probe command and perform anomaly detection on the response frame.

[0039] When the target device receives a matching probe command, it can generate a response frame corresponding to the probe command and send it to the driver module to indicate that a connection can be established. The driver module stops sending probe commands upon receiving the response frame from the target device. Simultaneously, after receiving the response frame, the driver module can perform anomaly detection on the response frame to determine its validity.

[0040] The driver module can cache the response frame and the corresponding probe command, with a cache of ≥10 frames to ensure data integrity.

[0041] For example, the anomaly detection process can be as follows:

[0042] The corresponding cached response frames (single frame example: 0xCC 0xDD 0x03 0x01 0x02 0x05 0x12 0x34 0x21 0xFF) are filtered to remove invalid response frames.

[0043] The filtering rules are as follows:

[0044] Frame length verification: Only frames with a length of 8-32 bytes (the normal frame length range of the native protocol of energy storage devices) are retained. In the example, all 10 frames are 10 bytes, which meets the requirements.

[0045] Frame header and frame tail verification: Only frames with a frame header of 0xCC 0xDD and a frame tail of 0xFF are retained.

[0046] For pseudo-valid response frames caused by electromagnetic interference in energy storage power stations, which are "valid at the beginning and end but abnormal in the data", an anomaly detection model using 1D-CNN (Convolutional Neural Network) + LSTM (Long Short-Term Memory) specifically designed for energy storage data can be used for anomaly detection.

[0047] S103, when the anomaly detection result of the response frame is determined to be normal, a registration command is sent to the EMS module based on the response frame so that the target device establishes communication with the EMS module.

[0048] When the driver module determines that the anomaly detection result of the response frame is normal, it can perform byte-level parsing of the response frame to obtain multiple frame structures. Finally, it matches these frame structures to determine the communication protocol format of the target device. Based on the matched communication protocol format, the multiple frame structures are then encapsulated into a JSON format, including the device identifier, timestamp, standard data, and conversion verification results, thereby generating a registration command. The driver program can then send the registration command to the EMS module, enabling the target device to connect to the EMS module and establish communication.

[0049] In this embodiment, the energy terminal includes an EMS module and a driver module for communication connection, and the process is executed by the driver module. First, in response to a connection request from the target device, the driver calculates the command sending order of each probe command in the command library based on the request and sends the probe commands to the target device sequentially in this order. Second, upon receiving a response frame from the target device, the driver stops sending probe commands and performs anomaly detection on the response frame. Finally, if the anomaly detection result of the response frame is determined to be normal, a registration command is sent to the EMS module based on the response frame, enabling the target device to establish communication with the EMS module. This allows for automatic identification of newly added devices through a broad-spectrum probe method without requiring modification of other EMS functions.

[0050] In some embodiments of this application, the instruction sending order of each probe instruction in the connection request calculation instruction library is included, including:

[0051] For each exploration command in the command library, feature extraction is performed on the exploration command to obtain multiple exploration frame features of the exploration command;

[0052] The weights of each probe frame feature are determined based on the connection request;

[0053] The matching degree of the search command is obtained by weighting the features of each search frame based on their respective weights.

[0054] The order in which commands are sent is determined by the matching degree from highest to lowest.

[0055] In some embodiments of this application, multiple probe frame features include energy storage function identification features, frame length features, and check segment location features.

[0056] In some embodiments of this application, the matching degree of the search command is obtained by weighting the features of each search frame based on their respective weights, including:

[0057] The matching degree of the search command is calculated based on the first calculation formula;

[0058] The first calculation formula is:

[0059] P = a × A + b × B + c × C

[0060] Where P is the matching degree of the search command, A is the matching score of the energy storage function identification feature, B is the matching score of the frame length feature, C is the matching score of the check segment position feature, a is the weight of the energy storage function identification feature, b is the weight of the frame length feature, and c is the weight of the check segment position feature. a+b+c=1.

[0061] The weights a, b, and c can be configured and adaptively adjusted according to the application scenario.

[0062] For example, the weight 'a' of the energy storage function identification feature can be adjusted according to the equipment type. If the equipment type is clear, the weight 'a' of the energy storage function identification feature can be set higher to prioritize matching search commands related to the core functions of the equipment. If the equipment type is ambiguous or unclear, the weight 'a' of the energy storage function identification feature can be set lower to reduce the impact of uncertainty.

[0063] The weight 'b' of the frame length feature can be adjusted based on the interface information. For high-speed interfaces, the weight 'b' can be appropriately reduced, resulting in high data transmission stability and potentially smaller frame length fluctuations. For low-speed interfaces, the weight 'b' can be appropriately increased to filter out invalid commands with abnormally long frames.

[0064] The weight c of the check segment position feature can be adjusted according to the fluctuation of the check segment position. If the check segment position fluctuates greatly, the weight c of the check segment position feature can be appropriately increased to strengthen the requirement for check segment position matching. If the check segment position is fixed or fluctuates little, the weight c of the check segment position feature can be appropriately decreased to reduce the cost of redundant verification.

[0065] Specifically, in the embodiments of this application, the calculation process for the matching score of energy storage function identification features can be as follows:

[0066] Extract the function identifier field information (i.e., function identifier features) from the response frame, calculate its proportion in the instruction library, and use it as the matching score:

[0067] A = Number of matching fields / Number of all energy storage function fields in the instruction library

[0068] The calculation process for the matching score of frame length features can be as follows:

[0069] Extract the actual frame length of the response frame from the response frame, compare it with the corresponding standard frame length range in the instruction library, and calculate the matching score:

[0070] B = max(0, 100 - |actual frame length - standard frame length| / standard frame length)

[0071] The matching score calculation process for the location features of the verification segment is as follows:

[0072] Locate the starting offset position of the check segment in the response frame, compare it with the preset check segment position offset in the instruction library, and calculate the matching score:

[0073] C = max(0, 100 - |actual offset - preset offset| / preset offset)

[0074] After obtaining the matching scores A, B, and C, the corresponding data can be substituted into the first calculation formula to calculate the matching degree of the search command.

[0075] For example, the instruction library may include 50 search instructions. Three types of energy storage-specific features can be extracted from each search instruction: energy storage function identification features, frame length features, and check segment location features. Then, the matching degree of the search instructions can be calculated.

[0076] For example, the first calculation formula can be:

[0077] P = 0.4 × A + 0.3 × B + 0.3 × C

[0078] The commands are sorted from highest to lowest matching degree to obtain the command sending order. Exploration commands are then sent in this order, prioritizing commands that better match the protocol characteristics of the energy storage device (e.g., "read voltage" commands take precedence over "read temperature" commands).

[0079] This application's embodiments optimize the order of command delivery through multi-dimensional feature extraction and weighted calculation, resulting in greater efficiency and accuracy. First, based on three types of features—energy storage function identifier, frame length, and checksum position—the matching degree is accurately calculated using a first calculation formula that dynamically allocates weights for connection requests. Second, commands are sent in order of matching degree, prioritizing core commands such as "read voltage," significantly improving device identification efficiency and reducing invalid communication. Finally, a dynamic weight adjustment mechanism ensures rapid adaptation to new devices, avoiding the drawbacks of frequent program modifications in traditional EMS systems, and providing energy terminals with an efficient and flexible device access solution.

[0080] In some embodiments of this application, the probe commands are sent to the target device sequentially according to the command sending order, including: sending probe commands to the target device sequentially at preset time intervals according to the command sending order; wherein the preset time interval is calculated and determined based on the interface information in the connection request and the device information of the target device.

[0081] The embodiments of this application can calculate the preset duration according to the second calculation formula.

[0082] The second calculation formula is: T = V × k × m, where T represents the preset duration, V represents the standard waiting time, k represents the interface coefficient, and m represents the device coefficient. The interface coefficient can be determined based on the interface information, and the device coefficient can be determined based on the device information.

[0083] In the embodiments of this application, the interface information includes parameters such as the communication interface type, transmission rate, and physical layer protocol carried in the connection request, such as CAN interface and Ethernet interface. The interface coefficient k ≥ 1, and the faster the response speed, the smaller the value. For example, for a high-speed Ethernet interface, the interface coefficient k = 1, and for a medium-speed CAN interface, the interface coefficient k = 1.2.

[0084] Device information includes data such as the target device's type, response capability, and historical communication latency, for example, BMS devices, PCS devices, etc. The device coefficient m ≥ 1; the faster the response speed, the smaller the value. For example, a fast-responding BMS device has a device coefficient m = 1, while a PCS device with a moderate response speed has a device coefficient m = 1.2.

[0085] For example, the second calculation formula can be: T=500ms×k×m, where if the target device is connected to the driver module via an RS485 interface, then k=1.5, and if the target device is a lead-acid device, then m=1.8.

[0086] According to the second calculation formula T=500×1.5×1.8=1350ms, if no response frame is received, the next probe command can be sent every 1350ms. By dynamically adjusting the sending interval, the adaptation failure caused by response delay can be avoided.

[0087] This application's embodiments improve device access reliability by dynamically calculating the probe command transmission interval. The dynamic adjustment mechanism balances communication efficiency and device compatibility, solving the problem of easily lost response frames in traditional fixed-interval transmission, and providing a precise timing control scheme for energy terminal device access.

[0088] In some embodiments of this application, anomaly detection of the response frame includes: inputting the response frame into a pre-built anomaly detection model to obtain anomaly probability; performing anomaly detection on the response frame according to the anomaly probability; wherein, the anomaly detection model includes a first anomaly verification layer and a second anomaly verification layer, the first anomaly verification layer is used to perform anomaly verification on the format of the response frame, and the second anomaly verification layer is used to perform anomaly verification on the timing rationality of the response frame.

[0089] In the embodiments of this application, if the abnormal probability is greater than or equal to a preset threshold, it is determined to be an abnormal response frame and filtered. If the abnormal probability is less than the preset threshold, it is determined to be a normal response frame and retained.

[0090] In some embodiments of this application, the anomaly detection model can be a 1D-CNN+LSTM anomaly detection model, which can mainly detect pseudo-valid frames caused by electromagnetic interference in energy storage power stations, where the frame header and tail are valid but the data is abnormal.

[0091] Specifically, the detection process is as follows:

[0092] (1) Feature extraction

[0093] Feature extraction is performed on each response frame, extracting 5 types of energy storage-specific features to generate a 10-dimensional feature vector (5 types of energy storage features are extracted from "two adjacent frames of data", and then merged to form a 10-dimensional vector).

[0094] This application embodiment takes into account that the operating data (such as voltage and current) of energy storage devices are continuously and gradually changing. By comparing the features of two adjacent frames, it can more accurately identify anomalies where "a single frame looks legal but contradicts the logic of the previous frame" (for example, the voltage in the previous frame is 3V, and the current frame suddenly becomes 10V. Although the value of a single frame is within the range, the fluctuation of adjacent frames is abnormal, which is a typical interference frame in the energy storage scenario).

[0095] ① Frame length fluctuation rate ΔL = |Ln - L(n-1)| (Ln is the length of the nth frame, L(n-1) is the length of the (n-1)th frame, and ΔL ≤ 2 for energy storage devices).

[0096] ② Reasonable fluctuation range Cr: The value parsed from the response frame data segment, if it belongs to the reasonable fluctuation range of the corresponding parameter of the energy storage device (such as the single unit voltage ∈ [2V, 5V]), then Cr=1, otherwise Cr=0.

[0097] ③ Verification segment correlation Cc: If the verification value matches the XOR result of the data segment, Cc=1; otherwise, Cc=0.

[0098] ④ Function code stability Cf: If the function codes of consecutive frames are consistent, Cf=1; otherwise, Cf=0.

[0099] ⑤ Timestamp continuity Ct: If the timestamp is incrementing, Ct=1; otherwise, Ct=0.

[0100] (2) 1D-CNN+LSTM structure

[0101] ① First anomaly detection layer – 1D-CNN layer (3 kernels, 16 channels):

[0102] Extract local energy storage features (such as function codes and fixed patterns of numerical segments) within a single frame.

[0103] Since the response frame of the energy storage device is a one-dimensional byte stream (not two-dimensional data), 1D-CNN is adopted. The convolution kernel = 3 corresponds to the fixed local structure of the energy storage frame "frame header (2 bytes) + instruction code (1 byte)", and the number of channels = 16 covers the core local features of the energy storage protocol (such as frame header and instruction code mode) to realize the single frame format legality detection.

[0104] ② Second anomaly detection layer – LSTM layer (hidden layer dimension = 32, time step = 10):

[0105] Capture the temporal correlation of 10 frames of data (such as the gradual trend of energy storage voltage).

[0106] Because the operating data of energy storage devices exhibits continuous and gradual changes, it is necessary to capture the temporal correlation of multiple frames. A time step of 10 corresponds to 10 cached samples, and a hidden layer dimension of 32 adapts to the complexity of changes in energy storage data, enabling the detection of the rationality of trends in multi-frame data.

[0107] ③ Output layer: Output the abnormal probability value (0-1) of the response frame.

[0108] (3) Anomaly detection

[0109] Set a preset threshold G=0.95. If the abnormal probability value is ≥0.95, it is judged as an abnormal frame and filtered. If the proportion of abnormal frames (abnormal rate) is >10% in N consecutive abnormal detections (e.g., N=10), "instruction similarity reordering" is automatically triggered to rematch the device protocol.

[0110] The embodiments of this application achieve high-precision anomaly recognition through a 1D-CNN+LSTM model, which significantly improves the communication reliability of energy storage terminals and effectively solves the problem of pseudo-valid frames caused by electromagnetic interference, providing highly robust communication guarantees for energy terminals.

[0111] In some embodiments of this application, sending a registration instruction to the EMS module based on a response frame includes: parsing the response frame to obtain multiple frame structures of the response frame; generating a communication protocol format for the target device based on the multiple frame structures; generating a registration instruction based on the communication protocol format and sending the registration instruction to the EMS module; wherein, generating a communication protocol format for the target device based on multiple frame structures includes: matching the verification rules corresponding to each frame structure; verifying each frame structure based on the verification rules corresponding to each frame structure, and generating a communication protocol format for the target device based on the verification results.

[0112] Specifically, the parsing process can be as follows:

[0113] Frame header identification: Analyze the starting byte of the 10 response frames. They are all 0xCC 0xDD (byte bits 0-1), which is determined to be the frame header. The fixed value is 0xCC 0xDD.

[0114] Command code identification: The second byte (byte bit 2) is 0x03 in all 10 frames of data, and it is consistent with the command code field in the interrogation command that triggers the response. It is determined to be a command code, which means "read core parameters response".

[0115] Data and checksum segment division: The total frame length is 10 bytes, with a 2-byte frame header, a 1-byte instruction code, and a 1-byte frame trailer = 4 bytes. The remaining 6 bytes (bytes 3-8) are the data and checksum segments. Bytes 3-4 (0x01, 0x02) are fixed throughout the 10 frames and are identified as the parameter identifier segment; bytes 5-7 (0x05, 0x12, 0x34) fluctuate dynamically and are identified as the numeric field; byte 8 (0x21) changes with the numeric field and is identified as the checksum segment. The final frame structure parsing table in Table 1 is obtained.

[0116]

[0117] After obtaining multiple frame structures, precise matching can be performed according to the verification rules. The specific process is as follows:

[0118] Extract the check segment and the field to be checked: The check segment is byte 8 (0x21), and the field to be checked is byte 2-7 (instruction code + parameter identifier + numerical field), and the byte stream is 0x03 0x01 0x02 0x05 0x12 0x34.

[0119] Rule-by-rule matching calculation:

[0120] XOR check:

[0121] 0x03^0x01=0x02→0x02^0x02=0x00→0x00^0x05=0x05→0x05^0x12=0x17→0x17^0x34=0x23, which does not match the check segment 0x21, so it fails.

[0122] The summation and remainder check is performed as follows: 0x03 + 0x01 + 0x02 + 0x05 + 0x12 + 0x34 = 0x51. The remainder is taken from 0x100 (i.e., decimal 256) to ensure that the result is a byte (8 bits). The remainder result is 0x51, which does not match the check segment 0x21, so the check fails.

[0123] CRC16-Modbus checksum (low byte): polynomial 0x8005, initial value 0xFFFF, data bit order "highest bit first", result XOR 0x0000, calculation result is 0x21 0x26, low byte 0x21 completely matches the check segment, match successful.

[0124] Output result: The lock check rule is "CRC16-Modbus (take low byte)", and the calculation parameters are explicitly defined.

[0125] After determining the verification rules, the data can be encapsulated into JSON format according to the EMS preset standard, including device identifier, timestamp, standard data, and conversion verification results. Finally, the driver module registers the newly connected target device with the EMS module.

[0126] The registration instruction generation method in this application achieves efficient communication and interoperability between the target device and the EMS module through structured parsing and verification rule matching. This enables plug-and-play functionality for new devices, avoiding the drawbacks of manual coding required for protocol adaptation in traditional EMS systems, and improving the automation and compatibility of energy terminal device access.

[0127] In some embodiments of this application, the energy terminal includes an EMS module and a driver module. The energy terminal adopts a three-layer partitioning mechanism of "physical interface + time slice scheduling + device physical identifier" to achieve parallel adaptation of multiple devices, as detailed below:

[0128] (1) Dynamic time-slice partitioning (based on energy storage bus characteristics):

[0129] For the same hardware interface (such as RS485), calculate the minimum time slice for single-device adaptation based on the bus baud rate (such as 9600bps) and the number of connected devices N:

[0130] Ts = 1000ms / (N+2)

[0131] (Example: RS485 interface connects 3 devices, Ts=1000 / 5=200ms; 2 time slices are reserved for bus conflict avoidance).

[0132] (2) Equipment physical identifier binding:

[0133] Assign a physical identifier of "interface + port" to each device under the same interface (e.g., device ID of port 1 of RS485 interface = 485_001), record the physical location of the device access, and associate it with the corresponding time slice (e.g., 485_001 corresponds to time slice 1).

[0134] (3) Time-slice parallel delivery:

[0135] The driver polls on a time-slice basis, only sending polling commands to the physical identifier device corresponding to the current time slice; other devices are in a receive standby state to avoid bus conflicts.

[0136] (Example: Time slice 1 sends an instruction to 485_001, time slice 2 sends an instruction to 485_002, and so on.)

[0137] (4) The response frame is associated with the device ID:

[0138] When capturing a response frame, the device features hidden within the frame (such as subtle differences in parameter identifiers) are extracted, bound to the physical identifier ID, and the response frame is assigned to the parsing queue of the corresponding device to avoid response confusion.

[0139] (5) Parallel parsing across multiple devices:

[0140] Start N independent parsing threads to process the response frames of each device, and perform frame filtering, structure parsing, and verification rule matching in parallel. The parsing results are reported to EMS management according to device ID.

[0141] Figure 2 The system architecture diagram of the energy terminal provided in the embodiments of this application is as follows: Figure 2As shown, the energy terminal includes a drive module, which can be equipped with different interface device drivers, and each interface device driver can connect to different electrical devices.

[0142] The interaction in this embodiment can be achieved through MQTT communication.

[0143] Specifically, it may include the following parts:

[0144] (a) All JSON messages within the system are transmitted via the EMS internal MQTT bus, and the message subject is defined according to the rule "ems / [message direction] / [interface name]".

[0145] (b) Messages sent from the driver module to the EMS module (such as registration requests and data reporting) are published to the ems / driver_to_manager / [interface name] topic.

[0146] (c) Messages that the EMS module can send to the driver module (such as registration replies, command issuance) can be published to the ems / manager_to_driver / [interface name] topic.

[0147] (d) All messages are transmitted via the EMS internal MQTT bus. Topics are hierarchically structured according to "direction + interface name", with the rule: ems / [message direction] / [interface name]

[0148] Message direction: driver_to_manager (driver → manager), manager_to_driver (management → driver)

[0149] Interface names: 232_1, 232_2, 485_1, CAN_1, ...

[0150] In the embodiments of this application, the following descriptions are provided:

[0151] 1. The driver module sends a registration request to the EMS module using a standard JSON message.

[0152] 2. After the EMS module receives the registration request, if the JSON message is correct and parsed completely, the driver registration is actually complete and the driver can start working.

[0153] 3. In the actual process, a step has been added to synchronize the driver's own instruction set and the system management module to add a storage instruction mapping. Specifically, the EMS module records the functions of the driver according to its ID, such as: the driver has device registration, device parameter configuration, and device data proactive reporting functions. The purpose of adding this step is: the system management module can clearly define the capability boundaries of each driver through the "driver-instruction mapping table," avoiding sending instructions that the driver does not support and improving interaction stability.

[0154] Examples of new device access, internal communication, and driver registration are as follows:

[0155] Taking a device connected to the first 232 interface of the EMS module as an example:

[0156] (a) The 232_1 driver module identifies new devices through broad-spectrum exploration and protocol parsing.

[0157] (b) The driver module publishes the registration request JSON message to the ems / driver_to_manager / 232_1 topic.

[0158] The execution process is as follows:

[0159] Subject: ems / driver_to_manager / 232_1

[0160] {

[0161] "req_id": "202601121600001",

[0162] "device_id": "RS232_001",

[0163] "interface_version": "1.0",

[0164] "msg_direction": "driver_to_manager",

[0165] "msg_type": "REG",

[0166] "cmd_type": "REG_DRIVER",

[0167] "param": {},

[0168] "data": {},

[0169] "reg_info":

[0170] {

[0171] "driver_name": "232_Driver_V1.0",

[0172] "support_cmds": ["GET_DATA", "SET_PARAM"]

[0173] },

[0174] "execute_result": {},

[0175] "timestamp": "2026-01-12 16:00:00"

[0176] }

[0177] (c) The EMS module subscribes to the ems / driver_to_manager / topic and receives messages. After processing, it publishes the registration reply JSON message to the ems / manager_to_driver / 232_1 topic.

[0178] The execution process is as follows:

[0179] Subject: ems / manager_to_driver / pcs

[0180] {

[0181] "req_id": "202601121600001",

[0182] "device_id": "RS232_001",

[0183] "interface_version": "1.0",

[0184] "msg_direction": "manager_to_driver",

[0185] "msg_type": "REG",

[0186] "cmd_type": "REG_DRIVER",

[0187] "param": {},

[0188] "data": {},

[0189] "reg_info":

[0190] {

[0191] "driver_name": "232_Driver_V1.0",

[0192] "support_cmds": ["GET_DATA", "SET_PARAM"]

[0193] },

[0194] "execute_result":

[0195] {

[0196] "status": "SUCCESS",

[0197] "error_code": "0000",

[0198] "error_desc": ""

[0199] },

[0200] "timestamp": "2026-01-12 16:00:01"

[0201] }

[0202] (d) The driver module subscribes to the ems / manager_to_driver / 232_1 topic, receives and parses the registration reply message, and completes the registration of the new device.

[0203] The beneficial effects of the embodiments of this application are as follows:

[0204] 1. Zero equipment modification + minimalist architecture: Eliminating redundant layers, it achieves full-type device adaptation only through innovation on the EMS side. The EMS side provides standard interfaces to enable automatic recognition by the APP.

[0205] 2. Based on the standard interface specifications provided by EMS, develop an adapted APP (essentially a device-specific driver). The APP has built-in private protocol encoding and decoding and broad spectrum search functions, so that the APP is automatically recognized by EMS upon installation without modifying the EMS core program.

[0206] 3. APP byte-level protocol conversion engine: refines the entire process of frame parsing, verification matching, and value conversion at the byte level, achieving accurate conversion without the need for device-side cooperation;

[0207] 4. APP broad-spectrum inquiry command set + passive response adaptation closed loop: Automatically generate multi-protocol inquiry commands to achieve non-interventional adaptation of passive response devices;

[0208] 5. EMS no longer distinguishes between new device types, but rather by interface type. EMS initially only provides a basic management application; EMS focuses on management and no longer concerns itself with device communication protocols. Device access and identification can be completed simply by developing and installing the relevant drivers according to the standard interface.

[0209] This application embodiment enables EMS internal decoupling protocol adaptation and basic management functions. It does not rely entirely on equipment manufacturer protocols; the EMS has the ability to automatically identify newly connected devices. The EMS no longer distinguishes between the types of newly connected devices, but rather by interface type. It no longer differentiates between PCS, BMS, etc., but distinguishes by interface name, for example, whether a device is connected via the first 485 port or the first 232 interface.

[0210] Based on the same principle as the communication method for energy terminals provided in the embodiments of this application, the embodiments of this application also provide a communication device for energy terminals, such as... Figure 3 As shown, the energy terminal includes an EMS module and a drive module connected by communication. The communication device 20 is applied to the drive module. Specifically, the communication device 20 applied to the energy terminal may include an instruction sending module 21, an anomaly detection module 22, and a registration communication module 23.

[0211] The instruction sending module 21 is used to respond to the connection request received from the target device, calculate the instruction sending order of each exploration instruction in the instruction library based on the connection request, and send the exploration instructions to the target device in sequence according to the instruction sending order;

[0212] The anomaly detection module 22 is used to stop sending the probe command when a response frame is received from the target device, and to perform anomaly detection on the response frame;

[0213] The registration communication module 23 is used to send a registration command to the EMS module based on the response frame when the abnormal detection result of the response frame is normal, so as to enable the target device to establish communication with the EMS module.

[0214] In one embodiment of this application, the instruction sending module 21 is configured to: extract features from each exploration instruction in the instruction library to obtain multiple exploration frame features of the exploration instruction; determine the weight of each exploration frame feature based on the connection request; perform weighted calculation on each exploration frame feature based on the weight of each exploration frame feature to obtain the matching degree of the exploration instruction; and use the order of matching degree from high to low as the instruction sending order.

[0215] In one embodiment of this application, the multiple probe frame features include energy storage function identification features, frame length features, and check segment location features.

[0216] In one embodiment of this application, the instruction sending module 21 is used to: calculate the matching degree of the search instruction based on a first calculation formula;

[0217] The first calculation formula is:

[0218] P = a × A + b × B + c × C

[0219] Where P is the matching degree of the search command, A is the matching score of the energy storage function identification feature, B is the matching score of the frame length feature, C is the matching score of the check segment position feature, a is the weight of the energy storage function identification feature, b is the weight of the frame length feature, and c is the weight of the check segment position feature.

[0220] In one embodiment of this application, the instruction sending module 21 is used to send exploration instructions to the target device sequentially at preset time intervals according to the instruction sending order;

[0221] The preset duration is calculated and determined based on the interface information and the device information of the target device in the connection request.

[0222] In one embodiment of this application, the anomaly detection module 22 is used to: input the response frame into a pre-built anomaly detection model to obtain the anomaly probability;

[0223] Anomaly detection is performed on the response frame based on the anomaly probability;

[0224] The anomaly detection model includes a first anomaly verification layer and a second anomaly verification layer. The first anomaly verification layer is used to verify the format of the response frame, and the second anomaly verification layer is used to verify the timing of the response frame.

[0225] In one embodiment of this application, the registration communication module 23 is used to: perform structural parsing on the response frame to obtain multiple frame structures of the response frame;

[0226] Generate the target device's communication protocol format based on multiple frame structures;

[0227] A registration instruction is generated based on the communication protocol format and sent to the EMS module.

[0228] The communication protocol format of the target device is generated based on multiple frame structures, including:

[0229] Match the verification rules corresponding to each frame structure;

[0230] Each frame structure is validated based on the validation rules corresponding to each frame structure, and the communication protocol format of the target device is generated based on the validation results.

[0231] The apparatus in this application embodiment can execute the method provided in this application embodiment, and the implementation principle is similar. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For detailed functional descriptions of each module of the apparatus, please refer to the descriptions in the corresponding methods shown above, which will not be repeated here.

[0232] Figure 4A schematic diagram of the structure of an energy system applicable to an embodiment of this application is shown, such as... Figure 4 As shown, this energy system can be used to implement the methods provided in any embodiment of this application.

[0233] like Figure 4 As shown, the energy system 300 may primarily include at least one processor 301. Figure 4 The diagram shows components such as a memory 302, a communication module 303, and an input / output interface 304. Optionally, these components can be connected and communicate with each other via a bus 305. It should be noted that... Figure 4 The structure of the energy system 300 shown is merely illustrative and does not constitute a limitation on the energy system to which the method provided in the embodiments of this application applies.

[0234] The memory 302 can be used to store operating systems and applications, etc. The applications can include computer programs that implement the methods shown in the embodiments of this application when invoked by the processor 301, and can also include programs for implementing other functions or services. The memory 302 can be ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices that can store information and computer programs, or it can be EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.

[0235] Processor 301 is connected to memory 302 via bus 305 and implements corresponding functions by calling the application programs stored in memory 302. Processor 301 can be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 301 can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0236] The energy system 300 can connect to a network via a communication module 303 (which may include, but is not limited to, components such as a network interface) to communicate with other devices (such as user terminals or servers) through the network and achieve data interaction, such as sending data to or receiving data from other devices. The communication module 303 may include a wired network interface and / or a wireless network interface, meaning the communication module may include at least one of a wired communication module or a wireless communication module.

[0237] The energy system 300 can connect to necessary input / output devices, such as keyboards and display devices, via the input / output interface 304. The energy system 300 itself may have a display device, and other external display devices can also be connected via the input / output interface 304. Optionally, a storage device, such as a hard drive, can also be connected via the input / output interface 304 to store data from the energy system 300, retrieve data from the storage device, or store data from the storage device in the memory 302. It is understood that the input / output interface 304 can be a wired interface or a wireless interface. Depending on the actual application scenario, the device connected to the input / output interface 304 can be a component of the energy system 300 or an external device connected to the energy system 300 when needed.

[0238] The bus 305 used to connect the components may include a path for transmitting information between the components. The bus 305 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Depending on its function, the bus 305 may be divided into an address bus, a data bus, a control bus, etc.

[0239] Optionally, for the solution provided in the embodiments of this application, the memory 302 can be used to store a computer program that executes the solution of this application, and the processor 301 runs the computer program. When the processor 301 runs the computer program, it implements the operation of the method or apparatus provided in the embodiments of this application.

[0240] Based on the same principle as the method provided in the embodiments of this application, the embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the corresponding content of the aforementioned method embodiments.

[0241] This application also provides a computer program product, which includes a computer program that, when executed by a processor, can implement the corresponding content of the aforementioned method embodiments.

[0242] It should be noted that the terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text.

[0243] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0244] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.

[0245] The above are only optional implementation methods for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application, without departing from the technical concept of this application, also fall within the protection scope of the embodiments of this application.

Claims

1. A communication method applied to an energy terminal, characterized in that, The energy terminal includes an EMS module and a drive module connected by communication. The communication method is applied to the drive module and includes: In response to receiving a connection request from a target device, the system calculates the instruction sending order of each exploration instruction in the instruction library based on the connection request, and sends the exploration instructions to the target device sequentially according to the instruction sending order. Upon receiving a response frame from the target device, the probe command is stopped, and anomaly detection is performed on the response frame. When the anomaly detection result of the response frame is determined to be normal, a registration command is sent to the EMS module based on the response frame so that the target device establishes communication with the EMS module; The instruction sending order of each probe instruction in the connection request calculation instruction library includes: For each exploration instruction in the instruction library, feature extraction is performed on the exploration instruction to obtain multiple exploration frame features of the exploration instruction; The weights of each probe frame feature are determined based on the connection request; The matching degree of the search command is obtained by weighting the features of each search frame based on their respective weights. The order in which the commands are sent is determined by the matching degree from highest to lowest. The multiple exploration frame features include energy storage function identification features, frame length features, and verification segment location features; The anomaly detection of the response frame includes: The response frame is input into a pre-built anomaly detection model to obtain the anomaly probability; Anomaly detection is performed on the response frame based on the anomaly probability; The anomaly detection model includes a first anomaly verification layer and a second anomaly verification layer. The first anomaly verification layer is used to perform anomaly verification on the format of the response frame, and the second anomaly verification layer is used to perform anomaly verification on the timing rationality of the response frame.

2. The communication method applied to an energy terminal as described in claim 1, wherein the weighted calculation of each probe frame feature based on the weight of each probe frame feature to obtain the matching degree of the probe command includes: The matching degree of the search command is calculated based on the first calculation formula; The first calculation formula is: P = a × A + b × B + c × C Where P is the matching degree of the search command, A is the matching score of the energy storage function identification feature, B is the matching score of the frame length feature, C is the matching score of the check segment position feature, a is the weight of the energy storage function identification feature, b is the weight of the frame length feature, and c is the weight of the check segment position feature.

3. The communication method applied to an energy terminal as described in claim 1, characterized in that, Sending exploration commands to the target device sequentially according to the command sending order includes: In accordance with the order of instruction transmission, exploration instructions are sequentially sent to the target device at preset time intervals; The preset duration is calculated and determined based on the interface information and the device information of the target device in the connection request.

4. The communication method applied to an energy terminal according to any one of claims 1 to 3, characterized in that, Sending a registration instruction to the EMS module based on the response frame includes: The response frame is structurally parsed to obtain multiple frame structures of the response frame; The communication protocol format of the target device is generated based on multiple frame structures; A registration instruction is generated based on the communication protocol format, and the registration instruction is sent to the EMS module. The step of generating the communication protocol format of the target device based on multiple frame structures includes: Match the verification rules corresponding to each frame structure; Each frame structure is validated based on the validation rules corresponding to each frame structure, and the communication protocol format of the target device is generated based on the validation results.

5. A communication device applied to an energy terminal, characterized in that, The energy terminal includes an EMS module and a drive module connected by communication. The communication device is applied to the drive module and includes: The instruction sending module is used to respond to a connection request received from a target device, calculate the instruction sending order of each exploration instruction in the instruction library based on the connection request, and send the exploration instructions to the target device in sequence according to the instruction sending order; An anomaly detection module is used to stop sending probe commands when a response frame is received from the target device, and to perform anomaly detection on the response frame; The registration communication module is used to send a registration instruction to the EMS module based on the response frame when the anomaly detection result of the response frame is determined to be normal, so as to enable the target device to establish communication with the EMS module; The instruction sending module is used for: For each exploration instruction in the instruction library, feature extraction is performed on the exploration instruction to obtain multiple exploration frame features of the exploration instruction; The weights of each probe frame feature are determined based on the connection request; The matching degree of the search command is obtained by weighting the features of each search frame based on their respective weights. The order in which the commands are sent is determined by the matching degree from highest to lowest. The multiple exploration frame features include energy storage function identification features, frame length features, and verification segment location features; The anomaly detection module is used for: The response frame is input into a pre-built anomaly detection model to obtain the anomaly probability; Anomaly detection is performed on the response frame based on the anomaly probability; The anomaly detection model includes a first anomaly verification layer and a second anomaly verification layer. The first anomaly verification layer is used to perform anomaly verification on the format of the response frame, and the second anomaly verification layer is used to perform anomaly verification on the timing rationality of the response frame.

6. An energy system characterized by, The energy system includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the communication method for an energy terminal as described in any one of claims 1 to 4 when running the computer program.

7. A computer readable storage medium characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the communication method for an energy terminal as described in any one of claims 1 to 4.