CN109861949B - Message filtering method and device and electronic equipment - Google Patents
Message filtering method and device and electronic equipment Download PDFInfo
- Publication number
- CN109861949B CN109861949B CN201711243609.1A CN201711243609A CN109861949B CN 109861949 B CN109861949 B CN 109861949B CN 201711243609 A CN201711243609 A CN 201711243609A CN 109861949 B CN109861949 B CN 109861949B
- Authority
- CN
- China
- Prior art keywords
- sequence
- message
- truth table
- table corresponding
- values
- 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
Links
Images
Landscapes
- Computer And Data Communications (AREA)
Abstract
The application provides a message filtering method, a message filtering device and electronic equipment, wherein the message filtering method comprises the following steps: receiving a message; splitting a sequence corresponding to the message identifier of the message into a first sequence and a second sequence; inquiring a truth table corresponding to the first sequence to obtain a value corresponding to the first sequence, and inquiring a truth table corresponding to the second sequence to obtain a value corresponding to the second sequence; and carrying out bitwise AND calculation on the value corresponding to the first sequence and the value corresponding to the second sequence, and processing the message if the result of the bitwise AND calculation is equal to the second sequence. The method and the device can rapidly determine whether to process the received message according to the message ID, thereby achieving the effect of software filtering, not needing hardware filtering and improving the filtering efficiency.
Description
Technical Field
The present application relates to the field of bus communication technologies, and in particular, to a message filtering method and apparatus, and an electronic device.
Background
With the rapid development of the automobile industry, the design requirements of automobiles in terms of functional types are continuously increased, and more electronic units are applied to automobiles. Various electronic control units on the automobile are all linked to the bus, and signals and data to be exchanged are sent and received through the bus. Among them, the more commonly used type of vehicle-mounted bus is a Controller Area Network (CAN) bus.
Various electronic control units on the automobile are connected to the CAN bus through an external CAN transceiver, and the electronic control units work with the CAN transceiver through an internal CAN controller to send and receive CAN bus messages on the CAN bus. The CAN bus technology clearly defines the data format of CAN bus messages, and each CAN bus message contains a message Identifier (ID) and data information. After receiving the message on the bus through the CAN transceiver, the electronic control unit needs to filter the message.
In the filtering method for the CAN bus messages provided by the prior art, hardware filtering is firstly performed, after the messages after the hardware filtering are received, a numbered message buffer device corresponding to a message ID is placed, an ID information subset is determined according to the number of the message buffer device, and then traversal comparison is performed in the determined ID information subset to determine whether the received messages are messages to be processed, so that the purpose of filtering the CAN bus messages is achieved.
However, in the above method, after receiving the CAN bus message, the message is first filtered by hardware, and then put into the numbered message buffer device corresponding to the message ID, and the hardware filtering increases the use limitation of the method, and if the CAN bus message to be processed has many and irregular message IDs, the hardware filter has a heavier load and cannot process the message; in addition, when the above method performs traversal comparison in the determined ID information subset, if the content of the determined ID information subset is more, the number of traversal comparisons is more, and the filtering efficiency is lower.
Disclosure of Invention
The present application is directed to solving, at least to some extent, one of the technical problems in the related art.
Therefore, a first objective of the present application is to provide a message filtering method to quickly determine whether to process a received message according to a message ID, so as to achieve a software filtering effect, without requiring hardware filtering, and improve filtering efficiency.
A second objective of the present application is to provide a message filtering apparatus.
A third object of the present application is to provide an electronic device.
A fourth object of the present application is to propose a non-transitory computer-readable storage medium.
A fifth object of the present application is to propose a computer program product.
To achieve the above object, an embodiment of a first aspect of the present application provides a message filtering method, including: receiving a message; splitting a sequence corresponding to the message identifier of the message into a first sequence and a second sequence; inquiring a truth table corresponding to the first sequence to obtain a value corresponding to the first sequence, and inquiring a truth table corresponding to the second sequence to obtain a value corresponding to the second sequence; and carrying out bitwise AND calculation on the value corresponding to the first sequence and the value corresponding to the second sequence, and processing the message if the result of the bitwise AND calculation is equal to the second sequence.
In the message filtering method according to the embodiment of the application, after a message is received, a sequence corresponding to a message identifier of the message is split into a first sequence and a second sequence, then a truth table corresponding to the first sequence is queried to obtain a value corresponding to the first sequence, and a truth table corresponding to the second sequence is queried to obtain a value corresponding to the second sequence; and carrying out bitwise and calculation on the value corresponding to the first sequence and the value corresponding to the second sequence, and if the result of the bitwise and calculation is equal to the second sequence, processing the message, so that whether the received message is processed or not can be quickly determined according to the message ID, software filtering on the message is realized, hardware filtering is not needed, and the filtering efficiency is improved.
To achieve the above object, a second aspect of the present application provides a message filtering apparatus, including: the receiving module is used for receiving the message; the splitting module is used for splitting a sequence corresponding to the message identifier of the message into a first sequence and a second sequence; the query module is configured to query the truth table corresponding to the first sequence to obtain a value corresponding to the first sequence, and query the truth table corresponding to the second sequence to obtain a value corresponding to the second sequence; the calculation module is used for carrying out bitwise AND calculation on the values corresponding to the first sequence and the values corresponding to the second sequence; and the processing module is used for processing the message when the bitwise sum of the calculation module and the calculation result is equal to a second sequence.
In the message filtering method according to the embodiment of the application, after a receiving module receives a message, a splitting module splits a sequence corresponding to a message identifier of the message into a first sequence and a second sequence, and then an inquiring module inquires a truth table corresponding to the first sequence to obtain a value corresponding to the first sequence and inquires a truth table corresponding to the second sequence to obtain a value corresponding to the second sequence; the calculation module carries out bitwise and calculation on the value corresponding to the first sequence and the value corresponding to the second sequence, and if the result of the bitwise and calculation is equal to the second sequence, the processing module processes the message, so that whether the received message is processed or not can be quickly determined according to the message ID, software filtering on the message is realized, hardware filtering is not needed, and the filtering efficiency is improved.
To achieve the above object, an embodiment of a third aspect of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the electronic device implements the method described above.
To achieve the above object, a non-transitory computer-readable storage medium is provided in a fourth aspect of the present application, on which a computer program is stored, and the computer program is executed by a processor to implement the method as described above.
To achieve the above object, an embodiment of a fifth aspect of the present application provides a computer program product, where instructions of the computer program product, when executed by a processor, perform the method as described above.
Additional aspects and advantages of the present application will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the present application.
Drawings
The foregoing and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
fig. 1 is a flowchart of an embodiment of a message filtering method according to the present application;
fig. 2 is a schematic diagram of an embodiment of a truth table corresponding to a first sequence in the message filtering method of the present application;
fig. 3 is a schematic diagram of an embodiment of a truth table corresponding to a second sequence in the message filtering method of the present application;
fig. 4 is a schematic structural diagram of an embodiment of a message filtering apparatus according to the present application;
fig. 5 is a schematic structural diagram of an embodiment of an electronic device according to the present application.
Detailed Description
Reference will now be made in detail to embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are exemplary and intended to be used for explaining the present application and should not be construed as limiting the present application.
Fig. 1 is a flowchart of an embodiment of a message filtering method according to the present application, and as shown in fig. 1, the message filtering method may include:
The message may be a CAN bus message, and certainly, the message may also be other types of messages, but this embodiment is described by taking the message as a CAN bus message as an example.
In this embodiment, the first sequence includes a sequence of a first predetermined number of bits from the highest bit of the sequence corresponding to the message identifier, the second sequence includes a sequence of a second predetermined number of bits from the lowest bit of the sequence corresponding to the message identifier, and the sum of the first predetermined number of bits and the second predetermined number of bits is the total number of bits of the sequence corresponding to the message identifier.
The first predetermined number of bits and the second predetermined number of bits may be set according to system performance and/or implementation requirements, and the size of the first predetermined number of bits and the size of the second predetermined number of bits are not limited in this embodiment.
Taking the message as a CAN bus message as an example, the total number of bits of the sequence corresponding to the message ID of the CAN bus message is 11 bits, the first predetermined number of bits may be set to be 8, and the second predetermined number of bits is set to be 3, that is, the upper 8 bits of the sequence corresponding to the message ID are divided into a first sequence, and the lower 3 bits of the sequence corresponding to the message ID are divided into a second sequence.
And 104, performing bitwise AND calculation on the values corresponding to the first sequence and the values corresponding to the second sequence.
And 105, if the bitwise sum calculation result is equal to the second sequence, processing the message.
Further, after step 104, the method may further include:
and 106, if the bitwise and the calculated result is not equal to the second sequence, discarding the message.
In the message filtering method, after a message is received, a sequence corresponding to a message identifier of the message is split into a first sequence and a second sequence, then a truth table corresponding to the first sequence is queried to obtain a value corresponding to the first sequence, and a truth table corresponding to the second sequence is queried to obtain a value corresponding to the second sequence; and carrying out bitwise and calculation on the value corresponding to the first sequence and the value corresponding to the second sequence, and if the result of the bitwise and calculation is equal to the second sequence, processing the message, so that whether the received message is processed or not can be quickly determined according to the message ID, software filtering on the message is realized, hardware filtering is not needed, and the filtering efficiency is improved.
Still taking CAN bus messages as an example, in the embodiment shown in fig. 1 of the present application, the truth table corresponding to the first sequence may include 256 elements, each element is defined as an unsigned character (unsigned char), the binary table is represented as xxxxxxxxxxb, which has 8 bits, the truth table corresponding to the first sequence may set whether the number of received messages is 256 × 8 ═ 2048(0x800), and includes all message IDs of CAN bus messages 0x0 to 0x7ff, so that the purpose of software filtering may be achieved by setting the values of the elements in the truth table corresponding to the first sequence, fig. 2 is a schematic diagram of an embodiment of the truth table corresponding to the first sequence in the message filtering method of the present application, and in the truth table shown in fig. 2, the element in the 1 st row 1, column 1, is the 0 th element, and then the element in the sequence from left to right is the 1 st element, the 2 nd element, …, and the 255 th element.
The truth table of the second sequence includes 8 elements, each element is also defined as an unsigned char, the binary representation is xxxxxxxxxxb, and each element of the truth table of the second sequence corresponds toThe value of element is 2n,n<Fig. 3 is a schematic diagram of an embodiment of a truth table corresponding to the second sequence in the message filtering method of the present application, and in the truth table shown in fig. 3, the element in the 1 st row and the 1 st column is the 0 th element, and then the 1 st element, …, and the 7 th element are sequentially arranged from left to right.
Specifically, in step 103 of the embodiment shown in fig. 1 of the present application, the obtaining a value corresponding to the first sequence by querying the truth table corresponding to the first sequence may be: converting the first sequence into decimal representation to obtain a first sequence in decimal representation; and inquiring the truth table corresponding to the first sequence to obtain the element values at the element positions indicated by the first sequence in decimal representation in the truth table corresponding to the first sequence, wherein the obtained element values are the values corresponding to the first sequence.
In step 103, the truth table corresponding to the second sequence is queried to obtain a value corresponding to the second sequence, which may be: converting the second sequence into decimal representation to obtain a second sequence in decimal representation; and inquiring the truth table corresponding to the second sequence to obtain the element values at the element positions indicated by the second sequence in decimal representation in the truth table corresponding to the second sequence, wherein the obtained element values are the values corresponding to the second sequence.
For example, assuming that the message ID of the CAN bus message is "00100100011 b", the sequence may be divided into a first sequence "00100100100 b" and a second sequence "011 b" according to a division method in which the first predetermined number of bits is 8 and the second predetermined number of bits is 3. Converting the first sequence "00100100100 b" into decimal representation, obtaining the first sequence represented by decimal representation as "36", querying the truth table shown in fig. 2 to obtain the element value at the element position indicated by "36" (i.e. the 36 th element in the truth table shown in fig. 2, which is marked by a box in fig. 2) in the truth table corresponding to the first sequence, and obtaining the element value "0 x0 e" as the value corresponding to the first sequence.
Converting the second sequence "011 b" into decimal representation, obtaining the decimal second sequence "3", looking up the truth table shown in fig. 3 to obtain the element value at the element position indicated by "3" (i.e. the 3 rd element in the truth table shown in fig. 3, marked by a box in fig. 3) in the truth table corresponding to the second sequence, and obtaining the element value "0 x 08" as the value corresponding to the second sequence.
And then performing bitwise and calculation on the values corresponding to the first sequence and the values corresponding to the second sequence, in a specific implementation, the values corresponding to the first sequence and the values corresponding to the second sequence may be converted into binary representations, and then performing bitwise and calculation, in this example, the calculation process of performing bitwise and calculation on "0 x0 e" and "0 x 08" may be: firstly, converting '0 x0 e' into a binary representation to be '00001110 b', converting '0 x 08' into a binary representation to be '00001000 b', then performing bitwise AND calculation on '00001110 b' and '00001000 b', wherein the result is '00001000 b', which is equal to the second sequence, and then receiving and processing the CAN bus message with the message ID of '00100100011 b'.
If the truth table corresponding to the first sequence is queried, the corresponding value of the first sequence is "0 x 00", so that the bitwise and calculation results of "0 x 00" and "0 x 08" will be "0 x 00", which is not equal to the second sequence, and the CAN bus packet with the packet ID of "00100100011" needs to be discarded. In summary, the software filtering can be achieved by setting the values of the elements in the truth table corresponding to the first sequence.
According to the message filtering method provided by the embodiment of the application, a hardware filter is not used for receiving the CAN bus message, all message IDs of the CAN bus message CAN be received in terms of hardware performance, a hardware performance bottleneck does not exist, software filtering is realized, the message IDs of all CAN bus messages have the same priority, and the time for executing the software filtering is also consistent.
According to the message filtering method provided by the embodiment of the application, whether the received CAN bus message is processed or not is determined by inquiring the truth table according to the message ID, traversing comparison is not needed, and the filtering efficiency is improved.
Fig. 4 is a schematic structural diagram of an embodiment of a message filtering apparatus according to the present application, where the message filtering apparatus in this embodiment may be used as an electronic device, or a part of the electronic device to implement the message filtering method according to the present application.
The electronic device may be a device including a chip with a CAN peripheral, for example: an Electronic fuel injection module, an Electronic Stability Program (ESP), an automatic Transmission Control Unit (TCU), an Adaptive Cruise Control (ACC), and the like in an automobile.
As shown in fig. 4, the message filtering apparatus may include: a receiving module 41, a splitting module 42, a querying module 43, a calculating module 44 and a processing module 45;
the receiving module 41 is configured to receive a message; the message may be a CAN bus message, and certainly, the message may also be other types of messages, but this embodiment is described by taking the message as a CAN bus message as an example.
A splitting module 42, configured to split a sequence corresponding to the message identifier of the message into a first sequence and a second sequence; in this embodiment, the first sequence includes a sequence of a first predetermined number of bits from the highest bit of the sequence corresponding to the message identifier, the second sequence includes a sequence of a second predetermined number of bits from the lowest bit of the sequence corresponding to the message identifier, and the sum of the first predetermined number of bits and the second predetermined number of bits is the total number of bits of the sequence corresponding to the message identifier.
The first predetermined number of bits and the second predetermined number of bits may be set according to system performance and/or implementation requirements, and the size of the first predetermined number of bits and the size of the second predetermined number of bits are not limited in this embodiment.
Taking the message as a CAN bus message as an example, the total number of bits of the sequence corresponding to the message ID of the CAN bus message is 11 bits, the first predetermined number of bits may be set to be 8, and the second predetermined number of bits is set to be 3, that is, the upper 8 bits of the sequence corresponding to the message ID are divided into a first sequence, and the lower 3 bits of the sequence corresponding to the message ID are divided into a second sequence.
The query module 43 is configured to query the truth table corresponding to the first sequence to obtain a value corresponding to the first sequence, and query the truth table corresponding to the second sequence to obtain a value corresponding to the second sequence.
And a calculating module 44, configured to perform bitwise and calculation on the value corresponding to the first sequence and the value corresponding to the second sequence.
And a processing module 45, configured to process the message when the bitwise sum of the calculation result of the calculation module 44 is equal to the second sequence.
Further, the processing module 45 is further configured to discard the message when the bitwise sum of the calculation module 44 does not equal to the second sequence.
In the message filtering apparatus, after the receiving module 41 receives a message, the splitting module 42 splits a sequence corresponding to a message identifier of the message into a first sequence and a second sequence, and then the querying module 43 queries a truth table corresponding to the first sequence to obtain a value corresponding to the first sequence and queries a truth table corresponding to the second sequence to obtain a value corresponding to the second sequence; the calculation module 44 performs bitwise and calculation on the value corresponding to the first sequence and the value corresponding to the second sequence, and if the result of the bitwise and calculation is equal to the second sequence, the processing module 45 processes the packet, so that whether to process the received packet can be quickly determined according to the packet ID, software filtering on the packet is realized, hardware filtering is not required, and filtering efficiency is improved.
Still taking the CAN bus packet as an example, in the embodiment shown in fig. 4 of the present application, the truth table corresponding to the first sequence may include 256 elements, each element is defined as an unsigned character (unsigned char), the binary table is represented as xxxxxxxxxxb, which has 8 bits, the truth table corresponding to the first sequence may set whether the number of received packets is 256 × 8 ═ 2048(0x800), and includes all packet IDs of CAN bus packets 0x0 to 0x7ff, so that the purpose of software filtering may be achieved by setting the values of the elements in the truth table corresponding to the first sequence, referring to fig. 2, in the truth table shown in fig. 2, the element in row 1, column 1, is the 0 th element, and then the element in sequence from left to right is the 1 st element, the 2 nd element, the …, and the 255 th element.
The truth table for the second sequence includes 8 elements, each element is also defined as an unsigned char, the binary representation is xxxxxxxxxxb, and the truth table for the second sequence has a value of 2n,n<Referring to fig. 3, in the truth table of fig. 3, the element in row 1 and column 1 is the 0 th element, and then the 1 st element, …, and the 7 th element are arranged from left to right.
In the embodiment shown in fig. 4, the query module 43 is specifically configured to convert the first sequence into a decimal representation, and obtain the first sequence in the decimal representation; and inquiring the truth table corresponding to the first sequence to obtain the element values at the element positions indicated by the first sequence in decimal representation in the truth table corresponding to the first sequence, wherein the obtained element values are the values corresponding to the first sequence.
The query module 43 is specifically configured to convert the second sequence into a decimal representation, obtain the second sequence represented in the decimal representation, query the truth table corresponding to the second sequence, obtain the element value at the element position indicated by the second sequence represented in the decimal representation in the truth table corresponding to the second sequence, and obtain the element value as the value corresponding to the second sequence.
For example, assuming that the message ID of the CAN bus message is "00100100011 b", according to the dividing method that the first predetermined number of bits is 8 and the second predetermined number of bits is 3, the splitting module 42 may divide the sequence into a first sequence "00100100100 b" and a second sequence "011 b". The query module 43 converts the first sequence "00100100100 b" into a decimal representation, obtains the first sequence represented by a decimal number as "36", queries the truth table shown in fig. 2 to obtain the element value at the element position indicated by "36" (i.e. the 36 th element in the truth table shown in fig. 2 and marked by a box in fig. 2) in the truth table corresponding to the first sequence, and obtains the element value "0 x0 e", which is the value corresponding to the first sequence.
Similarly, the query module 43 converts the second sequence "011 b" into decimal representation, obtains the decimal representation of the second sequence "3", queries the truth table shown in fig. 3 to obtain the element value at the element position indicated by "3" in the truth table corresponding to the second sequence (i.e. the 3 rd element in the truth table shown in fig. 3 is marked by a box in fig. 3), and obtains the element value "0 x 08" as the value corresponding to the second sequence.
Then, the calculating module 44 performs bitwise and calculation on the value corresponding to the first sequence and the value corresponding to the second sequence, in a specific implementation, the calculating module 44 may convert the value corresponding to the first sequence and the value corresponding to the second sequence into a binary representation, and then perform bitwise and calculation, in this example, the calculating process of bitwise and calculation on "0 x0 e" and "0 x 08" may be: firstly, converting "0 x0 e" into binary representation, namely "00001110 b", converting "0 x 08" into binary representation, namely "00001000 b", then performing bitwise and calculation on "00001110 b" and "00001000 b", wherein the result is "00001000 b", which is equal to the second sequence, and then the processing module 45 receives and processes the CAN bus message with the message ID of "00100100011 b".
If the truth table corresponding to the first sequence is queried, the query module 43 obtains that the value corresponding to the first sequence is also "0 x 00", so that the result of bitwise and computation performed by the computation module 44 on "0 x 00" and "0 x 08" is "0 x 00", which is not equal to the second sequence, and thus the processing module 45 needs to discard the CAN bus packet with the packet ID of "00100100011". In summary, the software filtering can be achieved by setting the values of the elements in the truth table corresponding to the first sequence.
In the message filtering apparatus provided in the embodiment of the present application, the receiving module 41 receives the CAN bus message without using a hardware filter, and in terms of hardware performance, may receive all the message IDs of the CAN bus message, and there is no hardware performance bottleneck, so that software filtering is implemented, and the message IDs of all the CAN bus messages have the same priority, and the time for executing software filtering is also the same.
The message filtering device provided by the embodiment of the application determines whether to process the received CAN bus message by inquiring the truth table according to the message ID without traversing comparison, thereby improving the filtering efficiency.
Fig. 5 is a schematic structural diagram of an embodiment of an electronic device according to the present application, where the electronic device may include a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the message filtering method according to the embodiment of the present application may be implemented.
The electronic device may be a device including a chip with a CAN peripheral, for example: electronic fuel injection modules in automobiles, ESPs, TCUs or ACCs, etc.
FIG. 5 illustrates a block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present application. The electronic device 12 shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in FIG. 5, electronic device 12 is embodied in the form of a general purpose computing device. The components of electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
Electronic device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by electronic device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system Memory 28 may include computer system readable media in the form of volatile Memory, such as Random Access Memory (RAM) 30 and/or cache Memory 32. The electronic device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, and commonly referred to as a "hard drive"). Although not shown in FIG. 5, a disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a Compact disk Read Only memory (CD-ROM), a Digital versatile disk Read Only memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the application.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally perform the functions and/or methodologies of the embodiments described herein.
Electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and may also communicate with one or more devices that enable a user to interact with electronic device 12, and/or with any devices (e.g., Network card, modem, etc.) that enable electronic device 12 to communicate with one or more other computing devices, such communication may occur via input/output (I/O) interfaces 22. furthermore, electronic device 12 may also communicate with one or more networks (e.g., local Area Network (L Area Network; L AN), Wide Area Network (WAN; for short) and/or a public Network, such as the Internet) via Network adapter 20. As shown in FIG. 5, Network adapter 20 communicates with other modules of electronic device 12 via bus 18. it should be understood that, although not shown in FIG. 5, other hardware and/or software modules may be used in conjunction with electronic device 12, including, but not limited to, microcode, device drives, Redundant array drives, disk drive Arrays, RAID disk drives, disk drive systems, RAID systems, disk drives, disk Arrays, and the like.
The processing unit 16 executes programs stored in the system memory 28 to execute various functional applications and data processing, such as implementing the message filtering method provided by the embodiment of the present application.
The present application further provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the message filtering method provided in the embodiments of the present application.
The non-transitory computer readable storage medium described above may take any combination of one or more computer readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read Only Memory (ROM), an Erasable Programmable Read Only Memory (EPROM) or flash Memory, an optical fiber, a portable compact disc Read Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present application may be written in any combination of one or more programming languages, including AN object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" language or similar programming languages.
The embodiment of the present application further provides a computer program product, and when instructions in the computer program product are executed by a processor, the message filtering method provided in the embodiment of the present application is executed.
In the description herein, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present application, "plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing steps of a custom logic function or process, and alternate implementations are included within the scope of the preferred embodiment of the present application in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present application.
The logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection portion (electronic device) having one or more wires, a portable computer cartridge (magnetic device), a Random Access Memory (RAM), a Read Only Memory (ROM), an Erasable Programmable Read Only Memory (EPROM) or a flash Memory, an optical fiber device, and a portable Compact Disc Read Only Memory (CD-ROM). Additionally, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic Gate circuit for realizing a logic function for a data signal, an asic having an appropriate combinational logic Gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), and the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present application may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. Although embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present application, and that variations, modifications, substitutions and alterations may be made to the above embodiments by those of ordinary skill in the art within the scope of the present application.
Claims (10)
1. A method for filtering a message, comprising:
receiving a message;
splitting a sequence corresponding to a message identifier of the message into a first sequence and a second sequence, wherein the first sequence comprises a sequence with a first predetermined digit from the highest bit of the sequence corresponding to the message identifier, the second sequence comprises a sequence with a second predetermined digit from the lowest bit of the sequence corresponding to the message identifier, and the sum of the first predetermined digit and the second predetermined digit is the total digit of the sequence corresponding to the message identifier;
inquiring a truth table corresponding to the first sequence to obtain a value corresponding to the first sequence, and inquiring a truth table corresponding to the second sequence to obtain a value corresponding to the second sequence;
and carrying out bitwise AND calculation on the value corresponding to the first sequence and the value corresponding to the second sequence, and processing the message if the result of the bitwise AND calculation is equal to the second sequence.
2. The method of claim 1, wherein after bitwise anding the values corresponding to the first sequence and the values corresponding to the second sequence, further comprising:
and if the bitwise and computed result is not equal to the second sequence, discarding the message.
3. The method according to any one of claims 1-2, wherein the querying the truth table corresponding to the first sequence to obtain the value corresponding to the first sequence comprises:
converting the first sequence into a decimal representation, obtaining a first sequence in decimal representation;
and inquiring a truth table corresponding to the first sequence to obtain element values at element positions indicated by the first sequence in decimal representation in the truth table corresponding to the first sequence, wherein the obtained element values are values corresponding to the first sequence.
4. The method according to any one of claims 1-2, wherein the querying the truth table corresponding to the second sequence to obtain the value corresponding to the second sequence comprises:
converting the second sequence into a decimal representation, obtaining a second sequence in decimal representation;
and inquiring the truth table corresponding to the second sequence to obtain the element values at the element positions indicated by the second sequence in decimal representation in the truth table corresponding to the second sequence, wherein the obtained element values are the values corresponding to the second sequence.
5. A message filtering apparatus, comprising:
the receiving module is used for receiving the message;
the splitting module is used for splitting a sequence corresponding to a message identifier of the message into a first sequence and a second sequence, the first sequence comprises a sequence with a first predetermined digit from the highest bit of the sequence corresponding to the message identifier, the second sequence comprises a sequence with a second predetermined digit from the lowest bit of the sequence corresponding to the message identifier, and the sum of the first predetermined digit and the second predetermined digit is the total digit of the sequence corresponding to the message identifier;
the query module is configured to query the truth table corresponding to the first sequence to obtain a value corresponding to the first sequence, and query the truth table corresponding to the second sequence to obtain a value corresponding to the second sequence;
the calculation module is used for carrying out bitwise AND calculation on the values corresponding to the first sequence and the values corresponding to the second sequence;
and the processing module is used for processing the message when the bitwise sum of the calculation module and the calculation result is equal to the second sequence.
6. The apparatus of claim 5,
the processing module is further configured to discard the packet when the bitwise sum of the calculation module and the calculation result is not equal to the second sequence.
7. The apparatus according to any one of claims 5 to 6,
the query module is specifically configured to convert the first sequence into a decimal representation, and obtain a first sequence represented in the decimal representation; and inquiring a truth table corresponding to the first sequence to obtain element values at element positions indicated by the first sequence in decimal representation in the truth table corresponding to the first sequence, wherein the obtained element values are values corresponding to the first sequence.
8. The apparatus according to any one of claims 5 to 6,
the query module is specifically configured to query the truth table corresponding to the second sequence, and obtaining the value corresponding to the second sequence includes: converting the second sequence into a decimal representation, obtaining a second sequence in decimal representation; and inquiring the truth table corresponding to the second sequence to obtain the element values at the element positions indicated by the second sequence in decimal representation in the truth table corresponding to the second sequence, wherein the obtained element values are the values corresponding to the second sequence.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method according to any of claims 1-4 when executing the computer program.
10. A non-transitory computer-readable storage medium having stored thereon a computer program, wherein the computer program, when executed by a processor, implements the method of any one of claims 1-4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711243609.1A CN109861949B (en) | 2017-11-30 | 2017-11-30 | Message filtering method and device and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711243609.1A CN109861949B (en) | 2017-11-30 | 2017-11-30 | Message filtering method and device and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109861949A CN109861949A (en) | 2019-06-07 |
CN109861949B true CN109861949B (en) | 2020-08-07 |
Family
ID=66888707
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711243609.1A Active CN109861949B (en) | 2017-11-30 | 2017-11-30 | Message filtering method and device and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109861949B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102467530A (en) * | 2010-11-11 | 2012-05-23 | 上海大潮电子技术有限公司 | Data mining system and data mining method |
JP2013211702A (en) * | 2012-03-30 | 2013-10-10 | Lapis Semiconductor Co Ltd | Communication device and filtering method |
CN103780508A (en) * | 2014-02-20 | 2014-05-07 | 北京经纬恒润科技有限公司 | Software wave filtering method and system of CAN bus messages and electronic control unit |
CN107181663A (en) * | 2017-06-28 | 2017-09-19 | 联想(北京)有限公司 | A kind of message processing method, relevant device and computer-readable recording medium |
CN107402564A (en) * | 2017-07-07 | 2017-11-28 | 山东汉格威新能源汽车电控制造有限公司 | A kind of CAN filter setting methods on Freescale single-chip microcomputer |
-
2017
- 2017-11-30 CN CN201711243609.1A patent/CN109861949B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102467530A (en) * | 2010-11-11 | 2012-05-23 | 上海大潮电子技术有限公司 | Data mining system and data mining method |
JP2013211702A (en) * | 2012-03-30 | 2013-10-10 | Lapis Semiconductor Co Ltd | Communication device and filtering method |
CN103780508A (en) * | 2014-02-20 | 2014-05-07 | 北京经纬恒润科技有限公司 | Software wave filtering method and system of CAN bus messages and electronic control unit |
CN107181663A (en) * | 2017-06-28 | 2017-09-19 | 联想(北京)有限公司 | A kind of message processing method, relevant device and computer-readable recording medium |
CN107402564A (en) * | 2017-07-07 | 2017-11-28 | 山东汉格威新能源汽车电控制造有限公司 | A kind of CAN filter setting methods on Freescale single-chip microcomputer |
Also Published As
Publication number | Publication date |
---|---|
CN109861949A (en) | 2019-06-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110929860B (en) | Convolution acceleration operation method and device, storage medium and terminal equipment | |
CN101036125A (en) | Masking within a data processing system having applicability for a development interface | |
CN107807989B (en) | Small file processing method and device | |
CN106708468B (en) | Division operation device | |
CN112395322B (en) | List data display method and device based on hierarchical cache and terminal equipment | |
US20190163442A1 (en) | Buffer size optimization in a hierarchical structure | |
CN111930923B (en) | Bloom filter system and filtering method | |
US20190163441A1 (en) | Multi-cycle key compares for keys and records of variable length | |
KR20210090249A (en) | Image processing method, apparatus, vehicle-mounted computing platform, electronic device and system | |
US20190163443A1 (en) | Hierarchical sort/merge structure using a request pipe | |
CN111930924A (en) | Data duplicate checking system and method based on bloom filter | |
CN105528183A (en) | Data storage method and storage equipment | |
CN105701128A (en) | Query statement optimization method and apparatus | |
US7484068B2 (en) | Storage space management methods and systems | |
CN104270287A (en) | Message disorder detecting method and device | |
US10896022B2 (en) | Sorting using pipelined compare units | |
CN109861949B (en) | Message filtering method and device and electronic equipment | |
US10761847B2 (en) | Linear feedback shift register for a reconfigurable logic unit | |
CN110737678A (en) | data searching method, device, equipment and storage medium | |
CN108874994A (en) | A kind of piecemeal reads the method, apparatus and computer storage medium of data | |
US9858179B2 (en) | Data sort using memory-intensive exosort | |
CN111258733B (en) | Embedded OS task scheduling method and device, terminal equipment and storage medium | |
CN108897817B (en) | Data storage method, detection method and system, storage medium and computer equipment | |
CN110795405A (en) | Fragment data restoration method, terminal device and storage medium | |
CN118264933A (en) | Method, device, equipment, vehicle and medium for transmitting vehicle acquisition signal |
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 |