CN113852532A - CAN communication method for machine number matching and CAN controller - Google Patents

CAN communication method for machine number matching and CAN controller Download PDF

Info

Publication number
CN113852532A
CN113852532A CN202111108616.7A CN202111108616A CN113852532A CN 113852532 A CN113852532 A CN 113852532A CN 202111108616 A CN202111108616 A CN 202111108616A CN 113852532 A CN113852532 A CN 113852532A
Authority
CN
China
Prior art keywords
information
machine number
target
data frame
target data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111108616.7A
Other languages
Chinese (zh)
Other versions
CN113852532B (en
Inventor
马群
张�浩
李睿
郭喜斌
司建龙
王洋
曹会平
李世涛
王勇江
张逾良
徐卫东
吴彦
张文杰
牛江涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hebei Tonghe New Energy Technology Co ltd
Original Assignee
Shijiazhuang Tonghe Electronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shijiazhuang Tonghe Electronics Co Ltd filed Critical Shijiazhuang Tonghe Electronics Co Ltd
Priority to CN202111108616.7A priority Critical patent/CN113852532B/en
Publication of CN113852532A publication Critical patent/CN113852532A/en
Application granted granted Critical
Publication of CN113852532B publication Critical patent/CN113852532B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40215Controller Area Network CAN

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Communication Control (AREA)

Abstract

The invention provides a CAN communication method for machine number matching and a CAN controller. The method is applied to the CAN controller and comprises the following steps: the machine number matching module receives a target data frame; the machine number matching module extracts frame information corresponding to each set of machine number positioning information from the target data frame according to a plurality of sets of pre-configured machine number positioning information; under the condition that target frame information exists, the machine number matching module sends a target data frame and ID partition index information corresponding to machine number positioning information of the target frame information to the ID partition module; the ID partitioning module searches whether target ID information identical to the ID information of the target data frame exists in the preset ID information corresponding to the ID partitioning index information; and if the target ID information exists, the communication module processes the target data frame according to the CAN communication protocol corresponding to the target ID information. The invention CAN solve the problem of complicated protocol code compiling in adapting to different CAN communication protocols.

Description

CAN communication method for machine number matching and CAN controller
Technical Field
The invention relates to the technical field of data communication, in particular to a CAN communication method and a CAN controller for machine number matching.
Background
A Controller Area Network (CAN) bus is a serial communication protocol bus, and is increasingly emphasized by people due to its high performance, high reliability and unique design, and is widely used in many fields, such as the field of automobile communication.
At present, a plurality of modules that charge in the electric automobile fills electric pile are generally connected to and carry out mutual communication on the CAN bus, fill electric pile complete machine and also generally CAN carry out the CAN communication with the external world. As the functional requirements become more complex, the communication protocol based on the CAN also become more complex and more varied according to different car factories or charging stations. In order to adapt to different CAN communication protocols, corresponding protocol codes are often required to be written for various CAN communication protocols, and the problem of complex operation exists.
Disclosure of Invention
The embodiment of the invention provides a CAN communication method and a CAN controller for number matching, which aim to solve the problem of complicated protocol code compiling in the process of adapting to different CAN communication protocols.
In a first aspect, an embodiment of the present invention provides a CAN communication method for machine number matching, which is applied to a CAN controller, where the CAN controller includes a machine number matching module, an ID partitioning module, and a communication module, and the method includes:
the machine number matching module receives a target data frame;
the machine number matching module extracts frame information corresponding to each set of machine number positioning information from the target data frame according to a plurality of sets of pre-configured machine number positioning information;
under the condition that target frame information exists, the machine number matching module sends a target data frame and ID partition index information corresponding to machine number positioning information of the target frame information to the ID partition module; the target frame information is the frame information which is the same as a preset machine number in the plurality of frame information;
the ID partitioning module searches whether target ID information identical to the ID information of the target data frame exists in the preset ID information corresponding to the ID partitioning index information;
and if the target ID information exists, the communication module processes the target data frame according to the CAN communication protocol corresponding to the target ID information.
In a second aspect, an embodiment of the present invention provides a CAN controller, including a number matching module, an ID partition module, and a communication module, where:
the system comprises a machine number matching module, a data processing module and a data processing module, wherein the machine number matching module is used for receiving a target data frame and respectively extracting frame information corresponding to each set of machine number positioning information from the target data frame according to a plurality of sets of pre-configured machine number positioning information; under the condition that target frame information exists, sending a target data frame and ID partition index information corresponding to the machine number positioning information of the target frame information to an ID partition module; the target frame information is the frame information which is the same as a preset machine number in the plurality of frame information;
the ID partition module is used for searching whether target ID information which is the same as the ID information of the target data frame exists in the preset ID information corresponding to the ID partition index information;
and the communication module is used for processing the target data frame according to the CAN communication protocol corresponding to the target ID information if the target ID information exists.
In a third aspect, an embodiment of the present invention provides a CAN controller, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method according to the first aspect when executing the computer program.
The embodiment of the invention provides a CAN communication method for number matching and a CAN controller, wherein a number matching module of the CAN controller CAN receive a target data frame and CAN respectively extract frame information corresponding to each group of number positioning information from the target data frame according to a plurality of groups of preset number positioning information. And under the condition that the target frame information exists, the machine number matching module sends the target data frame and the ID partition index information corresponding to the machine number positioning information of the target frame information to the ID partition module. And then, the ID partition module searches whether the target ID information identical to the ID information of the target data frame exists in the preset ID information corresponding to the ID partition index information. And if the target ID information exists, the communication module processes the target data frame according to the CAN communication protocol corresponding to the target ID information.
Therefore, the unified communication architecture for different CAN communication protocols carrying the number information is provided, corresponding protocol codes do not need to be independently compiled for different types of CAN communication protocols, for different CAN communication protocols, the number information rule of the CAN communication protocol is only needed to be configured into the number positioning information, the codes do not need to be modified, and the advantage of strong reusability is achieved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart illustrating steps of a CAN communication method for number matching according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a communication architecture according to an embodiment of the present invention;
FIG. 3 is a schematic processing flow diagram of a number matching module according to an embodiment of the present invention;
FIG. 4 is a flow chart illustrating a process of an ID partition module according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a CAN controller according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a CAN controller according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following description is made by way of specific embodiments with reference to the accompanying drawings.
As described in the background art, in order to adapt to different CAN communication protocols, it is often necessary to write corresponding protocol codes for various CAN communication protocols, and there is a problem of cumbersome operation.
For example, the CAN communication protocol adopted by the power modules in the existing electric vehicle and the charging pile thereof is usually complicated and variable according to different car factories or charging stations, wherein one charging pile CAN be composed of a plurality of power modules. In an actual scene, the power modules in the charging piles are generally required to be controlled respectively, and broadcast transmission is not required, so that the CAN communication protocol carries the number information in the data frame, namely, the data frame carrying a certain number is issued, only the power module corresponding to the number responds, and other power modules do not respond. However, the existing CAN communication protocols are complex and variable, some CAN communication protocols require that the number information is carried in the ID area of the data frame, some CAN communication protocols require that the number information is carried in the data area of the data frame, that is, whether the number information is in the data area or the ID area, and at which position of the data area or the ID area the number information is, neither CAN be unified, and have no universality. As shown in table one.
Watch 1
Figure BDA0003273293940000041
Therefore, in order to identify and process the data frame carrying the organic number information, corresponding protocol codes need to be independently written for different types of CAN communication protocols, and the problem of complex operation exists.
In order to solve the problem of the prior art, the embodiment of the invention provides a CAN communication method and a CAN controller for number matching. First, a CAN communication method for matching a serial number according to an embodiment of the present invention will be described.
Referring to fig. 1, it shows a flowchart of implementing a CAN communication method for machine number matching according to an embodiment of the present invention, including the following steps:
and step S110, the machine number matching module receives the target data frame.
In some embodiments, the target data frame may be any one of the data frames received by the CAN controller.
Step S120, the machine number matching module extracts frame information corresponding to each set of machine number positioning information from the target data frame according to a plurality of sets of machine number positioning information configured in advance.
Because different CAN communication protocols carry the machine number in the data frame, the data frame CAN be considered as a whole, namely the ID area and the data area are considered as a whole, and the machine number positioning information is adopted to replace the existing mode of matching the machine number in the ID area or the data area, so that the configuration of the machine number information by the different CAN communication protocols is unified.
Specifically, the machine number positioning information includes a machine number starting address and an address length occupied by the machine number. The machine number matching module CAN configure machine number information rules of different CAN communication protocols into machine number positioning information in advance based on the received control instruction.
Optionally, the specific processing of step S120 may be as follows: and respectively extracting numerical values corresponding to the initial address and the address length of the machine number in each group of machine number positioning information from the target data frame, and determining the corresponding numerical values as frame information corresponding to each group of machine number positioning information.
In some embodiments, taking the machine number positioning information with the machine number starting address of bit5 and the address length of 8 as an example, the ID area and the data area of the target data frame may be taken as a whole, for example, the data frame with the bit0-bit63 as the data area and the bit64-bit92 as the ID area, and then the value of the target data frame at bit5-12 is extracted, and the value at bit5-12 in the target data frame is the frame information corresponding to the machine number positioning information in this embodiment.
Step S130, under the condition that the target frame information exists, the machine number matching module sends the target data frame and the ID partition index information corresponding to the machine number positioning information of the target frame information to the ID partition module.
The target frame information is the frame information which is the same as a preset machine number in the plurality of frame information.
In some embodiments, the ID partition index information includes an ID partition start address and an ID partition address length.
Optionally, if the target frame information does not exist, it indicates that the number information of the target data frame does not conform to the preset number of the CAN controller, that is, the target data frame does not need to respond, and at this time, the target data frame may be discarded.
Step S140, the ID partitioning module searches whether there is target ID information identical to the ID information of the target data frame in the ID information corresponding to the ID partitioning index information configured in advance.
In some embodiments, an ID partition range consisting of an ID partition start address and an ID partition address length may be determined, and then a traversal lookup is performed to find whether there is target ID information identical to the ID information of the target data frame among all ID information belonging to the ID partition range.
And step S150, if the target ID information exists, processing the target data frame according to the CAN communication protocol corresponding to the target ID information.
Optionally, if the target ID information does not exist, it indicates that there is no corresponding CAN communication protocol, that is, the target data frame does not need to respond, and at this time, the target data frame may be discarded.
To better understand the CAN communication method for matching machine numbers provided by the embodiment of the present invention, as shown in fig. 2, a schematic diagram of a communication architecture is provided, where the communication architecture may be designed by using a C + + object-oriented method, and the communication architecture has the following functions:
the function 1, use the machine number to match module and machine number ID and divide the module, to carrying the data frame of CAN communication protocol of machine number information, CAN find the receiving protocol of self ID accurately, if the machine number information does not match with self machine number, directly abandon the data frame, CAN not reach the processing area of receiving protocol.
Function 2, to the different problem in the representation machine number position in a plurality of different CAN communication protocols, regard ID district and data area as unified whole and carry out data processing, avoid the condition that the machine number needs to be handled respectively in ID district and data area.
And the function 3 and the machine number matching module respectively record the starting bit and length of the machine number, the position indexed to the ID partition module and the size information of the position according to different positions of the represented machine number, and directly index to the ID area head address of the ID partition module at the corresponding position to search the ID after the received machine number information is matched with the actual machine number.
Function 4, ID partition module: the ID information representing different positions of the machine number is partitioned, and the different ID information in the same position can be decoupled.
Through the functions, different CAN communication protocols carrying the number information CAN be unified under the communication framework, corresponding protocol codes do not need to be independently compiled for different types of CAN communication protocols, for different CAN communication protocols, the number information rule of the CAN communication protocol is only needed to be configured into the number positioning information, the codes do not need to be modified, and the advantage of strong reusability is achieved.
Referring to fig. 3, the processing flow of the number matching module will be described in detail.
Firstly, whether the position information (namely machine number positioning information) of all machine numbers is searched is judged, if the position information is searched, the computer exits, if the position information is not searched, and one of the machine number information is searched, whether the position of the machine number information exceeds the limit, namely whether the position of the machine number information is in the range of bit0-bit92 is judged, if the position of the machine number information exceeds the limit, the current machine number information is directly discarded, the next machine number information is detected, if the position information does not exceed the limit, whether the current machine number information is in an ID area or a data area is judged, if the current machine number information is in the ID area, the machine number is obtained from the ID area, an ID filter is obtained according to the position obtained by the ID area (the part which does not need to be matched in the received ID number is filtered, only the part which needs to be matched is left for matching), if the data area, the machine number is obtained from the data area, and the ID filter keeps a default value, such as 0 xFFFFFFFFFF. And finally, judging whether the obtained machine number information is matched with the actual machine number or not, if so, ending the process, and if not, detecting the next position information.
Through the process, the machine number under the corresponding position information can be acquired according to different position information. In addition, the acquired machine number can be matched with the actual machine number, if the matching is successful, the ID searching is directly carried out on the machine number ID partition module according to the index of the machine number matching module and the area size information, if the matching is unsuccessful, the next position information is continuously detected, and the matching of the actual machine number is carried out until all the position information is searched.
Referring to fig. 4, the processing flow of the number ID partition module will be described in detail.
First, the ID numbers (ID information) of the same number position information are recorded in one ID area, the ID numbers of different number positions are recorded in different ID areas, and the ID number matching is performed according to the head address and the total length of the ID area specified by the number matching module. And then judging whether all the ID numbers in the ID area are traversed or not. If the traversal is finished, the process of detecting the next position information in the figure 3 is returned, and if the traversal is not finished, the traversal is continued. If the current ID number is traversed to one ID number, detecting whether the residual part of the ID number after the ID filter is filtered is consistent with the ID number of the target data frame (the ID filter part is removed in the same way), if so, processing by a CAN communication protocol corresponding to the ID number, and if not, detecting the next ID number of the ID area.
In the embodiment of the invention, the machine number matching module of the CAN controller CAN receive the target data frame and CAN respectively extract the frame information corresponding to each set of machine number positioning information from the target data frame according to a plurality of sets of machine number positioning information configured in advance. And under the condition that the target frame information exists, the machine number matching module sends the target data frame and the ID partition index information corresponding to the machine number positioning information of the target frame information to the ID partition module. And then, the ID partition module searches whether the target ID information identical to the ID information of the target data frame exists in the preset ID information corresponding to the ID partition index information. And if the target ID information exists, the communication module processes the target data frame according to the CAN communication protocol corresponding to the target ID information. Therefore, the unified communication architecture for different CAN communication protocols carrying the number information is provided, corresponding protocol codes do not need to be independently compiled for different types of CAN communication protocols, for different CAN communication protocols, the number information rule of the CAN communication protocol is only needed to be configured into the number positioning information, the codes do not need to be modified, and the advantage of strong reusability is achieved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
The following are embodiments of the apparatus of the invention, reference being made to the corresponding method embodiments described above for details which are not described in detail therein.
Fig. 5 shows a schematic structural diagram of a CAN controller provided in an embodiment of the present invention, and for convenience of description, only parts related to the embodiment of the present invention are shown, which are detailed as follows:
as shown in fig. 5, the CAN controller 500 includes a number matching module 510, an ID partitioning module 520, and a communication module 530, wherein:
a number matching module 510, configured to receive a target data frame, and extract frame information corresponding to each set of number positioning information from the target data frame according to multiple sets of pre-configured number positioning information; under the condition that target frame information exists, sending a target data frame and ID partition index information corresponding to the machine number positioning information of the target frame information to an ID partition module; the target frame information is the frame information which is the same as a preset machine number in the plurality of frame information;
an ID partitioning module 520, configured to search whether there is target ID information that is the same as ID information of a target data frame in ID information corresponding to ID partitioning index information configured in advance;
and the communication module 530 is configured to, if the target ID information exists, process the target data frame according to a CAN communication protocol corresponding to the target ID information.
In one possible implementation manner, the machine number positioning information includes a machine number starting address and an address length occupied by the machine number.
In one possible implementation, the machine number matching module is further configured to:
and respectively extracting numerical values corresponding to the initial address and the address length of the machine number in each group of machine number positioning information from the target data frame, and determining the corresponding numerical values as frame information corresponding to each group of machine number positioning information.
In one possible implementation, the ID partition index information includes an ID partition start address and an ID partition address length.
In one possible implementation, the ID partitioning module is further configured to:
determining an ID partition range formed by an ID partition starting address and an ID partition address length;
and traversing and searching whether target ID information identical to the ID information of the target data frame exists in all the ID information belonging to the ID partition range.
In one possible implementation, the communication module is further configured to:
in the absence of target frame information, the target data frame is discarded.
In one possible implementation, the communication module is further configured to:
if the target ID information does not exist, the target data frame is discarded.
In the embodiment of the invention, the machine number matching module of the CAN controller CAN receive the target data frame and CAN respectively extract the frame information corresponding to each set of machine number positioning information from the target data frame according to a plurality of sets of machine number positioning information configured in advance. And under the condition that the target frame information exists, the machine number matching module sends the target data frame and the ID partition index information corresponding to the machine number positioning information of the target frame information to the ID partition module. And then, the ID partition module searches whether the target ID information identical to the ID information of the target data frame exists in the preset ID information corresponding to the ID partition index information. And if the target ID information exists, the communication module processes the target data frame according to the CAN communication protocol corresponding to the target ID information. Therefore, the unified communication architecture for different CAN communication protocols carrying the number information is provided, corresponding protocol codes do not need to be independently compiled for different types of CAN communication protocols, for different CAN communication protocols, the number information rule of the CAN communication protocol is only needed to be configured into the number positioning information, the codes do not need to be modified, and the advantage of strong reusability is achieved.
Fig. 6 is a schematic diagram of the CAN controller 6 according to the embodiment of the present invention. As shown in fig. 6, the CAN controller 6 of this embodiment includes: a processor 60, a memory 61 and a computer program 62 stored in said memory 61 and executable on said processor 60. The processor 60 executes the computer program 62 to implement the steps in the above-mentioned embodiments of the CAN communication method for machine number matching, such as steps S110 to S150 shown in fig. 1. Alternatively, the processor 60, when executing the computer program 62, implements the functions of the modules in the above-described device embodiments, such as the functions of the modules 510 to 530 shown in fig. 5.
Illustratively, the computer program 62 may be partitioned into one or more modules that are stored in the memory 61 and executed by the processor 60 to implement the present invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 62 in the CAN controller 6. For example, the computer program 62 may be divided into the modules 510 to 530 shown in fig. 5.
The CAN controller 6 may include, but is not limited to, a processor 60, a memory 61. It will be appreciated by those skilled in the art that fig. 6 is merely an example of a CAN controller 6 and does not constitute a limitation of the CAN controller 6 and may include more or fewer components than shown, or combine certain components, or different components, e.g. the CAN controller may also include input output devices, network access devices, buses, etc.
The Processor 60 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 61 may be an internal storage unit of the CAN controller 6, such as a hard disk or a memory of the CAN controller 6. The memory 61 may also be an external storage device of the CAN controller 6, such as a plug-in hard disk provided on the CAN controller 6, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like. Further, the memory 61 may also include both an internal storage unit and an external storage device of the CAN controller 6. The memory 61 is used to store the computer program and other programs and data required by the CAN controller. The memory 61 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated module, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the method according to the above embodiments may be implemented by a computer program, which may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the steps of the above embodiments of the CAN communication method for machine number matching may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A CAN communication method for machine number matching is applied to a CAN controller, the CAN controller comprises a machine number matching module, an ID partition module and a communication module, and the method comprises the following steps:
the machine number matching module receives a target data frame;
the machine number matching module extracts frame information corresponding to each group of machine number positioning information from the target data frames according to a plurality of groups of pre-configured machine number positioning information;
under the condition that target frame information exists, the machine number matching module sends the target data frame and ID partition index information corresponding to the machine number positioning information of the target frame information to the ID partition module; the target frame information is frame information which is the same as a preset machine number in the plurality of frame information;
the ID partitioning module searches whether target ID information which is the same as the ID information of the target data frame exists in the preset ID information corresponding to the ID partitioning index information;
and if the target ID information exists, the communication module processes the target data frame according to a CAN communication protocol corresponding to the target ID information.
2. The method of claim 1, wherein the machine number positioning information comprises a machine number starting address and an address length occupied by the machine number.
3. The method according to claim 2, wherein said extracting frame information corresponding to each set of the number positioning information in the target data frame respectively comprises:
and respectively extracting numerical values corresponding to the starting address and the address length of the machine number in each group of the machine number positioning information from the target data frame, and determining the corresponding numerical values as frame information corresponding to each group of the machine number positioning information.
4. The method of claim 1, wherein the ID partition index information comprises an ID partition start address and an ID partition address length.
5. The method of claim 4, wherein the searching whether the target ID information identical to the ID information of the target data frame exists comprises:
determining an ID partition range formed by the ID partition starting address and the ID partition address length;
and traversing and searching whether target ID information identical to the ID information of the target data frame exists in all the ID information belonging to the ID partition range.
6. The method according to claim 1, wherein after said extracting frame information corresponding to each set of said number positioning information in said target data frame, respectively, said method further comprises:
in the absence of target frame information, discarding the target data frame.
7. The method of claim 1, wherein after the finding whether there is target ID information that is the same as the ID information of the target data frame, the method further comprises:
and if the target ID information does not exist, discarding the target data frame.
8. A CAN controller is characterized by comprising a machine number matching module, an ID partition module and a communication module, wherein:
the machine number matching module is used for receiving a target data frame and extracting frame information corresponding to each group of machine number positioning information from the target data frame according to a plurality of groups of pre-configured machine number positioning information; under the condition that target frame information exists, sending the target data frame and ID partition index information corresponding to the machine number positioning information of the target frame information to an ID partition module; the target frame information is frame information which is the same as a preset machine number in the plurality of frame information;
the ID partition module is used for searching whether target ID information which is the same as the ID information of the target data frame exists in the preset ID information corresponding to the ID partition index information;
and the communication module is used for processing the target data frame according to a CAN communication protocol corresponding to the target ID information if the target ID information exists.
9. The CAN controller of claim 8 wherein said machine number location information comprises a machine number start address and an address length occupied by a machine number.
10. A CAN controller comprising a memory, a processor and a computer program stored in said memory and executable on said processor, characterized in that said processor implements the steps of the method according to any of claims 1 to 7 when executing said computer program.
CN202111108616.7A 2021-09-22 2021-09-22 CAN communication method for machine number matching and CAN controller Active CN113852532B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111108616.7A CN113852532B (en) 2021-09-22 2021-09-22 CAN communication method for machine number matching and CAN controller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111108616.7A CN113852532B (en) 2021-09-22 2021-09-22 CAN communication method for machine number matching and CAN controller

Publications (2)

Publication Number Publication Date
CN113852532A true CN113852532A (en) 2021-12-28
CN113852532B CN113852532B (en) 2023-01-06

Family

ID=78974897

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111108616.7A Active CN113852532B (en) 2021-09-22 2021-09-22 CAN communication method for machine number matching and CAN controller

Country Status (1)

Country Link
CN (1) CN113852532B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090210397A1 (en) * 2008-02-20 2009-08-20 Fujitsu Ten Limited Data search device and gateway device in communication apparatus
CN105717813A (en) * 2016-01-29 2016-06-29 深圳市美好幸福生活安全***有限公司 Method and device for obtaining physical quantity corresponding to CAN data and equipment
CN106031098A (en) * 2015-01-20 2016-10-12 松下电器(美国)知识产权公司 Invalid frame handling method, invalidity detection electronic-control unit and vehicle-mounted network system
CN113177015A (en) * 2021-05-24 2021-07-27 石家庄通合电子科技股份有限公司 Frame header-based serial port communication method and serial port chip

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090210397A1 (en) * 2008-02-20 2009-08-20 Fujitsu Ten Limited Data search device and gateway device in communication apparatus
CN106031098A (en) * 2015-01-20 2016-10-12 松下电器(美国)知识产权公司 Invalid frame handling method, invalidity detection electronic-control unit and vehicle-mounted network system
CN105717813A (en) * 2016-01-29 2016-06-29 深圳市美好幸福生活安全***有限公司 Method and device for obtaining physical quantity corresponding to CAN data and equipment
CN113177015A (en) * 2021-05-24 2021-07-27 石家庄通合电子科技股份有限公司 Frame header-based serial port communication method and serial port chip

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
QIAN WANG,YIMING QIAN,ZHAOJUN LU,YASSER SHOUKRY,GANG QU: "A Delay based Plug-in-Monitor for Intrusion Detection in Controller Area Network", 《2018 ASIAN HARDWARE ORIENTED SECURITY AND TRUST SYMPOSIUM (ASIANHOST)》 *
束庆冉: "面向智能电池管理***的集成CAN总线接口电路设计", 《中国优秀硕士学位论文全文数据库》 *

Also Published As

Publication number Publication date
CN113852532B (en) 2023-01-06

Similar Documents

Publication Publication Date Title
CN108551670B (en) Bluetooth connection method and device and intelligent terminal
CN109814524B (en) Vehicle diagnosis method, device and system
CN113852531B (en) CAN communication method and CAN controller for function code matching
EP4170514A1 (en) Data association query method and apparatus, and device and storage medium
CN105101161A (en) Information processing method and information processing device
CN112052643B (en) Circuit schematic diagram checking method and system
CN112199935A (en) Data comparison method and device, electronic equipment and computer readable storage medium
CN113177015B (en) Frame header-based serial port communication method and serial port chip
CN113852532B (en) CAN communication method for machine number matching and CAN controller
CN113655776B (en) Vehicle detection method and device, electronic equipment and storage medium
CN114418147A (en) Method and device for processing abnormity of main charging module, terminal and storage medium
CN113824621B (en) CAN communication method based on signals and CAN controller
CN115442799A (en) Number query method and device, nonvolatile storage medium and processor
CN114756585A (en) Vehicle data acquisition method and device, electronic equipment and storage medium
CN104684046A (en) A network searching method and terminal
CN113127408A (en) Data conversion method and device
CN115938022B (en) Vehicle entity key safety authentication method and system
CN115474164B (en) Bluetooth broadcast filtering method and system
CN116321541A (en) Collector network configuration method, collector network configuration device, terminal and storage medium
CN112702068B (en) Method, device, equipment and storage medium for processing coded data
CN113901285B (en) Vehicle road test method, device, electronic equipment and storage medium
US11423646B2 (en) Loop closure detection method, mobile device and computer readable storage medium
CN111046012B (en) Method and device for extracting inspection log, storage medium and electronic equipment
CN111016730B (en) Battery charging detection method and device and terminal equipment
CN118096550A (en) Spinal image fusion method based on multi-scale residual pyramid attention network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20221213

Address after: 050000 no.350 Lijiang Road, high tech Zone, Shijiazhuang, Hebei Province

Applicant after: Hebei Tonghe New Energy Technology Co.,Ltd.

Address before: 050000 no.350 Lijiang Road, high tech Zone, Shijiazhuang, Hebei Province

Applicant before: SHIJIAZHUANG TONGHE ELECTRONICS Co.,Ltd.

GR01 Patent grant
GR01 Patent grant