CN117155422B - CAN signal receiving and transmitting method and system - Google Patents

CAN signal receiving and transmitting method and system Download PDF

Info

Publication number
CN117155422B
CN117155422B CN202311182170.1A CN202311182170A CN117155422B CN 117155422 B CN117155422 B CN 117155422B CN 202311182170 A CN202311182170 A CN 202311182170A CN 117155422 B CN117155422 B CN 117155422B
Authority
CN
China
Prior art keywords
signal
transmitted
signals
sent
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.)
Active
Application number
CN202311182170.1A
Other languages
Chinese (zh)
Other versions
CN117155422A (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.)
Huile Zhixing Automotive Technology Kunshan Co ltd
Original Assignee
Huile Zhixing Automotive Technology Kunshan 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 Huile Zhixing Automotive Technology Kunshan Co ltd filed Critical Huile Zhixing Automotive Technology Kunshan Co ltd
Priority to CN202311182170.1A priority Critical patent/CN117155422B/en
Publication of CN117155422A publication Critical patent/CN117155422A/en
Application granted granted Critical
Publication of CN117155422B publication Critical patent/CN117155422B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04BTRANSMISSION
    • H04B1/00Details of transmission systems, not covered by a single one of groups H04B3/00 - H04B13/00; Details of transmission systems not characterised by the medium used for transmission
    • H04B1/38Transceivers, i.e. devices in which transmitter and receiver form a structural unit and in which at least one part is used for functions of transmitting and receiving
    • H04B1/40Circuits
    • H04B1/44Transmit/receive switching

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention discloses a CAN signal receiving and transmitting method and a system, which relate to the technical field of CAN signal processing, wherein the CAN signal receiving and transmitting method comprises the following steps: analyzing an expression in the json file; selecting CAN signals corresponding to the current interface from the received CAN signals; carrying out signal analysis on the CAN signal corresponding to the current interface, and storing the signal name and the signal value obtained by analysis into a first hash table; traversing the first hash table, and substituting signal values corresponding to the expressions into the expressions; modifying the control state of the current interface according to the result whether the expression is true after substituting the corresponding signal values; judging whether the CAN signals to be transmitted are periodically transmitted or not for each CAN signal to be transmitted; if yes, extracting CAN signals to be transmitted from the corresponding array, and transmitting the CAN signals according to the corresponding cycle period; if not, a default signal is sent. The invention reduces the complexity and improves the program operation efficiency.

Description

