CN115695589A - Method, system, device and medium for automatically generating CAN message analysis code - Google Patents

Method, system, device and medium for automatically generating CAN message analysis code Download PDF

Info

Publication number
CN115695589A
CN115695589A CN202211196899.XA CN202211196899A CN115695589A CN 115695589 A CN115695589 A CN 115695589A CN 202211196899 A CN202211196899 A CN 202211196899A CN 115695589 A CN115695589 A CN 115695589A
Authority
CN
China
Prior art keywords
message
signal
byte
signals
analysis
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211196899.XA
Other languages
Chinese (zh)
Inventor
白新龙
刘义
张震
周思全
王瑞男
刘强
任帅
刘宏伟
郝刘丹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xian Fast Auto Drive Co Ltd
Original Assignee
Xian Fast Auto Drive 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 Xian Fast Auto Drive Co Ltd filed Critical Xian Fast Auto Drive Co Ltd
Priority to CN202211196899.XA priority Critical patent/CN115695589A/en
Publication of CN115695589A publication Critical patent/CN115695589A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses a method, a system, a device and a medium for automatically generating CAN message analysis codes, which comprise the following steps: collecting CAN message signals; dividing the collected CAN message signals to obtain different types of messages; acquiring parameters of the CAN message signals based on the distribution of the CAN message signals in the message; acquiring the mobile information of the CAN message signal based on the parameter of the CAN message signal; and converting the original value of the CAN message signal into an actual physical value based on the mobile information of the CA N message signal, thereby realizing the analysis of the CAN message. The invention automatically generates the message analysis code, automatically analyzes a large number of complex and various message signals, has high working efficiency, greatly saves time, reduces labor cost and generates very obvious economic benefit.

Description

