CN115633044B - Message processing method and device, electronic equipment and storage medium - Google Patents

Message processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115633044B
CN115633044B CN202210859082.XA CN202210859082A CN115633044B CN 115633044 B CN115633044 B CN 115633044B CN 202210859082 A CN202210859082 A CN 202210859082A CN 115633044 B CN115633044 B CN 115633044B
Authority
CN
China
Prior art keywords
network message
network
message
channel
copying
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
CN202210859082.XA
Other languages
Chinese (zh)
Other versions
CN115633044A (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.)
Guangzhou Automobile Group Co Ltd
Original Assignee
Guangzhou Automobile Group 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 Guangzhou Automobile Group Co Ltd filed Critical Guangzhou Automobile Group Co Ltd
Priority to CN202210859082.XA priority Critical patent/CN115633044B/en
Publication of CN115633044A publication Critical patent/CN115633044A/en
Application granted granted Critical
Publication of CN115633044B publication Critical patent/CN115633044B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40215Controller Area Network CAN

Abstract

The application provides a message processing method, a message processing device, electronic equipment and a storage medium, wherein the method is applied to a gateway and comprises the following steps: acquiring a network message and determining a source channel corresponding to the network message; judging whether the source channel is the same as a preset channel, wherein the preset channel is determined by the gateway based on a target instruction sent by a connected peripheral; and if the source channel is the same as the preset channel, copying the network message and sending the network message to the peripheral equipment. The method and the device CAN realize the modification of the source channel to select the network message needing to be copied, thereby avoiding the need of modifying the register and restarting the corresponding CAN module, and further ensuring that error frames cannot occur in the copied network message; meanwhile, the stability of the network message sent to the peripheral is improved.

Description