CAN signal receiving and transmitting method and system
Technical Field
The invention relates to the technical field of CAN signal processing, in particular to a CAN signal receiving and transmitting method and a system.
Background
With the rapid progress of new generation information technology, artificial intelligence, sensors, integrated circuits and other technologies, the global automobile industry is in a deep revolution period, the intellectualization and networking become a new strategy high point of the automobile industry, and the automobile intelligent driving test industry is emerging under the background. At present, the intelligent driving test industry is still in the primary stage, and there are more problems and very big promotion space.
From the overall development of the automobile industry, advanced Driving Assistance Systems (ADAS) will be the standard function of automobiles in the future, and also considered as the first step in automatic driving, intelligent driving functions and ADAS are also gaining market acceptance.
From the perspective of automobile research and development, an autopilot domain (intelligent driving domain) becomes one of five functional domains of an entire automobile, and is increasingly valued, the number and complexity of corresponding functions are rapidly increased, and the test technical requirements on the intelligent driving domain are also increased year by year.
At present, research and development of intelligent driving domain test products in the intelligent driving domain test field becomes an important development direction of companies in various related fields, and CAN signals serve as key data sources and communication bases for realizing various functions in an intelligent driving system, so that research and development of processing technologies of the CAN signals occupy an important proportion in the development process of the intelligent driving domain test products.
The implementation of the intelligent driving function test technology mainly relates to three technical points of CAN signal receiving, CAN signal analyzing and CAN signal transmitting.
CAN signal reception:
the traditional CAN signal receiving logic is that after a program receives a CAN signal sent by a vehicle, the signal is analyzed, and the analyzed signal name and value are transmitted through a data stream. These values are subject to multiple levels of filtering and are processed before being transmitted to the page. The page can carry out logic judgment according to the received data, and the state of the page control is changed correspondingly.
However, this approach has some disadvantages. First, the level through which the signals pass is excessive, resulting in an increase in complexity of program logic, making subsequent maintenance work difficult. Secondly, the state of the page control is not decoupled from the signal logic, meaning that subsequent maintenance work is also faced with a certain difficulty. Finally, adaptation to different vehicle models is also difficult to achieve.
CAN signal transmission:
after the conventional CAN transmit logic transmits signals for the program, a complete signal array for transmission is finally formed from the initial signal name and value to the final combination.
This technique can result in intermediate processing being overly complex. In addition, the number of hash tables used in signal combining is excessive, and the definition of each hash table is not well defined, resulting in difficulty in post-maintenance.
In addition to the above problems, the transmission of signals requires a special requirement: each transmitted signal message has a fixed number of cycles and time period. After the fixed number of times of sending according to the time period, a certain signal in the message needs to be set back to a default value, and the sending is continued according to the time period. However, there are potential problems with the way this part of the requirements is handled in the code: the same thread is used to handle different time periods, resulting in logic confusion. If different time periods appear later, a large amount of code modification is needed, and errors such as out-of-range and the like are easy to occur.
CAN signal analysis:
the conventional CAN signal parsing logic is a method of string concatenation, which is usually used when data (receiving) of a specific signal in a message is required to be acquired or the signals are combined into a signal array (transmitting) recognizable by a vehicle.
However, this approach has a major impact on the running efficiency of the program, mainly involving the following aspects:
(1) In Java, the string is immutable, meaning that each time a string splice is made, a new string object is created. If character strings are spliced frequently in a cycle, a large number of temporary character strings are created and destroyed, the burden of garbage collection is increased, and additional performance overhead is generated.
(2) String concatenation can result in frequent memory allocation and copy operations. Each time a string splice is made, the original string and the new string content need to be copied into a new string object, which is a costly operation. If a large number of character strings are spliced in a loop, a large amount of CPU resources and memory resources are consumed.
(3) Each time a string splice is made, a new intermediate result is generated. When the spliced character strings are longer or the number of times of circulation is more, a large number of intermediate results are generated, and a large amount of memory is occupied.
Disclosure of Invention
The invention aims to provide a CAN signal receiving and transmitting method and system, which reduce complexity and improve program operation efficiency.
In order to achieve the above object, the present invention provides the following solutions:
a CAN signal receiving and transmitting method comprises the following steps:
analyzing an expression in the json file;
selecting CAN signals corresponding to the current interface from the received CAN signals;
carrying out signal analysis on the CAN signal corresponding to the current interface, and storing the signal name and the signal value obtained by analysis into a first hash table;
traversing the first hash table, and substituting a signal value corresponding to the expression into the expression;
modifying the control state of the current interface according to the result whether the expression is true after being substituted into each corresponding signal value;
different CAN signals to be sent are put into an array corresponding to the cycle period of each CAN signal to be sent;
judging whether each CAN signal to be transmitted is periodically transmitted or not;
if the CAN signals to be transmitted are transmitted periodically, extracting the CAN signals to be transmitted from the corresponding array, and transmitting the CAN signals to be transmitted for corresponding times according to the corresponding cycle period;
if not, a default signal is sent.
Optionally, signal analysis is performed on the CAN signal corresponding to the current interface, and a signal name and a signal value obtained by the analysis are stored in a first hash table, which specifically includes:
performing matrix coordinate conversion on the received CAN signals to obtain converted received signals;
determining the starting position of the CAN signal corresponding to the current interface according to the converted received signal;
determining construction data according to the signal length of the CAN signal corresponding to the current interface;
determining the left shift bit number according to the starting position of the CAN signal corresponding to the current interface, and recording the left shift bit number as a first bit number;
after the construction data is shifted left according to the first bit number, carrying out logical AND operation on the construction data and the converted received signal;
right-shifting the data after the logical AND operation according to the first bit number;
and intercepting the data of the signal length from the right end of the right shifted data to obtain an analyzed signal value.
Optionally, performing matrix coordinate conversion on the received CAN signal to obtain a received signal after matrix coordinate conversion, which specifically includes:
performing matrix coordinate conversion on the received CAN signals by adopting a conversion matrix to obtain received signals after matrix coordinate conversion;
wherein the transformation matrix is expressed as x0= { -7, -5, -3, -1, 3,5,7}.
Optionally, the CAN signal corresponding to the current interface is screened from the received CAN signals, which specifically comprises:
storing the received CAN signal into a database file;
screening CAN signals corresponding to the client demand form of the current interface from the database file; the client demand table is used for storing signal IDs corresponding to the interfaces.
Optionally, the method further comprises:
performing matrix coordinate conversion on the array to be transmitted to obtain a transmission signal after matrix coordinate conversion;
determining the starting position of the CAN signal to be transmitted according to the converted transmission signal;
determining a mask according to the signal length of the CAN signal to be transmitted;
determining the left shift bit number according to the starting position of the CAN signal to be transmitted, and recording the left shift bit number as a second bit number;
the CAN signals to be sent are moved to the position of the CAN signals to be sent in the array to be sent according to the second number, and the temporary variable is assigned;
and performing logical AND operation on the hash table of the array to be transmitted and the mask, and performing logical OR operation on the negation result and the temporary variable to obtain the array to be transmitted, wherein the array to be transmitted is inserted into the CAN signal to be transmitted.
The invention also discloses a CAN signal receiving and transmitting system, which comprises:
the json file analysis module is used for analyzing the expression in the json file;
the CAN signal screening module is used for screening CAN signals corresponding to the current interface from the received CAN signals;
the CAN signal analysis module is used for carrying out signal analysis on the CAN signal corresponding to the current interface and storing the signal name and the signal value obtained by analysis into the first hash table;
the signal value substituting expression module is used for traversing the first hash table and substituting the signal value corresponding to the expression into the expression;
the control state modifying module is used for modifying the control state of the current interface according to the result whether the expression is established after being substituted into each corresponding signal value;
the CAN signal array allocation module is used for putting different CAN signals to be sent into an array corresponding to the cycle period of each CAN signal to be sent;
the judging module is used for judging whether each CAN signal to be transmitted is periodically transmitted or not;
the periodic sending module is used for extracting the CAN signals to be sent from the corresponding array if the CAN signals to be sent are periodically sent, and sending the CAN signals to be sent for corresponding times according to the corresponding cycle period;
and the default sending module is used for sending a default signal if the periodic sending is not performed.
According to the specific embodiment provided by the invention, the invention discloses the following technical effects:
according to the invention, the CAN signal corresponding to the current interface is subjected to signal analysis, the signal names and the signal values obtained through analysis are stored in the first hash table, the first hash table is traversed, the signal values corresponding to the expressions are substituted into the expressions, and the control state of the current interface is modified according to the result that whether the expressions are substituted into the corresponding signal values or not is established, so that the level of signal passing is reduced, and the program operation efficiency is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the drawings that are needed in the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a CAN signal transceiving method according to an embodiment of the present invention;
fig. 2 is a schematic flow chart II of a CAN signal transceiving method according to an embodiment of the present invention;
fig. 3 is a schematic flow chart of a CAN signal receiving method according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a standard CAN matrix coordinate system;
FIG. 5 is a schematic diagram of a converted CAN matrix coordinate system according to an embodiment of the invention;
fig. 6 is a detailed flowchart of a CAN signal sending method according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a CAN signal processing application provided in an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The invention aims to provide a CAN signal receiving and transmitting method and system, which reduce complexity and improve program operation efficiency.
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
Example 1
As shown in fig. 1 and fig. 2, the method for receiving and sending CAN signals provided in this embodiment specifically includes the following steps:
step 101: the expressions in the json file are parsed.
The step 101 specifically includes: and reading the json file to be analyzed according to the line by means of for-loop traversal, and obtaining a value corresponding to the key according to the key obtained by reading, wherein the key represents a keyword, and the value corresponds to the expression logic. I.e., the expression from parsing the json file.
The contents of the parsed expression are stored in an array.
Step 102: and screening CAN signals corresponding to the current interface from the received CAN signals.
The step 102 specifically includes:
and initializing a CAN (controller area network) path, and receiving CAN signals by adopting the initialized CAN path.
And storing the received CAN signal into a database file.
Screening CAN signals corresponding to the client demand form of the current interface from the database file; and the client demand list is used for storing the signal IDs corresponding to the interfaces, and the CAN signals corresponding to the client demand list of the current interface are screened from the database file according to the signal IDs required by the current interface. The developer has defined the contents of the customer requirements table as the json expression described above.
Step 103: and carrying out signal analysis on the CAN signal corresponding to the current interface, and storing the signal name and the signal value obtained by analysis into a first hash table.
Step 103 specifically includes:
and performing matrix coordinate conversion on the received CAN signals to obtain converted received signals.
And determining the starting position of the CAN signal corresponding to the current interface according to the converted received signal.
And determining the construction data according to the signal length of the CAN signal corresponding to the current interface.
And determining the left shift bit number according to the starting position of the CAN signal corresponding to the current interface, and recording the left shift bit number as the first bit number.
And after the construction data is shifted left according to the first bit number, performing logical AND operation with the converted received signal.
The logical AND operation data is shifted right by the first number of bits.
And intercepting the data of the signal length from the right end of the right shifted data to obtain an analyzed signal value.
The position of the signal message represents the signal name, and the data of the signal length bit at the corresponding position is the signal value.
Examples of definitions for signal names and signal values in the matrix table: a signal message is a 64-bit array, the signal A corresponds to bits 1-4, the signal B corresponds to bits 17-19, the data of the signal length bits intercepted in the parsing operation is the signal value, and the position corresponding to the interception is the signal name.
Performing matrix coordinate conversion on the received CAN signal to obtain a received signal after matrix coordinate conversion, wherein the method specifically comprises the following steps of: and performing matrix coordinate conversion on the received CAN signals by adopting a conversion matrix to obtain the received signals after matrix coordinate conversion.
Wherein the transformation matrix is expressed as x0= { -7, -5, -3, -1, 3,5,7}.
Step 104: traversing the first hash table, and substituting signal values corresponding to the expression into the expression.
Step 105: and modifying the control state of the current interface according to the result whether the expression is true after being substituted into each corresponding signal value.
Step 106: and placing different CAN signals to be sent into an array corresponding to the cycle period of each CAN signal to be sent.
Step 107: and judging whether each CAN signal to be transmitted is periodically transmitted or not.
Step 108: and if the CAN signals are periodically transmitted, extracting the CAN signals to be transmitted from the corresponding array, and transmitting the CAN signals to be transmitted for corresponding times according to the corresponding cycle period.
Step 109: if not, a default signal is sent.
Steps 101 to 105 are a CAN signal receiving method, and a specific flow is shown in fig. 3. Steps 106 to 109 are a CAN signaling method, and a specific flow is shown in fig. 6.
The invention also comprises the steps of analyzing the array to be transmitted, inserting the CAN signal to be transmitted into the array to be transmitted, and specifically comprises the following steps:
and performing matrix coordinate conversion on the array to be transmitted to obtain a transmission signal after matrix coordinate conversion.
And determining the starting position of the CAN signal to be transmitted according to the converted transmission signal.
And determining a mask according to the signal length of the CAN signal to be transmitted.
And determining the left shift bit number according to the starting position of the CAN signal to be transmitted, and recording the left shift bit number as a second bit number.
And (3) moving the CAN signal to be transmitted to the position of the CAN signal to be transmitted in the array to be transmitted according to the second bit number, and assigning the value to the temporary variable.
And performing logical AND operation on the hash table of the array to be transmitted and the mask, and performing logical OR operation on the negation result and the temporary variable to obtain the array to be transmitted, wherein the array to be transmitted is inserted into the CAN signal to be transmitted.
As shown in fig. 3, when a user switches to a certain interface, the signal ID required by the current interface is transmitted to an analysis method, the analysis method traverses the received signal ID and the transmitted signal ID, if the signal ID is required, the message is analyzed, the analyzed signal name and signal value are stored in a resolveMap array (first hash table), the contents in the jConext (expression object) are modified by traversing the data of the first hash table, namely, the data of the first hash table is substituted into the expression, expression calculation is performed according to program setting, the calculation result is stored in a second hash table (finalMap) and is transmitted by using a data stream, and the page receives the data through the data stream, so that the control state is modified.
The analysis of CAN signals mainly includes two parts: receiving parsing and transmitting parsing. Before analysis, for the convenience of calculation, the matrix coordinate system is transformed, and the following specific transformation modes are as follows:
and a character string splicing mode is replaced by bit operation. The change greatly improves the running efficiency of the program and successfully solves the problems of overhigh memory occupation and the like in the old version.
Both the receiving and transmitting of the program are based on a fixed matrix coordinate system, which is converted for ease of calculation into a common matrix coordinate system as shown in fig. 5 for ease of understanding.
The matrix is converted to x0= { -7, -5, -3, -1, 3,5,7}.
Calculating the column of the original starting position; y=7- (original starting position% 8), where y is the column number and% is the remainder operation.
The starting position after transformation is: original start position + conversion matrix.
In CAN signal reception, after the program filters the signal ID required by the current interface, the signal ID and the message required to be analyzed are transmitted into an analysis method, and the message is analyzed into a specific signal name and value according to the definition of a database and the analysis method described below so as to be used for the calculation of a subsequent expression.
After the matrix coordinate conversion is completed, a certain signal in the message is intercepted in a bit operation mode according to the initial position and the signal length, and then converted into a specific signal value. The specific steps are as follows:
a: the number of bits that the construction data needs to be shifted left (number of bits shifted left=64-start position after conversion-signal length) is calculated and assigned to the variable shlBit.
b: the construction data is shifted left by the shlBit bit (the purpose of this operation is to extract the required value in the original data by a logical and operation).
c: the construction data is bitwise logically anded with the original data (this operation is intended to remove the data prior to the current signal position of the original data).
d: and shifting the fetched data to the right by the shlBit bit, and removing redundant bit numbers.
Examples: a CAN signal array is 64 bits, a certain CAN signal to be extracted is at the 59 th bit of the array, the signal length is 3, the construction data is 111, then the data is shifted left, 111+3 data of 0 are obtained, and the data and the 64 bit signal array are subjected to logical AND operation, so that the 59 th bit to the 61 th bit data CAN be extracted, and the calculation is convenient.
The 59 th bit is a position where the matrix coordinate conversion is not performed, and the coordinate conversion is required to be performed first to calculate the left shift number. The calculation method is as follows:
the original start position is in the column: y=7- (59% 8) =4;
the corresponding conversion matrix x0= -1;
start position after conversion: 59-1=58;
left shift number=64-58-3=3.
The transmitting array includes a plurality of signal messages, and each signal message includes a plurality of CAN signals.
In CAN signal transmission, a signal name and a signal value are transmitted by clicking a transmitting button, a signal message where the CAN signal is located, a signal starting position and a signal length are required to be queried in a transmitting array through the signal name, then the signal value is converted into corresponding digits, and the digits are combined into an array and then transmitted. The specific steps are as follows:
a: the number of bits that need to be left shifted (left shifted number = 64-start position after conversion-signal length) to construct the mask is calculated and assigned to the variable shlBit.
b: a mask is constructed (the mask is used to facilitate setting back the default value after the end of the cycle): and determining a construction mask according to the signal length of the CAN signal to be transmitted.
c: and (3) leftwards moving the data to be transmitted to the position of the CAN signal to be transmitted, and assigning the data to the variable tempData, wherein tempdata=leftwards moving the data to be transmitted to the position of the CAN signal to be transmitted.
d: the message ID corresponding to the signal name is obtained from the hash table (if not, it is manually checked whether it is defined in the database). The purpose of the message ID is to determine in which CAN signal message the signal name should be placed.
e: the hash table storing the transmitted data is inverted by the bit logic and the mask, and then is subjected to bit logic or tempData. The hash table stores transmission data, after initialization, the hash table stores default data to be transmitted, and when signals need to be transmitted, the data are calculated according to the steps and then transmitted.
The CAN signal to be sent is converted into a sending array, the sending array is put into different arrays according to the cycle time of the CAN signal to be sent, whether the CAN signal to be sent is periodically sent or not is judged according to the requirement of a customer, and if the CAN signal to be sent is the periodic sending signal, the cycle times are judged according to the cycle logic until the signal sending is finished. If the signal is transmitted aperiodically, a default signal is transmitted.
And each CAN signal to be transmitted has fixed cycle times according to the definition of the demand table, and if the cycle times are transmitted, the CAN signal is periodically transmitted, otherwise, the CAN signal is not periodically transmitted. Periodic transmission refers to whether the number of cycles of a signal is specified.
Example 2
The CAN signal receiving and transmitting system provided by the embodiment comprises:
and the json file analysis module is used for analyzing the expression in the json file.
And the CAN signal screening module is used for screening CAN signals corresponding to the current interface from the received CAN signals.
And the CAN signal analysis module is used for carrying out signal analysis on the CAN signal corresponding to the current interface, and storing the signal name and the signal value obtained by analysis into the first hash table.
And the signal value substitution expression module is used for traversing the first hash table and substituting the signal value corresponding to the expression into the expression.
And the control state modifying module is used for modifying the control state of the current interface according to the result whether the expression is established after being substituted into each corresponding signal value.
The CAN signal array distribution module is used for placing different CAN signals to be transmitted into an array corresponding to the cycle period of each CAN signal to be transmitted.
The judging module is used for judging whether the CAN signals to be transmitted are periodically transmitted or not for each CAN signal to be transmitted.
And the periodic transmission module is used for extracting the CAN signals to be transmitted from the corresponding array if the CAN signals are transmitted periodically, and transmitting the CAN signals to be transmitted for corresponding times according to the corresponding cycle period.
And the default sending module is used for sending a default signal if the periodic sending is not performed.
The actual application of the CAN signal processing method (comprising the CAN signal receiving method and the CAN signal transmitting method) is shown in fig. 7, and the effect display of the intelligent driving function is realized through the CAN signal processing technology, so that intelligent driving testers are helped to verify the correctness of the intelligent driving function signals. Mainly realize the control to the automatic driving auxiliary function of vehicle, include: the intelligent driving selection, lane changing mode selection, intelligent lane changing assistance, driving safety assistance and other functions, namely the CAN signal received and transmitted by the intelligent driving control system is a CAN signal for controlling the automatic driving assistance function of the vehicle.
The invention has the following technical effects:
1. CAN signal reception: the signal transmission level is simplified, and the logic complexity is reduced; the page control state is logically separated from the signal, so that subsequent maintenance is facilitated, and technical support is provided for subsequent support adaptation to different vehicle types.
2. CAN signal transmission aspect: simplifying the signaling hierarchy, reducing the logic complexity: the page control state is logically separated from the signal, so that subsequent maintenance is facilitated, and technical support is provided for subsequent support adaptation to different vehicle types; the special requirement of CAN signal transmission, namely the problem of processing different time periods of each signal, is solved by adopting a reasonable algorithm.
3. CAN signal analysis: and a character string splicing mode is replaced by a high-quality algorithm, so that the problems of overhigh memory occupation and the like are solved, and the program operation efficiency is improved.
In the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
The principles and embodiments of the present invention have been described herein with reference to specific examples, the description of which is intended only to assist in understanding the methods of the present invention and the core ideas thereof; also, it is within the scope of the present invention to be modified by those of ordinary skill in the art in light of the present teachings. In view of the foregoing, this description should not be construed as limiting the invention.