Method, system, device and medium for automatically generating CAN message analysis code
Technical Field
The invention belongs to the technical field of message processing, and relates to a method, a system, a device and a medium for automatically generating CAN message analysis codes.
Background
With the popularization of new energy commercial vehicles, each large host factory continuously pushes out new energy commercial vehicles, the vehicles are multiple in types, the projects are multiple, the intelligent control of the whole vehicle is required to have more communication nodes, the communication node network distribution is complex, and meanwhile, a unified communication protocol standard does not exist; the communication nodes on the traditional commercial vehicle mostly follow SAE J19139 protocol, and the communication nodes are few, so CAN message analysis work in gearbox software development is very small, and errors are not easy to occur. When the new energy commercial vehicle is developed in gearbox software, because each host factory is a self-defined communication protocol, the CAN message analysis workload is very large, errors are easy to occur, and the efficiency is low.
Disclosure of Invention
The invention aims to solve the problems of large workload, high error probability and low efficiency of CAN message analysis in the prior art, and provides a method, a system, a device and a medium for automatically generating CAN message analysis codes.
In order to achieve the purpose, the invention adopts the following technical scheme to realize the purpose:
a method for automatically generating CAN message analysis codes comprises the following steps:
collecting CAN message signals;
dividing the collected CAN message signals to obtain different types of messages;
based on the distribution of the CAN message signals in the message, the parameters of the CAN message signals are obtained,
acquiring the mobile information of the CAN message signal based on the parameter of the CAN message signal;
and based on the mobile information of the CAN message signal, converting the original value of the CAN message signal into an actual physical value, and realizing the analysis of the CAN message.
The invention is further improved in that:
dividing the collected CAN message signals to obtain different types of messages, specifically: in the collected CAN message signals, the CAN message signals with the same message ID are divided into a group; the message IDs have different types, and CAN message signals are divided to obtain different types of messages.
The parameters of the CAN message signal comprise the start bit, the length, the precision and the offset of the signal.
The mobile information of the CAN message signal comprises: the signal occupies bytes, a shift direction, a shift length and a bit fetch length.
The original value of the CAN message signal is a binary number with a certain length; acquiring an original value of the CAN message signal based on the CAN message signal parameter;
converting an original value of the CAN message signal into an actual physical value, specifically: the CAN message signal comprises a motor torque signal, and the motor torque signal is positioned in a third byte and a fourth byte; the original value of the motor torque signal is converted into an actual physical value as follows:
MotTorque=(uint16(byte[4])<<8+uint16(byte[3]))*scale+offset
wherein MotTorque is the variable name of the motor torque in the program, scale is the motor torque signal precision, offset is the offset, and uint16 is 16-bit unsigned integer; byte [3] is the third byte and byte [4] is the fourth byte.
The CAN message is formed by 64-bit binary numbers, 8-bit binary numbers form a byte, and 8 bytes form a frame of CAN message.
The CAN message analysis file is a C language file, and the extension names are.
A system for automatically generating CAN message analysis codes comprises:
the acquisition module is used for acquiring CAN message signals;
the dividing module is used for dividing the collected CAN message signals to obtain different types of messages;
a first acquisition module that acquires a parameter of a CAN message signal based on the distribution of the CAN message signal in the message,
the second acquisition module acquires the mobile information of the CAN message signal based on the parameter of the CAN message signal;
and the conversion module converts the original value of the CAN message signal into an actual physical value based on the movement information of the CAN message signal, so as to realize the analysis of the CAN message.
A terminal device comprising a memory, a processor and a computer program stored in said memory and executable on said processor, said processor implementing the steps of the above method when executing said computer program.
A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method.
Compared with the prior art, the invention has the following beneficial effects:
the invention divides the collected CAN message signals to obtain different types of messages; according to the distribution of the CAN message signals in the message, acquiring the parameters of the CAN message signals and the movement information of the CAN message signals; and finally, the original value of the CAN message signal is converted into an actual physical value, so that the analysis of the CAN message is realized. The invention automatically generates the message analysis code, automatically analyzes a large number of complex and various message signals, has high working efficiency, greatly saves time, reduces labor cost and generates very obvious economic benefit.
Drawings
In order to more clearly explain the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention, and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
FIG. 1 is a flow chart of a method for automatically generating a CAN message analysis code according to the present invention;
FIG. 2 is a system structure diagram of the present invention for automatically generating CAN message analysis codes;
fig. 3 is an exemplary diagram of a CAN message according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
In the description of the embodiments of the present invention, it should be noted that if the terms "upper", "lower", "horizontal", "inner", etc. are used for indicating the orientation or positional relationship based on the orientation or positional relationship shown in the drawings or the orientation or positional relationship which is usually arranged when the product of the present invention is used, the description is merely for convenience and simplicity, and the indication or suggestion that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and thus, cannot be understood as limiting the present invention. Furthermore, the terms "first," "second," and the like are used solely to distinguish one from another, and are not to be construed as indicating or implying relative importance.
Furthermore, the term "horizontal", if present, does not mean that the component is required to be absolutely horizontal, but may be slightly inclined. For example, "horizontal" merely means that the direction is more horizontal than "vertical" and does not mean that the structure must be perfectly horizontal, but may be slightly inclined.
In the description of the embodiments of the present invention, it should be further noted that unless otherwise explicitly stated or limited, the terms "disposed," "mounted," "connected," and "connected" should be interpreted broadly, and may be, for example, fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood according to specific situations by those of ordinary skill in the art.
The invention is described in further detail below with reference to the accompanying drawings:
referring to fig. 1, the invention discloses a method for automatically generating a CAN message analysis code, which comprises the following steps:
s101, collecting CAN message signals.
S102, dividing the collected CAN message signals to obtain different types of messages.
In the collected CAN message signals, the CAN message signals with the same message ID are divided into a group; the message IDs have different types, and CAN message signals are divided to obtain different types of messages.
S103, acquiring parameters of the CAN message signals based on the distribution of the CAN message signals in the message.
The parameters of the CAN message signal comprise the starting bit, the length, the precision and the offset of the signal.
And S104, acquiring the mobile information of the CAN message signal based on the parameter of the CAN message signal.
The mobile information of the CAN message signal comprises: the signal occupies bytes, a shift direction, a shift length and a bit fetch length.
And S105, converting the original value of the CAN message signal into an actual physical value based on the mobile information of the CAN message signal, so as to realize the analysis of the CAN message.
The original value of the CAN message signal is a binary number with a certain length; acquiring an original value of the CAN message signal based on the CAN message signal parameter;
converting an original value of the CAN message signal into an actual physical value, specifically: the CAN message signal comprises a motor torque signal, and the motor torque signal is positioned in a third byte and a fourth byte; the original value of the motor torque signal is converted into an actual physical value as follows:
MotTorque=(uint16(byte[4])<<8+uint16(byte[3]))*scale+offset
wherein MotTorque is the variable name of the motor torque in the program, scale is the motor torque signal precision, offset is the offset, and uint16 is 16-bit unsigned integer; byte [3] is the third byte and byte [4] is the fourth byte.
The CAN message is formed by 64-bit binary numbers, 8-bit binary numbers form one byte, and 8 bytes form one frame of CAN message. The CAN message analysis file is a C language file, and the extension names are.
Referring to fig. 2, the present invention discloses a system for automatically generating a CAN message parsing code, which includes:
the acquisition module is used for acquiring CAN message signals;
the dividing module is used for dividing the collected CAN message signals to acquire different types of messages;
a first acquisition module, which is distributed in the message based on the CAN message signal to acquire the parameter of the CAN message signal,
the second acquisition module acquires the mobile information of the CAN message signal based on the parameter of the CAN message signal;
and the conversion module converts the original value of the CAN message signal into an actual physical value based on the movement information of the CAN message signal, so as to realize the analysis of the CAN message.
The invention provides a software interface developed based on an MATLAB tool, which CAN realize man-machine interaction, manually input various attribute information of CAN message signals through the interface, and click a generated code to automatically generate a CAN message analysis file, wherein the CAN message analysis file is a C language file with extension names of x, C and h.
The attribute information includes: signal name, association message ID, start bit, length, precision, offset, data type, node, channel, and period.
Inputting all signals in the interface, automatically identifying the associated message ID by a program for grouping, dividing all the signals with the same message ID into one group, namely a frame of message, and generating the analysis function code of the message aiming at the frame of message. And analyzing each signal according to the length, the initial bit, the precision and the offset of the signal, and converting the original value of the signal bus into an actual physical value, namely realizing the analysis of the signal.
One frame of message is composed of 64 bits of 8 bytes, wherein the original value of a signal on a bus is a binary number with a certain bit length, automatic analysis only needs to extract the original value of the signal from a binary data field with the 64 bit length, and then the original value is converted into a physical value according to an analysis rule.
Referring to fig. 3, fig. 3 is a frame of CAN message, which is composed of 64-bit 2-ary number, each line in the figure is composed of 8 bits, called one byte, and a total of 8 bytes constitutes a frame of message, which is composed of a motor speed signal, a motor torque signal and a motor operation mode signal, wherein the length and distribution of the signals are as shown in fig. 3; the analysis of the message is to analyze the original value (binary number) of the signal in the graph into a physical value according to an analysis rule.
The binary number of the original data of the message is stored in a byte digital group, wherein the byte digital group is composed of 8 bytes, byte [0], byte [1], \8230andbyte [7], and each byte is an 8-bit binary number, and the analytic code of the motor torque signal in the figure 3 is as follows:
MotTorque=(uint16(byte[4])<<8+uint16(byte[3]))*scale+offset
wherein MotTorque is the variable name of the motor torque in the program, scale is the motor torque signal precision, offset is the offset, and uint16 is 16-bit unsigned integer; byte [3] is the third byte and byte [4] is the fourth byte.
The analytic code of the motor working mode signal is as follows:
WorkMode=(uint8)(((byte[5]>>2)&0xF)*Scale+offset)
wherein, the & is a bit-taking symbol, 0x represents a 16-system, F is a 16-system number, and 1111 is converted into a 2-system number, that is, 4 bits of the byte occupied by the signal are taken out.
All the information required by analysis is acquired from the interface, according to the method, all the signals can automatically generate analysis codes, and finally all the analysis code functions form a complete analysis file.
And the user inputs the signal into the interface, clicks a 'generate code' button on the interface, so that the analysis code can be automatically generated, and the analysis code is output as the files of the x, c and the x, h. The callback function of the 'generate code' key has the main function of generating an analysis code and outputting a file.
Firstly, all signals input to an interface are grouped according to messages by using a cycle, the signals with the same associated message ID attribute are divided into a frame of message, after all the signals are all divided into each message, the cycle is used for generating analysis codes for the single message one by one, a program obtains the data of the start bit, the length, the precision, the offset and the like of the signals by using the distribution of the signals in the message, automatically calculates the information of the byte, the shift direction, the shift length, the bit taking length and the like of the signals, and then analyzes the information into physical values by using an analysis rule. All messages CAN independently generate an analytic function, and all analytic functions are output to the same x, c and h files, so that the automatic generation of the analytic code files of the CAN messages is completed.
The analysis function is a section of expression, the function is widely used in programming languages, the function CAN package codes for realizing one function into one unit, the function of the function is only needed to be called to realize a certain function, the CAN bus message comprises a plurality of messages, the analysis function of each frame of message CAN be automatically generated, and all analysis function codes form an analysis file.
The invention provides terminal equipment. The terminal device of this embodiment includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. The processor realizes the steps of the above method embodiments when executing the computer program. Alternatively, the processor implements the functions of the modules/units in the above device embodiments when executing the computer program.
The computer program may be partitioned into one or more modules/units that are stored in the memory and executed by the processor to implement the invention.
The terminal device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The terminal device may include, but is not limited to, a processor, a memory.
The processor may be a Central Processing Unit (CPU), other general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc.
The memory may be used for storing the computer programs and/or modules, and the processor may implement various functions of the terminal device by executing or executing the computer programs and/or modules stored in the memory and calling data stored in the memory.
The terminal device integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also 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 method embodiments described above 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, etc. It should be noted that the computer-readable medium may contain suitable additions or subtractions depending on the requirements of legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer-readable media may not include electrical carrier signals or telecommunication signals in accordance with legislation and patent practice.
The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes will occur to those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for automatically generating CAN message analysis codes is characterized by comprising the following steps:
collecting CAN message signals;
dividing the collected CAN message signals to obtain different types of messages;
based on the distribution of the CAN message signals in the message, the parameters of the CAN message signals are obtained,
acquiring the mobile information of the CAN message signal based on the parameter of the CAN message signal;
and based on the mobile information of the CAN message signal, converting the original value of the CAN message signal into an actual physical value, and realizing the analysis of the CAN message.
2. The method for automatically generating CAN message analysis codes according to claim 1, wherein the collected CAN message signals are divided to obtain different types of messages, specifically: in the collected CAN message signals, the CAN message signals with the same message ID are divided into a group; the message IDs have different types, and CAN message signals are divided to obtain different types of messages.
3. The method of automatically generating CAN message parsing codes of claim 2, wherein the parameters of the CAN message signal include start bit, length, precision and offset of the signal.
4. The method of automatically generating CAN message resolution codes according to claim 3, wherein the mobility information of the CAN message signal comprises: signal occupied byte, shift direction, shift length and bit fetch length.
5. The method of automatically generating a CAN message analytic code according to claim 4, wherein the original value of the CAN message signal is a binary number of a certain length; acquiring an original value of the CAN message signal based on the CAN message signal parameter;
the converting the original value of the CAN message signal into an actual physical value specifically includes: the CAN message signal comprises a motor torque signal, and the motor torque signal is positioned in a third byte and a fourth byte; the original value of the motor torque signal is converted into an actual physical value as follows:
MotTorque=(uint16(byte[4])<<8+uint16(byte[3]))*scale+offset
wherein MotTorque is the variable name of the motor torque in the program, scale is the motor torque signal precision, offset is the offset, and uint16 is 16-bit unsigned integer; byte [3] is the third byte and byte [4] is the fourth byte.
6. The method of automatically generating CAN message parsing codes of claim 5, wherein the CAN message is formed of 64-bit binary numbers, 8-bit binary numbers forming one byte, 8 bytes forming one frame CAN message.
7. The method according to claim 6, wherein said CAN packet parsing file is a C language file with extensions of x.c and x.h.
8. A system for automatically generating CAN message analysis codes is characterized by comprising:
the acquisition module is used for acquiring CAN message signals;
the dividing module is used for dividing the collected CAN message signals to acquire different types of messages;
a first acquisition module, which is distributed in the message based on the CAN message signal to acquire the parameter of the CAN message signal,
the second acquisition module acquires the mobile information of the CAN message signal based on the parameter of the CAN message signal;
and the conversion module converts the original value of the CAN message signal into an actual physical value based on the mobile information of the CAN message signal, so as to realize the analysis of the CAN message.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1-7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 8.
CN202211196899.XA 2022-09-28 2022-09-28 Method, system, device and medium for automatically generating CAN message analysis code Pending CN115695589A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211196899.XA CN115695589A (en) 2022-09-28 2022-09-28 Method, system, device and medium for automatically generating CAN message analysis code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211196899.XA CN115695589A (en) 2022-09-28 2022-09-28 Method, system, device and medium for automatically generating CAN message analysis code