Message processing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of automotive electronics, and in particular, to a method and apparatus for processing a message, an electronic device, and a storage medium.
Background
At present, the new national standard regulation requires that a vehicle-mounted diagnosis (On Board Diagnostics, OBD) system only allows one path of diagnosis CAN to be connected out, but the requirement of checking messages of other application CAN exists in the process of debugging the CAN, so that how to check messages of other CAN is a problem to be solved urgently at present under the condition that only one path of diagnosis CAN is allowed to be connected out.
Disclosure of Invention
In view of this, the embodiments of the present application provide a method, an apparatus, an electronic device, and a storage medium for processing a message, so as to improve the above-mentioned problems.
According to an aspect of an embodiment of the present application, there is provided a method for processing a message, where the method includes: acquiring a network message and determining a source channel corresponding to the network message; judging whether the source channel is the same as a preset channel, wherein the preset channel is determined by a gateway based on a target instruction sent by a connected peripheral; and if the source channel is the same as the preset channel, copying the network message and sending the network message to the peripheral equipment.
According to an aspect of an embodiment of the present application, there is provided a device for processing a packet, where the device includes: the network message acquisition module is used for acquiring a network message and determining a source channel corresponding to the network message; the judging module is used for judging whether the source channel is the same as a preset channel or not, wherein the preset channel is determined by the gateway based on a target instruction sent by a connected peripheral; and the network message sending module is used for copying the network message and sending the network message to the peripheral equipment if the source channel is the same as the preset channel.
According to an aspect of an embodiment of the present application, there is provided an electronic device including: a processor; and the memory is used for storing computer readable instructions, and when the computer readable instructions are executed by the processor, the processing method of the message is realized.
According to an aspect of the embodiments of the present application, there is provided a computer readable storage medium having stored thereon computer readable instructions which, when executed by a processor, implement a method of processing a message as described above.
In the scheme of the application, the network message is obtained, the source channel corresponding to the network message is determined, and when the source channel is determined to be the same as the preset channel, the network message is copied and sent to the peripheral, wherein the preset channel is determined by the gateway based on the target instruction sent by the connected peripheral, so that the network message needing to be copied CAN be selected by modifying the source channel, the register is prevented from being modified, the corresponding CAN module is restarted, and further, the fact that error frames cannot occur in the copied network message is ensured; meanwhile, the stability of the network message sent to the peripheral is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention as claimed.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application. It is apparent that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
Fig. 1 is a schematic diagram illustrating an application scenario suitable for the present application according to an embodiment of the present application.
Fig. 2 is a flow chart illustrating a method for processing a message according to an embodiment of the present application.
Fig. 3 is a flow chart illustrating a method for processing a message according to another embodiment of the present application.
Fig. 4 is a flow chart illustrating a method for processing a message according to still another embodiment of the present application.
Fig. 5 is a block diagram of a message processing apparatus according to an embodiment of the present application.
Fig. 6 is a hardware configuration diagram of an electronic device according to an embodiment of the present application.
There has been shown in the drawings, and will hereinafter be described, specific embodiments of the invention with the understanding that the present disclosure is to be considered in all respects as illustrative, and not restrictive, the scope of the inventive concepts being limited to the specific embodiments shown and described.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments may be embodied in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the present application. One skilled in the relevant art will recognize, however, that the aspects of the application can be practiced without one or more of the specific details, or with other methods, apparatus, steps, etc. In other instances, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the application.
The block diagrams depicted in the figures are merely functional entities and do not necessarily correspond to physically separate entities. That is, the functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices. The flow diagrams depicted in the figures are exemplary only, and do not necessarily include all of the elements and operations/steps, nor must they be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the order of actual execution may be changed according to actual situations.
At present, part of the hardware of the chip has a mirror image routing function, and the function is to associate the sending hardware Buffer and the receiving hardware Buffer of the source channel to the sending Buffer of the gateway through register configuration, so that the network message received and sent by the CAN CAN be directly forwarded to the corresponding diagnosis CAN by the hardware, and further, the function of the corresponding mirror image routing is realized.
However, in the hardware image routing, the binding of the source CAN and the diagnostic CAN is only realized when the chip CAN module is in the initialization mode, if other paths CAN are routed to the diagnostic CAN, the CAN module must be restarted, so that the binding of the source CAN and the diagnostic CAN is performed again, and in the restarting process, the functions of receiving and sending the message of the gateway may be invalid.
Because the hardware route copies the message sent by the source CAN, the sequence of sending the message to the diagnosis CAN is the sequence of filling the message of the source CAN to the sending Buffer, but not the sequence of actually appearing the message on the CAN. In practice, after the message of the source CAN is sent to the sending Buffer, the message may not be actually sent out due to the reason of message arbitration, so that the problem of inaccurate sending sequence of the message may occur.
Since the mirror image routing CAN only be performed on the CAN of the conventional type, the data length of the network message of the CAN of the conventional type is not more than 8, so that the network message corresponding to the CAN of the conventional type CAN only be copied by the corresponding hardware mirror image routing, but the network message of the corresponding source channel may also be of the CAN FD type, and the data length of the network message of the CAN FD type is more than 8, and at this time, the mirror image routing cannot be performed on the message with the data length more than 8.
In order to solve the problems, the inventor finds out through long-term research and proposes a method, a device, an electronic device and a storage medium for processing a message, which are provided by the embodiment of the application, and sends a target instruction comprising a preset channel to a gateway through a peripheral device, and the gateway CAN judge whether a source channel corresponding to an acquired network message is the same as the preset channel according to the source channel of the acquired network message, so that a register is prevented from being modified and a corresponding CAN module is prevented from being restarted, and further, error frames are prevented from occurring in the copied network message; meanwhile, the stability of the network message sent to the peripheral is improved. The specific method for processing the message is described in detail in the following embodiments.
Fig. 1 is an application scenario diagram suitable for use in the present application, shown according to an embodiment of the present application. As shown in fig. 1, the application scenario includes a vehicle 100 and a peripheral device 200, where the vehicle 100 includes an on-board gateway 110, and the peripheral device 200 interacts with the on-board gateway 110 of the vehicle 100. The peripheral device 200 is connected with the on-board gateway 110 of the vehicle 100 through an on-board diagnostic interface in the vehicle. Alternatively, the peripheral 200 may be an external diagnostic device, a notebook computer, an external display, etc., which is not particularly limited herein.
The peripheral device 200 transmits a target instruction provided with a preset channel to the in-vehicle gateway 110 of the vehicle 100. The vehicle-mounted gateway 110 in the vehicle 100 acquires a network message sent by a controller connected with the vehicle gateway, determines a source channel corresponding to the network message, and then compares the source channel of the network message with a preset channel set by the peripheral 200 through a target instruction, so as to judge whether the source channel is identical with the preset channel; when the on-board gateway 110 determines that the source channel corresponding to the network message is the same as the preset channel, the network message is copied, and the copied network message is sent to the peripheral device 200.
Referring to fig. 2, fig. 2 is a flow chart illustrating a method for processing a message according to an embodiment of the present application. The processing method of the message determines whether the source channel of the acquired network message is the same as the preset channel by judging whether the source channel is the same as the preset channel, copies the network message and sends the network message to the peripheral when the source channel is the same as the preset channel, so that the network message needing to be copied can be selected by modifying the source channel, and the situation that error frames cannot occur in the copied network message is ensured; meanwhile, the stability of the network message sent to the peripheral is improved. In a specific embodiment, the method for processing a message may be applied to the apparatus 500 for processing a message as shown in fig. 5 and the electronic device 600 (fig. 6) configured with the apparatus 500 for processing a message. The specific flow of the present embodiment will be described below, and it will be understood that the peripheral devices according to the present embodiment may include an external diagnostic device, a notebook computer, an external display, etc., which are not limited herein. The following details about the flow shown in fig. 2, and the method for processing the message specifically may include the following steps:
Step S210, obtaining a network message and determining a source channel corresponding to the network message.
The channel is a data path used for transmitting information in the gateway, and can receive network messages sent by each controller in the vehicle, and instructions sent by a control module in the vehicle and an external device connected with the gateway. The source channel refers to a channel for transmitting the network message of the controller and the gateway, and it can be understood that the source channel indicates the source of the network message, that is, the controller for transmitting the network message can be determined according to the source channel of the network message.
In some embodiments, in a process that a network message is sent to a gateway through a source channel, identification information of the source channel may be added to the network message, and then a source channel corresponding to the network message may be determined according to the identification information.
In other embodiments, the mapping relationship between each network message and the source channel corresponding to each network message may be set, and after the network message is obtained, the source channel of the network message may be determined according to the mapping relationship between the network message and each network message and the source channel corresponding to each network message.
In some embodiments, step S210 may include determining whether an interrupt function in a gateway is triggered, wherein the interrupt function is triggered each time the gateway receives a network message or transmits a network message; and if the interrupt function in the gateway is triggered, acquiring the network message.
The interrupt function is to suspend the execution of the main function when the value currently meets a certain condition, and then execute the interrupt function. The interrupt function is triggered either by software or hardware, and the triggering mode can be selected according to the actual requirement. Alternatively, if the interrupt function is software triggered, the interrupt instruction of the interrupt function may be preset, and then the interrupt instruction of the interrupt function is sent to the gateway, and the gateway triggers the interrupt function according to the interrupt instruction.
Alternatively, if the interrupt function is a hardware trigger, the terminal function may be triggered by a serial interrupt, for example, when a network packet is sent to the gateway through the serial port, the gateway triggers the interrupt function after receiving the network packet. It will be appreciated that since the network message includes an end-of-message frame, the register in the gateway triggers the interrupt function after receiving the data and detecting the end-frame in the network message.
As a further way, the interruption may also be implemented by a timer-triggered interruption function. Optionally, a time interval for triggering the interrupt function is set in the timer of the gateway, and then the gateway triggers the interrupt function according to the time interval. For example, when the time interval of setting the interrupt function in the timer is 40ms, the gateway triggers the interrupt function according to the frequency of once of 40ms, and the specific time interval may be set according to actual needs, which is not limited herein.
As a further way, an interrupt flag may be set in the network packet, and when the gateway receives the network packet, the interrupt function is triggered according to the interrupt flag in the network packet.
In some embodiments, since the interrupt flag in the interrupt function changes after the interrupt function is triggered, whether the terminal function is triggered can be determined by determining whether the interrupt flag in the interrupt function changes. For example, the interrupt flag in the interrupt function is E, where e=1 indicates that the interrupt function is triggered; e=0 indicates that the interrupt function is not triggered, and the interrupt function is triggered can be determined by the value of E.
In other embodiments, it may also be determined whether the interrupt function is triggered by determining whether a level change in hardware associated with the interrupt function in the gateway has occurred. For example, when the level in the hardware associated with the interrupt function changes from low to high, or from high to low, it may be determined that the terminal function is triggered.
As a way, since the interrupt function is triggered every time the gateway receives the network message or transmits the network message, in order to avoid that the gateway cannot trigger the interrupt function after receiving the network message next time, the interrupt function may be reset after determining that the interrupt function is triggered. Optionally, the interrupt flag in the interrupt function may be restored to the interrupt flag corresponding to when the interrupt function is not triggered; or restoring the level in the hardware associated with the interrupt function in the gateway to a level corresponding to when the interrupt function is not triggered.
When the interrupt function in the gateway is triggered, the gateway can be determined to receive the complete network message, and the received network message can be directly obtained.
With continued reference to fig. 2, in step 220, it is determined whether the source channel is the same as a preset channel, where the preset channel is determined by the gateway based on a target instruction sent by the connected peripheral device.
The peripheral devices are external devices connected through an on-board diagnostic port (On Board Diagnostics, OBD) of the vehicle, for example, an external diagnostic device, a notebook computer, an external display, etc., and the peripheral devices may be provided according to actual needs, and are not particularly limited herein.
In some embodiments, the target instruction refers to a command for a preset channel set by the external device that needs to be mirrored. As one way, the external diagnostic apparatus may set a channel in which a network message needs to be copied by transmitting a Data ID (DID) command to the gateway, and the gateway sets the corresponding channel information according to the DID command. Optionally, the DID command may include an ID of the controller that sent the network message, a channel ID, and so on.
In other embodiments, the gateway may define a variable var_buffer, that is, define a channel variable in advance, and be used to record whether a status flag bit of a mirror route is to be opened in a Buffer area (Buffer) for receiving and sending network messages of each path of CAN or each controller in the gateway, then set, by an external device, a Buffer of a network message of a CAN that needs to be copied, and send the Buffer to the gateway, and after the gateway receives the Buffer, change a mirror route status flag bit of an accept Buffer of a corresponding CAN in var_buffer to be opened, where mirror route refers to copying the network message obtained by the gateway, and then forwarding the copied network message.
In some embodiments, a channel identifier may be set for a source channel corresponding to each network packet, and a corresponding channel identifier may be set in a preset channel, and whether the source channel is identical to the preset channel is determined by comparing whether the channel identifier of the source channel is identical to the channel identifier of the preset channel. For example, if there are 5 paths of CAN in the gateway, the channel identifiers of the source channels corresponding to the network messages are A, B, C, D, E, and the channel identifier of the preset channel is B, at this time, the gateway receives a network message, the channel identifier of the preset channel is the same as the source channel identifier of the network message, and it CAN be determined that the source channel of the network message is the same as the preset channel.
In other embodiments, a first identifier corresponding to each CAN or the controller receiving the Buffer sent by the controller may also be set, and a second identifier corresponding to the Buffer of the network packet of the CAN to be copied may also be set, where a mapping relationship exists between the first identifier and the second identifier, and whether the source channel is the same as the preset channel is determined based on the mapping relationship between the first identifier and the second identifier.
Step S230, if the source channel is the same as the preset channel, copying the network message and sending the network message to the peripheral device.
When the source channel is the same as the preset channel, it can be determined that the network message transmitted to the gateway through the source channel is the message which needs to be duplicated currently, at this time, the network message is duplicated, the duplicated network message is sent to the external device, and the external device can perform operations such as fault diagnosis according to the network message.
In some embodiments, the data length of the network packet may be determined before the network packet is copied, and in general, the data length of the network packet capable of being copied must not exceed the length threshold at the longest, if the data length of the network packet is greater than the length threshold, the data content of the network packet with the data length equal to the length threshold needs to be copied first, then the data content of the data length exceeding the length threshold is copied, and finally the copied network packet is sent to the peripheral according to the copying order.
In some embodiments, the copied network message may be temporarily stored in a Buffer, and after the copied network message is successfully sent to the peripheral device, the corresponding content in the Buffer storing the network message is deleted, so as to reduce the storage pressure of the gateway, and also facilitate the next sending of the network message.
In other embodiments, the content storage variables may be predefined, where each content storage variable may store the data content of a network packet with a data length not greater than a length threshold, and after the network packet corresponding to a content storage variable is successfully sent, the pointer of the content storage variable of the network packet is pointed to the next content storage variable, so that the network packet is sent to the peripheral device in the order of buffering the content storage variables.
In other embodiments, when it is determined that the source channel is the same as the preset channel, the network message corresponding to the source channel is copied, and the copied network is sent to a peripheral device and a vehicle-mounted terminal (T-BOX), and the vehicle-mounted terminal can upload the network message to an electronic device or a cloud server that is in communication connection with the vehicle-mounted terminal after receiving the network message.
In some embodiments, step 230 comprises: if the source channel is the same as the preset channel, copying and caching the network message; and sending the cached network message to the peripheral equipment according to a preset time interval.
In some embodiments, the time interval or frequency for sending the copied network message to the peripheral device may be preset, and then the copied network message is sent to the peripheral device according to the time interval or frequency, so that the problem of message arbitration when the copied network messages are sent together can be avoided, and the situation of congestion when the gateway sends the network message to the peripheral device is also avoided.
In other embodiments, a periodic function of the message transmission may be preset, where the periodic function is triggered at a preset time interval to implement the transmission of the duplicated network message to the peripheral device.
In other embodiments, the network message may be sent to the peripheral device by determining the number of buffered network messages, and optionally, when the number of buffered network messages is greater than the number threshold, the buffered network message may be sent to the peripheral device. For example, when the number threshold is 0, the buffer network message is sent to the peripheral by the stand-alone horse as long as the buffer network message exists. Specifically, the number threshold may be set according to actual needs, and is not specifically limited at this time.
In other embodiments, a variable may be predefined for calculating the number of network messages buffered in the gateway, which may be understood as duplicate network messages that have not yet been sent. After the copied network message is cached, the variable is accumulated to +1, when the periodic function of the message sending is triggered, whether the variable is larger than 0 can be judged, when the variable is larger than 0, the cached network message is sent to the peripheral equipment, and the variable is-1.
According to the message processing method provided by the embodiment of the application, the network message is obtained, the source channel corresponding to the network message is determined, when the source channel is determined to be the same as the preset channel, the network message is copied and sent to the peripheral, wherein the preset channel is determined by the gateway based on the target instruction sent by the connected peripheral, so that the network message needing to be copied CAN be selected by modifying the source channel, the register is prevented from being modified, the corresponding CAN module is restarted, and further, the error frame in the copied network message is prevented; meanwhile, the stability of the network message sent to the peripheral is improved.
Referring to fig. 3, fig. 3 is a flow chart illustrating a method for processing a message according to an embodiment of the present application. The method is applied to the gateway, and will be described in detail with respect to the flow shown in fig. 3, and the text processing method specifically may include the following steps:
step S310, a network message is obtained, and a source channel corresponding to the network message is determined.
Step S320, determining whether the source channel is the same as a preset channel, where the preset channel is determined by the gateway based on a target instruction sent by the connected peripheral device.
The specific description of step S310 and step S310 refer to step S210 and step S220, and are not described herein.
Step S330, if the source channel is the same as the preset channel, copying the network message and buffering.
In some embodiments, when the source channel is the same as the preset channel, it may be determined that the network packet transmitted to the gateway through the source channel is a packet that needs to be duplicated currently, at this time, the network packet is duplicated, and the duplicated network packet is cached, so that the gateway sends the duplicated network packet to the peripheral device.
In some embodiments, the copied network message may be temporarily cached in a non-volatile memory, e.g., in an erasable programmable read-only memory (Erasable Programmable Read Only Memory, EPROM) or an electrically erasable rewritable read-only memory (Electrically Erasable Programmable Read Only Memory, EEPROM). In other embodiments, the copied network message may be cached in a flash memory (flash memory), so as to delete the message that is successfully sent, and facilitate the next sending of the copied other network messages.
Step S340, determining the triggered sequence of the interrupt function corresponding to the cached network message, and sequentially sending the cached network message to the peripheral according to the sequence.
Currently, when the copied network message is sent to the peripheral device, the sequence of sending the copied network message is sent according to the buffer storage sequence of the network message in the gateway, and is not the sequence of receiving or sending the network message by the gateway. In practice, when the gateway sends the network message, the network message may not be successfully sent due to message arbitration, so that when the gateway copies the network message, the problem that the sequence of the copied network message is different from the sequence of the network message sent by the gateway may occur, and further, the sequence of the network message received by the peripheral device is different from the sequence of the network message sent or received by the gateway may occur. In order to solve the problem, the copied network messages are sent to the peripheral according to the sequence that the corresponding interrupt function is triggered when the network messages are sent to the gateway or the gateway sends the network messages through the source channel in the gateway, so that the problem of inaccurate sequence of the network messages is avoided.
When the gateway receives the network message or transmits the network message each time, the interrupt function is triggered, and the sequence in which the interrupt function is triggered is the sequence in which the gateway receives the network message or transmits the network message, so that the cached copied network message is transmitted to the peripheral according to the sequence in which the interrupt function is triggered, and the sequence accuracy of the network message can be improved.
In some embodiments, the time stamp of each time the interrupt function is triggered may also be copied into the corresponding network message and cached, and then the order in which the interrupt functions corresponding to the cached network message are triggered may be determined according to the time stamp of the time when the interrupt function is triggered.
In other embodiments, sequence identification information may be set in the corresponding network packet according to the function triggered by the interrupt function, and then the sequence triggered by the interrupt function corresponding to the cached network packet is determined according to the sequence identification information. For example, when the first interrupt function is triggered, the corresponding network message setting sequence identification information is 1st (first), and when the second interrupt function is triggered, the corresponding network message setting sequence identification information is 2nd (second), where specific sequence identifications can be set according to actual needs, and are not limited herein.
According to the message processing method provided by the embodiment of the application, the network message is obtained, the source channel corresponding to the network message is determined, when the source channel is determined to be the same as the preset channel, the network message is copied and cached, and then the cached network message is sent to the peripheral according to the sequence that the interrupt function in the gateway is triggered. Compared with the processing method of the message shown in fig. 2, the embodiment can also replicate the sequence of sending the network message to the gateway for sending the replicated network message to the peripheral, thereby improving the accuracy of the analysis based on the network message after training.
Referring to fig. 4, fig. 4 is a flow chart illustrating a method for processing a message according to an embodiment of the present application. The method is applied to the gateway, and will be described in detail with respect to the flow shown in fig. 4, and the text processing method specifically may include the following steps:
step S410, obtaining a network message and determining a source channel corresponding to the network message.
Step S420, judging whether the source channel is the same as a preset channel, wherein the preset channel is determined by the gateway based on a target instruction sent by a connected peripheral.
The specific description of step S410 and step S410 refer to step S210 and step S220, and are not described herein.
Step S430, if the source channel is the same as the preset channel, determining whether the type of the network message is a specified type.
The types of the network messages are classified into a CAN type and a CAN FD (CAN with Flexible Data-Rate) type, wherein the largest difference between the CAN type network messages and the CAN FD type network messages is that Data Length Codes (DLC) are different, and DLC is used for specifying the byte number of a data field in the network messages. The DLC of a CAN-type network message is at most 8 (i.e. the maximum number of bytes is 8), whereas the data length code DLC of a CAN FD-type network message is at most 64, wherein DLC determines the data length in the network message.
Currently, when the network message is copied, when the network message is a CAN type network message, the DLC is positioned between 0 and 8, and the network message with corresponding data length CAN be copied. However, for the network message of the CAN FD type, because DLC is larger than 8, only the data content of DLC 8 in the network message CAN be copied, so in order to ensure that the network message of the CAN FD type CAN also be completely copied and sent to the peripheral, the type of the network message CAN be judged first, and the subsequent method for copying the network message CAN be determined according to the type of the current network message.
In some embodiments, the specified type refers to a CAN FD type, but may be other DLC types greater than 8.
In some embodiments, a message identification identifier may be set in advance for a network message of a specified type, and whether the type of the network message is the specified type may be determined according to the message identification identifier.
Step S440, if the type is not the appointed type, copying the network message and transmitting to the peripheral equipment.
When the type of the network message is not the appointed type, the condition that the data content is missing when the network is copied can be determined, at the moment, the network message is directly copied, and the copied network message is sent to the peripheral equipment.
Step S450, if the type is the specified type, determining the data length of the network message.
In some embodiments, since the data length of the network packet of the specified type is 0-64, it is necessary to determine the data length of the network packet of the specified type again, and if the data length of the network packet of the specified type is between 0-8, the network packet can be duplicated according to the method of step S440. If the data length of the network message of the designated type is greater than 8, other ways are needed to copy the network message.
Step S460, determining a length relation between the data length and a preset length, copying the network message based on the length relation, and sending the network message to the peripheral equipment.
The length relationship between the data length and the preset length of the network message of the specified type may be whether the data length is not greater than the preset length or greater than the preset length. When the length relationship between the data length and the preset length indicates that the data length of the network message of the specified type is not greater than the preset length, the network message may be copied according to the method of step 440; when the length relationship between the data length and the preset length indicates that the data length of the network message of the specified type is greater than the preset length, the network message can be divided into a plurality of network sub-messages with data length not greater than the preset length, and then the plurality of network sub-messages are copied respectively according to the method of step S440, and the copied network message is sent to the peripheral device.
In some embodiments, whether the byte with the preset length in the network packet has data or not may be determined, if it is determined that the data exists, it may be determined that the length relationship between the data length of the network packet and the preset length is that the data length of the network packet is greater than the preset length, otherwise, it is determined that the data length of the network packet is not greater than the preset length.
In some embodiments, step S460 includes: if the data length is greater than the length threshold, the network message is subjected to segmented copying based on the length threshold and sent to the peripheral equipment; and if the data length is smaller than or equal to the length threshold, copying the network message and sending the network message to the peripheral equipment.
Optionally, the segment copying of the network packet may be to divide the network into a plurality of network sub-packets with data lengths not greater than a length threshold according to the data length of the network packet. For example, if the data length of a network packet of a specified type is 24, the network packet may be divided into 3 network sub-packets with data length of 8, and the network sub-packets with data length of 8 may be copied respectively; if the data length of a network packet of a specified type is 26, it can be divided into 3 network sub-packets with data length of 8 and 1 network sub-packet with data length of 2, and then the network sub-packets are copied to 4 network sub-packets respectively and sent to the peripheral device.
In some embodiments, the segment copying of the network packet may be to copy the data content of the initial length threshold in the network packet, copy the packet ID of the network packet, then subtract the length threshold from the data length of the corresponding network packet, point the pointer to the packet data field to the content after 8 bytes, and copy the data content corresponding to the length threshold and the packet ID of the network packet until the segment copying of the network packet is completed. Optionally, after the network message of the designated type is subjected to segment replication, the message ID of each network sub-message is the same.
In some embodiments, if the data length of a network packet of a specified type is not greater than the length threshold, the network packet is copied and sent to the peripheral device according to the method of step S440.
According to the message processing method provided by the embodiment of the application, the network message is obtained, the source channel corresponding to the network message is determined, and when the source channel is determined to be the same as the preset channel, the network messages of different types are copied according to the types of the network message. Compared with the processing method of the message shown in fig. 2, the embodiment can also copy the network message of the designated type with the data length greater than the length threshold in a segmented manner, and then send the network message of the segmented copy to the peripheral device, so that the problem that the data content is omitted when the data length of the network message is greater than the length threshold is avoided.
Referring to fig. 5, fig. 5 is a block diagram of a message processing apparatus according to an embodiment of the present application. The message processing device 500 is applied to the electronic device, and the message processing device 500 includes: a network message acquisition module 510, a judgment module 520, and a network message sending module 530, wherein:
a network message obtaining module 510, configured to obtain a network message, and determine a source channel corresponding to the network message; the judging module 520 is configured to judge whether the source channel is the same as a preset channel, where the preset channel is determined by the gateway based on a target instruction sent by a connected peripheral device; and the network message sending module 530 is configured to copy the network message and send the network message to the peripheral device if the source channel is the same as the preset channel.
In some embodiments, the network message acquisition module 510 includes: the triggering judging sub-module is used for judging whether an interrupt function in the gateway is triggered or not, wherein the interrupt function is triggered when the gateway receives a network message or sends the network message each time; and the network message acquisition sub-module is used for acquiring the network message if the interrupt function in the gateway is triggered.
In some embodiments, the network messaging module 530 includes: the network message replication sub-module is used for replicating and caching the network message if the source channel is the same as the preset channel; and the network message first sending sub-module is used for determining the sequence in which the interrupt function corresponding to the cached network message is triggered, and sequentially sending the cached network message to the peripheral according to the sequence.
In some embodiments, the network messaging module 530 further comprises: the type judging sub-module is used for judging whether the type of the network message is a designated type or not if the source channel is the same as the preset channel; and the second network message sending sub-module is used for copying the network message and sending the network message to the peripheral equipment if the type is not the appointed type.
In other embodiments, the network messaging module 530 further includes: a data length determining submodule, configured to determine a data length of the network packet if the type is the specified type; and the third network message sending sub-module is used for determining the length relation between the data length and the preset length, copying the network message based on the length relation and sending the copied network message to the peripheral equipment.
In some embodiments, the third sending submodule of the network packet includes: the network message segment copying unit is used for carrying out segment copying on the network message based on the length threshold value and sending the network message to the peripheral equipment if the data length is larger than the length threshold value; and the network message sending unit is used for copying the network message and sending the network message to the peripheral equipment if the data length is smaller than or equal to the length threshold value.
In still other embodiments, the network messaging module 530 further comprises: the network message replication sub-module is used for replicating and caching the network message if the source channel is the same as the preset channel; and the fourth network message sending sub-module is used for sending the cached network message to the peripheral equipment according to a preset time interval.
According to an aspect of the embodiments of the present application, there is further provided an electronic device, as shown in fig. 6, where the electronic device 600 includes a processor 610 and one or more memories 620, and the one or more memories 620 are configured to store program instructions executed by the processor 610, and the processor 610 implements the above-described object recognition method when executing the program instructions.
Further, the processor 610 may include one or more processing cores. The processor 610 executes or otherwise executes instructions, programs, code sets, or instruction sets stored in the memory 620 and invokes data stored in the memory 620. Alternatively, the processor 610 may be implemented in hardware in at least one of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), programmable logic array (Programmable Logic Array, PLA). The processor 610 may integrate one or a combination of several of a central processing unit (Central Processing Unt, CPU), an image processor (Graphics Processing Unit, GPU), and a modem, etc. The CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for being responsible for rendering and drawing of display content; the modem is used to handle wireless communications. It will be appreciated that the modem may not be integrated into the processor and may be implemented solely by a single communication chip.
According to an aspect of the present application, there is also provided a computer-readable storage medium that may be contained in the electronic device described in the above-described embodiment; or may exist alone without being incorporated into the electronic device. The computer readable storage medium carries computer readable instructions which, when executed by a processor, implement the method of any of the above embodiments.
It should be noted that, the computer readable medium shown in the embodiments of the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: 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 (Erasable Programmable Read Only Memory, EPROM), 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. In the present application, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. 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 of the foregoing. 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, wired, etc., or any suitable combination of the foregoing.
The units involved in the embodiments of the present application may be implemented by means of software, or may be implemented by means of hardware, and the described units may also be provided in a processor. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
It should be noted that although in the above detailed description several modules or units of a device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functions of two or more modules or units described above may be embodied in one module or unit, in accordance with embodiments of the present application. Conversely, the features and functions of one module or unit described above may be further divided into a plurality of modules or units to be embodied.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. Where each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains.
It is to be understood that the present application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (8)