Claims (3)

1. A CAN signal transceiving method, comprising:
analyzing an expression in the json file;
selecting CAN signals corresponding to the current interface from the received CAN signals;
carrying out signal analysis on the CAN signal corresponding to the current interface, and storing the signal name and the signal value obtained by analysis into a first hash table;
traversing the first hash table, and substituting a signal value corresponding to the expression into the expression;
modifying the control state of the current interface according to the result whether the expression is true after being substituted into each corresponding signal value;
different CAN signals to be sent are put into an array corresponding to the cycle period of each CAN signal to be sent;
judging whether each CAN signal to be transmitted is periodically transmitted or not;
if the CAN signals to be transmitted are transmitted periodically, extracting the CAN signals to be transmitted from the corresponding array, and transmitting the CAN signals to be transmitted for corresponding times according to the corresponding cycle period;
if the transmission is not periodic, transmitting a default signal;
the CAN signal corresponding to the current interface is subjected to signal analysis, and the signal name and the signal value obtained through analysis are stored in a first hash table, and the method specifically comprises the following steps:
performing matrix coordinate conversion on the received CAN signals to obtain converted received signals;
determining the starting position of the CAN signal corresponding to the current interface according to the converted received signal;
determining construction data according to the signal length of the CAN signal corresponding to the current interface; constructing data as all 1 data with the number of bits being the signal length of the CAN signal;
determining the left shift bit number according to the starting position of the CAN signal corresponding to the current interface, and recording the left shift bit number as a first bit number;
after the construction data is shifted left according to the first bit number, carrying out logical AND operation on the construction data and the converted received signal;
right-shifting the data after the logical AND operation according to the first bit number;
intercepting the data of the signal length from the right end of the right shifted data to obtain an analyzed signal value;
the position of the signal message represents the signal name, and the data of the signal length bit at the corresponding position is a signal value;
performing matrix coordinate conversion on the received CAN signal to obtain a received signal after matrix coordinate conversion, wherein the method specifically comprises the following steps of: performing matrix coordinate conversion on the received CAN signals by adopting a conversion matrix to obtain received signals after matrix coordinate conversion;
wherein the transformation matrix is expressed as x0= { -7, -5, -3, -1, 3,5,7};
calculating the column of the original starting position; y=7- (original starting position% 8), where y is the column number,% is the remainder operation;
the starting position after transformation is: original starting position + conversion matrix;
after the matrix coordinate conversion is completed, a certain signal in the message is intercepted in a bit operation mode according to the initial position and the signal length, and then converted into a specific signal value, wherein the specific steps are as follows:
a: calculating the bit number to be shifted left of the construction data and assigning the bit number to a variable shlBit; left shift number = 64-post conversion start position-signal length;
b: shifting the construction data left by a shlBit bit;
c: constructing data and original data to perform bit logic AND operation;
d: shifting the acquired data to the right by shlBit bits, and removing redundant bits;
different CAN signals to be sent are put into an array corresponding to the cycle period of each CAN signal to be sent, and the method specifically comprises the following steps:
performing matrix coordinate conversion on the array to be transmitted to obtain a transmission signal after matrix coordinate conversion;
determining the starting position of the CAN signal to be transmitted according to the converted transmission signal;
determining a mask according to the signal length of the CAN signal to be transmitted;
determining the left shift bit number according to the starting position of the CAN signal to be transmitted, and recording the left shift bit number as a second bit number;
the CAN signals to be sent are moved to the position of the CAN signals to be sent in the array to be sent according to the second number, and the temporary variable is assigned;
performing logical AND operation on the hash table of the array to be transmitted and the mask, and performing logical OR operation on the negation result and the temporary variable to obtain the array to be transmitted, wherein the array to be transmitted is inserted into the CAN signal to be transmitted;
the array to be transmitted comprises a plurality of signal messages, and each signal message comprises a plurality of CAN signals;
for each CAN signal to be sent, judging whether the CAN signal to be sent is periodically sent or not, specifically comprising: each CAN signal to be transmitted has fixed cycle times according to the definition of the demand table, if the cycle times are transmitted, the CAN signal is periodically transmitted, otherwise, the CAN signal is not transmitted; periodic transmission refers to whether the number of cycles of a signal is specified.
2. The CAN signal transceiving method according to claim 1, wherein a CAN signal corresponding to a current interface is selected from received CAN signals, comprising:
storing the received CAN signal into a database file;
screening CAN signals corresponding to the client demand form of the current interface from the database file; the client demand table is used for storing signal IDs corresponding to the interfaces.
3. A CAN signal transceiver system comprising:
the json file analysis module is used for analyzing the expression in the json file;
the CAN signal screening module is used for screening CAN signals corresponding to the current interface from the received CAN signals;
the CAN signal analysis module is used for carrying out signal analysis on the CAN signal corresponding to the current interface and storing the signal name and the signal value obtained by analysis into the first hash table;
the signal value substituting expression module is used for traversing the first hash table and substituting the signal value corresponding to the expression into the expression;
the control state modifying module is used for modifying the control state of the current interface according to the result whether the expression is established after being substituted into each corresponding signal value;
the CAN signal array allocation module is used for putting different CAN signals to be sent into an array corresponding to the cycle period of each CAN signal to be sent;
the judging module is used for judging whether each CAN signal to be transmitted is periodically transmitted or not;
the periodic sending module is used for extracting the CAN signals to be sent from the corresponding array if the CAN signals to be sent are periodically sent, and sending the CAN signals to be sent for corresponding times according to the corresponding cycle period;
the default sending module is used for sending a default signal if the periodic sending is not performed;
the CAN signal corresponding to the current interface is subjected to signal analysis, and the signal name and the signal value obtained through analysis are stored in a first hash table, and the method specifically comprises the following steps:
performing matrix coordinate conversion on the received CAN signals to obtain converted received signals;
determining the starting position of the CAN signal corresponding to the current interface according to the converted received signal;
determining construction data according to the signal length of the CAN signal corresponding to the current interface; constructing data as all 1 data with the number of bits being the signal length of the CAN signal;
determining the left shift bit number according to the starting position of the CAN signal corresponding to the current interface, and recording the left shift bit number as a first bit number;
after the construction data is shifted left according to the first bit number, carrying out logical AND operation on the construction data and the converted received signal;
right-shifting the data after the logical AND operation according to the first bit number;
intercepting the data of the signal length from the right end of the right shifted data to obtain an analyzed signal value;
the position of the signal message represents the signal name, and the data of the signal length bit at the corresponding position is a signal value;
performing matrix coordinate conversion on the received CAN signal to obtain a received signal after matrix coordinate conversion, wherein the method specifically comprises the following steps of: performing matrix coordinate conversion on the received CAN signals by adopting a conversion matrix to obtain received signals after matrix coordinate conversion;
wherein the transformation matrix is expressed as x0= { -7, -5, -3, -1, 3,5,7};
calculating the column of the original starting position; y=7- (original starting position% 8), where y is the column number,% is the remainder operation;
the starting position after transformation is: original starting position + conversion matrix;
after the matrix coordinate conversion is completed, a certain signal in the message is intercepted in a bit operation mode according to the initial position and the signal length, and then converted into a specific signal value, wherein the specific steps are as follows:
a: calculating the bit number to be shifted left of the construction data and assigning the bit number to a variable shlBit; left shift number = 64-post conversion start position-signal length;
b: shifting the construction data left by a shlBit bit;
c: constructing data and original data to perform bit logic AND operation;
d: shifting the acquired data to the right by shlBit bits, and removing redundant bits;
different CAN signals to be sent are put into an array corresponding to the cycle period of each CAN signal to be sent, and the method specifically comprises the following steps:
performing matrix coordinate conversion on the array to be transmitted to obtain a transmission signal after matrix coordinate conversion;
determining the starting position of the CAN signal to be transmitted according to the converted transmission signal;
determining a mask according to the signal length of the CAN signal to be transmitted;
determining the left shift bit number according to the starting position of the CAN signal to be transmitted, and recording the left shift bit number as a second bit number;
the CAN signals to be sent are moved to the position of the CAN signals to be sent in the array to be sent according to the second number, and the temporary variable is assigned;
performing logical AND operation on the hash table of the array to be transmitted and the mask, and performing logical OR operation on the negation result and the temporary variable to obtain the array to be transmitted, wherein the array to be transmitted is inserted into the CAN signal to be transmitted;
the array to be transmitted comprises a plurality of signal messages, and each signal message comprises a plurality of CAN signals;
for each CAN signal to be sent, judging whether the CAN signal to be sent is periodically sent or not, specifically comprising: each CAN signal to be transmitted has fixed cycle times according to the definition of the demand table, if the cycle times are transmitted, the CAN signal is periodically transmitted, otherwise, the CAN signal is not transmitted; periodic transmission refers to whether the number of cycles of a signal is specified.
CN202311182170.1A 2023-09-14 2023-09-14 CAN signal receiving and transmitting method and system Active CN117155422B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311182170.1A CN117155422B (en) 2023-09-14 2023-09-14 CAN signal receiving and transmitting method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311182170.1A CN117155422B (en) 2023-09-14 2023-09-14 CAN signal receiving and transmitting method and system