Publications (1)

Publication Number Publication Date
CN115695589A true CN115695589A (en) 2023-02-03

Family

ID=85063839

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211196899.XA Pending CN115695589A (en) 2022-09-28 2022-09-28 Method, system, device and medium for automatically generating CAN message analysis code

Country Status (1)

Country Link
CN (1) CN115695589A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117155422A (en) * 2023-09-14 2023-12-01 慧勒智行汽车技术(昆山)有限公司 CAN signal receiving and transmitting method and system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117155422A (en) * 2023-09-14 2023-12-01 慧勒智行汽车技术(昆山)有限公司 CAN signal receiving and transmitting method and system
CN117155422B (en) * 2023-09-14 2024-04-02 慧勒智行汽车技术(昆山)有限公司 CAN signal receiving and transmitting method and system

Similar Documents

Publication Publication Date Title
CN108600192B (en) Regular expression based DBC file analysis and message analysis method
CN115695589A (en) Method, system, device and medium for automatically generating CAN message analysis code
CN111008230A (en) Data storage method and device, computer equipment and storage medium
CN111240688A (en) excel file analysis method and device, computer equipment and storage medium
CN111629081A (en) Internet protocol IP address data processing method and device and electronic equipment
CN111447257A (en) Message conversion method and device
CN101288071A (en) Method and computer unit for determining computer service names
CN113642300A (en) Report generation method and device, electronic equipment and computer readable medium
CN113438211A (en) DBC format analysis and message analysis method, device, electronic equipment and medium
CN116634042A (en) Big data message analysis method, device and storage medium
CN113485282B (en) Message tracking display method, system, equipment and storage medium for distributed control system
CN114329090A (en) Path reference searching method and device, electronic equipment and storage medium
CN113032358B (en) Water affair data processing method and device and terminal equipment
CN112162951A (en) Information retrieval method, server and storage medium
CN112699111A (en) Report generation method and device, electronic equipment and computer readable medium
CN1567829A (en) General purpose data file conversion method
CN114385540B (en) Data unit conversion method and device
CN115048108A (en) Method, system, equipment and storage medium for automatically generating codes
CN113608889B (en) Message data processing method, device, equipment and storage medium
CN115967604A (en) Message transmission method and device, electronic equipment and computer readable storage medium
CN113296827A (en) Method and device for converting different languages and terminal equipment
CN118400443B (en) Electric energy meter data conversion method and device, computer equipment and storage medium
CN112329393A (en) Method, equipment and storage medium for generating short code ID
CN114679504B (en) UDP message parsing method and device and computer equipment
CN110881002B (en) Electronic red packet monitoring method and device and terminal equipment

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