1. The method for processing the message is characterized by comprising the following steps:
acquiring a network message and determining a source channel corresponding to the network message;
judging whether the source channel is the same as a preset channel, wherein the preset channel is determined by a gateway based on a target instruction sent by a connected peripheral;
if the source channel is the same as the preset channel, copying the network message and sending the network message to the peripheral, wherein if the source channel is the same as the preset channel, copying the network message and sending the network message to the peripheral comprises the following steps:
If the source channel is the same as the preset channel, judging whether the type of the network message is a designated type;
if the type is the appointed type, determining the data length of the network message;
determining a length relation between the data length and a preset length;
if the data length is greater than the length threshold, the network message is subjected to segmented copying based on the length threshold and sent to the peripheral, wherein the segmented copying is used for copying and splitting the network message into a plurality of network sub-messages so as to facilitate the sending of the plurality of network sub-messages corresponding to the network message to the peripheral;
and if the data length is smaller than or equal to the length threshold, copying the network message and sending the network message to the peripheral equipment.
2. The method of claim 1, wherein the obtaining the network message comprises:
judging whether an interrupt function in the gateway is triggered or not, wherein the interrupt function is triggered each time the gateway receives a network message or transmits the network message;
and if the interrupt function in the gateway is triggered, acquiring the network message.
3. The method of claim 1, wherein if the source channel is the same as the preset channel, copying the network message and sending the network message to the peripheral device, comprising:
If the source channel is the same as the preset channel, copying and caching the network message;
determining the sequence in which interrupt functions corresponding to the cached network messages are triggered, and sequentially sending the cached network messages to the peripheral equipment according to the sequence.
4. The method according to claim 1, wherein after the determining whether the type of the network packet is the specified type if the source channel is the same as the preset channel, the method further comprises:
and if the type is not the appointed type, copying the network message and sending the network message to the peripheral equipment.
5. The method according to any one of claims 1-4, wherein if the source channel is the same as the preset channel, copying the network message and sending the network message to the peripheral device includes:
if the source channel is the same as the preset channel, copying and caching the network message;
and sending the cached network message to the peripheral equipment according to a preset time interval.
6. A message processing apparatus, the apparatus comprising:
the network message acquisition module is used for acquiring a network message and determining a source channel corresponding to the network message;
The judging module is used for judging whether the source channel is the same as a preset channel or not, wherein the preset channel is determined by the gateway based on a target instruction sent by a connected peripheral;
and a network message sending module, configured to copy the network message and send the network message to the peripheral if the source channel is the same as the preset channel, where the network message sending module includes:
the type judging sub-module is used for judging whether the type of the network message is a designated type or not if the source channel is the same as the preset channel;
a data length determining submodule, configured to determine a data length of the network packet if the type is the specified type;
a length relation determining sub-module, configured to determine a length relation between the data length and a preset length;
a network message segment copying unit, configured to, if the data length is greater than a length threshold, perform segment copying on the network message based on the length threshold and send the network message to the peripheral device, where the segment copying is used to split the network message copy into multiple network sub-messages, so that multiple network sub-messages corresponding to the network message are sent to the peripheral device;
And the network message sending unit is used for copying the network message and sending the network message to the peripheral equipment if the data length is smaller than or equal to the length threshold value.
7. An electronic device, the electronic device comprising:
a processor;
a memory having stored thereon computer readable instructions which, when executed by the processor, implement the method of any of claims 1 to 5.
8. A computer readable storage medium having stored therein program code which is callable by a processor to perform the method of any one of claims 1 to 5.
CN202210859082.XA 2022-07-20 2022-07-20 Message processing method and device, electronic equipment and storage medium Active CN115633044B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210859082.XA CN115633044B (en) 2022-07-20 2022-07-20 Message processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210859082.XA CN115633044B (en) 2022-07-20 2022-07-20 Message processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115633044A CN115633044A (en) 2023-01-20
CN115633044B true CN115633044B (en) 2024-01-19