Publications (2)

Publication Number Publication Date
CN117155422A CN117155422A (en) 2023-12-01
CN117155422B true CN117155422B (en) 2024-04-02

Family

ID=88900599

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311182170.1A Active CN117155422B (en) 2023-09-14 2023-09-14 CAN signal receiving and transmitting method and system

Country Status (1)

Country Link
CN (1) CN117155422B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115167368A (en) * 2022-08-02 2022-10-11 广州路派电子科技有限公司 Method and system for converting and outputting automobile CAN data
CN115695589A (en) * 2022-09-28 2023-02-03 西安法士特汽车传动有限公司 Method, system, device and medium for automatically generating CAN message analysis code
CN115712537A (en) * 2022-10-31 2023-02-24 东风汽车集团股份有限公司 Low-cost vehicle controller CAN signal simulation system
CN116204477A (en) * 2021-11-30 2023-06-02 博泰车联网科技(上海)股份有限公司 CAN signal analysis method, CAN signal generation method, CAN signal analysis equipment and storage medium
WO2023110478A1 (en) * 2021-12-13 2023-06-22 Continental Automotive Technologies GmbH Method for automatically exploring states and transitions of a human machine interface (hmi) device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11780389B2 (en) * 2019-12-13 2023-10-10 Ut-Battelle, Llc Controller area network decoder (CAN-D)

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116204477A (en) * 2021-11-30 2023-06-02 博泰车联网科技(上海)股份有限公司 CAN signal analysis method, CAN signal generation method, CAN signal analysis equipment and storage medium
WO2023110478A1 (en) * 2021-12-13 2023-06-22 Continental Automotive Technologies GmbH Method for automatically exploring states and transitions of a human machine interface (hmi) device
CN115167368A (en) * 2022-08-02 2022-10-11 广州路派电子科技有限公司 Method and system for converting and outputting automobile CAN data
CN115695589A (en) * 2022-09-28 2023-02-03 西安法士特汽车传动有限公司 Method, system, device and medium for automatically generating CAN message analysis code
CN115712537A (en) * 2022-10-31 2023-02-24 东风汽车集团股份有限公司 Low-cost vehicle controller CAN signal simulation system