Family

ID=84903202

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210859082.XA Active CN115633044B (en) 2022-07-20 2022-07-20 Message processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115633044B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103293008A (en) * 2013-06-27 2013-09-11 长城汽车股份有限公司 Automobile diagnosing device
CN104240334A (en) * 2014-09-30 2014-12-24 长城汽车股份有限公司 Pulse signal recorder for automobile and automobile detecting equipment
CN106992879A (en) * 2017-03-14 2017-07-28 中国第汽车股份有限公司 A kind of computational methods of CAN load factor
CN109660436A (en) * 2018-12-18 2019-04-19 广州亚美信息科技有限公司 A kind of double CAN channel data processing methods, gateway and system
CN111586210A (en) * 2020-04-22 2020-08-25 东风商用车有限公司 Multichannel CAN bus OBD diagnostic protocol conversion device
WO2021184551A1 (en) * 2020-03-18 2021-09-23 平安科技(深圳)有限公司 Communication method and apparatus based on plurality of networks, electronic device, and storage medium
CN114189573A (en) * 2022-02-15 2022-03-15 中国汽车技术研究中心有限公司 CAN signal analysis method and system
WO2022116953A1 (en) * 2020-12-01 2022-06-09 阿里巴巴集团控股有限公司 Packet processing method, device, system, and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8086368B2 (en) * 2009-01-06 2011-12-27 Bosch Security Systems Inc. Variable function communication gateway for vehicles

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103293008A (en) * 2013-06-27 2013-09-11 长城汽车股份有限公司 Automobile diagnosing device
CN104240334A (en) * 2014-09-30 2014-12-24 长城汽车股份有限公司 Pulse signal recorder for automobile and automobile detecting equipment
CN106992879A (en) * 2017-03-14 2017-07-28 中国第汽车股份有限公司 A kind of computational methods of CAN load factor
CN109660436A (en) * 2018-12-18 2019-04-19 广州亚美信息科技有限公司 A kind of double CAN channel data processing methods, gateway and system
WO2021184551A1 (en) * 2020-03-18 2021-09-23 平安科技(深圳)有限公司 Communication method and apparatus based on plurality of networks, electronic device, and storage medium
CN111586210A (en) * 2020-04-22 2020-08-25 东风商用车有限公司 Multichannel CAN bus OBD diagnostic protocol conversion device
WO2022116953A1 (en) * 2020-12-01 2022-06-09 阿里巴巴集团控股有限公司 Packet processing method, device, system, and storage medium
CN114189573A (en) * 2022-02-15 2022-03-15 中国汽车技术研究中心有限公司 CAN signal analysis method and system

Also Published As

Publication number Publication date
CN115633044A (en) 2023-01-20

Similar Documents

Publication Publication Date Title
US11546088B2 (en) Check code processing method, electronic device and storage medium
CN108347476B (en) Cross-machine-room data synchronization method and device and server
CN113472607B (en) Application program network environment detection method, device, equipment and storage medium
US11734077B2 (en) Evaluation device, evaluation method and evaluation program
CN112822260B (en) File transmission method and device, electronic equipment and storage medium
CN114710224A (en) Frame synchronization method and device, computer readable medium and electronic device
CN111787098B (en) Earphone upgrading method and device, earphone and storage medium
US20140107863A1 (en) Vehicle Control Device, Vehicle Control System
CN107094085B (en) Signaling transmission method and device
CN110554929B (en) Data verification method, device, computer equipment and storage medium
CN108038127B (en) Data synchronization method, device, terminal equipment and storage medium
CN112732560B (en) Method and device for detecting leakage risk of file descriptor
CN115633044B (en) Message processing method and device, electronic equipment and storage medium
WO2021134418A1 (en) Data checking method and apparatus
CN104618474B (en) Facility information store method and device
CN108400901B (en) Application testing method, terminal device and computer readable storage medium
CN109743133B (en) Data reconciliation method and device
CN112749142B (en) Handle management method and system
CN111858379A (en) Application testing method and device
CN112199529A (en) Picture processing method and device, electronic equipment and storage medium
CN111988391A (en) Message sending method and device
CN112055058A (en) Data storage method and device and computer readable storage medium
CN115002135B (en) Multi-terminal cooperation method, device, system and computer readable storage medium
CN113064869B (en) Log processing method, device, transmitting end, receiving end equipment and storage medium
CN111478755B (en) Asynchronous data communication method, medium, equipment and asynchronous data communication system

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