Also Published As

Publication number Publication date
CN117155422A (en) 2023-12-01

Similar Documents

Publication Publication Date Title
CN110515973B (en) Data query optimization method, device, equipment and storage medium
US20080320031A1 (en) Method and device for analyzing an expression to evaluate
US20040003067A1 (en) System and method for enabling a user interface with GUI meta data
US20020002566A1 (en) Transfromation of marked up documents using a base architecture
CN106407170A (en) Rapid generation method and system for data report
CN110866029B (en) sql statement construction method, device, server and readable storage medium
US20110225273A1 (en) Method and apparatus for re-generating configuration commands of a network device using an object-based approach
CN117155422B (en) CAN signal receiving and transmitting method and system
CN108984178B (en) Communication method and device
CN114218394A (en) Knowledge visualization development method and system for data visualization large screen
CN110245311B (en) Local page dynamic rendering method and device
CN102486731B (en) Strengthen the visualization method of the call stack of software of software, equipment and system
CN108090034B (en) Cluster-based uniform document code coding generation method and system
CN115827676A (en) SQL sub-query execution method, device, terminal equipment and medium
US11194966B1 (en) Management of concepts and intents in conversational systems
CN114328525A (en) Data processing method and device
CN112269958A (en) Method for realizing difference algorithm for rapidly rendering virtual DOM in browser
Ghica et al. Local reasoning for robust observational equivalence
CN109388371A (en) A kind of sort method of data, system, association's processing unit and primary processing unit
US20140214748A1 (en) Incremental dfa compilation with single rule granularity
JP2015161983A (en) Source code generation device
Anisimov et al. On compositionality and petri nets in protocol engineering
CN116069669B (en) Full-automatic distributed consistency analysis method, system, equipment and storage medium
CN114064835B (en) Multi-source vector road network updating method based on change point detection and electronic equipment
CN112559326B (en) Fusion calibration testing method and device, vehicle-mounted system and vehicle

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
GR01 Patent grant
GR01 Patent grant