CN115633044A - 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
CN115633044A
CN115633044A CN202210859082.XA CN202210859082A CN115633044A CN 115633044 A CN115633044 A CN 115633044A CN 202210859082 A CN202210859082 A CN 202210859082A CN 115633044 A CN115633044 A CN 115633044A
Authority
CN
China
Prior art keywords
network
network message
channel
message
sending
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210859082.XA
Other languages
Chinese (zh)
Other versions
CN115633044B (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

Images

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 or not, 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. According to the method and the device, the network message which needs to be copied CAN be selected by modifying the source channel, so that the need of modifying a register and restarting a corresponding CAN module is avoided, and further, the situation that error frames do not occur in the copied network message is ensured; meanwhile, the stability of the network message sent to the peripheral equipment is improved.

Description

Message processing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of automotive electronics, and in particular, to a method and an apparatus for processing a packet, an electronic device, and a storage medium.
Background
At present, new national standard regulations require an On Board Diagnostics (OBD) system to allow only one path of diagnostic CAN to be connected out, but there is a demand for checking messages of other application CANs in the process of debugging the CAN, so how to check messages of other CANs under the condition that only one path of diagnostic CAN is allowed to be connected out is a problem to be solved urgently at present.
Disclosure of Invention
In view of this, embodiments of the present application provide a method and an apparatus for processing a message, an electronic device, and a storage medium, so as to solve the above problem.
According to an aspect of the embodiments of the present application, a method for processing a packet is provided, 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 or not, 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 the embodiments of the present application, there is provided a device for processing a packet, the device including: 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; a memory having computer readable instructions stored thereon, which when executed by the processor, implement a method of processing a message as described above.
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 for processing a message as described above.
According to the scheme, 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 equipment, wherein the preset channel is determined by the gateway based on the target instruction sent by the connected peripheral equipment, 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 an error frame does not occur in the copied network message is guaranteed; meanwhile, the stability of the network message sent to the peripheral equipment 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 present application and together with the description, serve to explain the principles of the application. It is obvious that the drawings in the following description are only some embodiments of the application, and that for a person skilled in the art, other drawings can be derived from them without inventive effort.
Fig. 1 is a schematic diagram illustrating an application scenario applicable to the present application according to an embodiment of the present application.
Fig. 2 is a flowchart illustrating a message processing method according to an embodiment of the present application.
Fig. 3 is a flowchart illustrating a message processing method according to another embodiment of the present application.
Fig. 4 is a flowchart illustrating a message processing method according to yet 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 block diagram of an electronic device according to an embodiment of the present application.
While specific embodiments of the invention have been illustrated and described in detail in the foregoing drawings, the drawings and detailed description are not intended to limit the scope of the inventive concept in any way, but rather to illustrate it by a person skilled in the art with the aid of specific embodiments.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different 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 example embodiments to those skilled in the art.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Moreover, 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 explicitly 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 application. One skilled in the relevant art will recognize, however, that the subject matter of the present application can be practiced without one or more of the specific details, or with other methods, apparatus, steps, and so forth. In other instances, well-known methods, devices, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the application.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means. The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to 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 actual execution sequence may be changed according to the actual situation.
At present, part of the hardware of the chip has a mirror image routing function, and the function associates the sending hardware Buffer and the receiving hardware Buffer of the source channel with the sending Buffer of the gateway through register configuration, so that the network messages received and sent by the path of the CAN CAN be directly forwarded to the corresponding diagnosis CAN through the hardware, and further, the function of the corresponding mirror image routing is realized.
However, in the hardware mirror routing, the binding between the source CAN and the diagnostic CAN be realized only when the chip CAN module is in the initialization mode, if other route CANs are routed to the diagnostic CAN, the CAN module needs to be restarted, so that the binding between the source CAN and the diagnostic CAN is carried out again, and in the restarting process, the functions of receiving and sending messages of the gateway CAN be possibly disabled.
When 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 transmission Buffer, and is not the actual appearance sequence of the message on the CAN. In fact, after the message of the source CAN is sent to the sending Buffer, the message may not be actually sent out due to the message arbitration, so that the problem of inaccurate sending sequence of the message may occur.
Because the mirror routing CAN be performed only on the CAN of the conventional type at present, and the data length of the network message of the CAN of the conventional type is not more than 8, the corresponding hardware mirror routing CAN only copy the network message corresponding to the CAN of the conventional type, but the network message of the corresponding source channel may also be of the CANFD type, and the data length of the network message of the CANFD type is greater than 8, and at this time, the mirror routing cannot be performed on the message of which the data length is greater than 8.
In view of the above problems, the inventors have found, through long-term research, that a method, an apparatus, an electronic device, and a storage medium for processing a packet provided in an embodiment of the present application are provided, where a target instruction including a preset channel is sent to a gateway through an external device, and the gateway CAN determine, according to a source channel of an acquired network packet, whether the source channel corresponding to the acquired network packet is the same as the preset channel, so as to avoid the need to modify a register and restart a corresponding CAN module, thereby ensuring that no error frame occurs in a copied network packet; meanwhile, the stability of the network message sent to the peripheral equipment is improved. The specific message processing method is described in detail in the following embodiments.
Fig. 1 is a diagram illustrating an application scenario applicable to the present application 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 therein, and the peripheral device 200 interacts with the on-board gateway 110 of the vehicle 100. The peripherals 200 are connected with the in-vehicle gateway 110 of the vehicle 100 through an in-vehicle diagnostic interface in the vehicle. Optionally, the peripheral 200 may be an external diagnostic apparatus, a notebook computer, an external display, and the like, which is not 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 gateway 110 in the vehicle 100 acquires a network message sent by a controller connected with the vehicle gateway, and determines a source channel corresponding to the network message, and then the vehicle gateway 110 compares the source channel of the network message with a preset channel set by the peripheral 200 through a target instruction, so as to determine whether the source channel is the same as the preset channel; when the vehicle-mounted gateway 110 determines that the source channel corresponding to the network packet is the same as the preset channel, the network packet is copied, and the copied network packet is sent to the peripheral device 200.
Referring to fig. 2, fig. 2 is a flow chart illustrating a message processing method according to an embodiment of the present application. The message processing method determines whether the source channel of the obtained network message is the same as the preset channel by judging whether the source channel is the same as the preset channel or not, and copies the network message and sends the network message to an external device 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 error frames cannot appear in the copied network message; meanwhile, the stability of the network message sent to the peripheral equipment is improved. In a specific embodiment, the method for processing a message may be applied to the message processing apparatus 500 shown in fig. 5 and the electronic device 600 (fig. 6) configuring the message processing apparatus 500. Specific processes of the present embodiment will be described below, and it is understood that the peripheral devices according to the present embodiment may include, but are not limited to, an external diagnostic apparatus, a notebook computer, an external display, and the like. As will be described in detail with respect to the flow shown in fig. 2, the method for processing a packet may specifically 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 external equipment connected with the gateway. The source channel is a channel for transmitting the network packet of the controller to the gateway, and it can be understood that the source channel indicates the source of the network packet, that is, the controller for sending the network packet can be determined according to the source channel of the network packet.
In some embodiments, in the process of sending a network packet to a gateway through a source channel, identification information of the source channel may be added to the network packet, and then the source channel corresponding to the network packet may be determined according to the identification information.
In other embodiments, after the network packet is obtained, the source channel of the network packet may be determined according to the mapping relationship between the network packet and the source channel corresponding to each network packet by setting the mapping relationship between each network packet and the source channel corresponding to each network packet.
In some embodiments, step S210 may include determining whether an interrupt function in a gateway is triggered, where the interrupt function is triggered each time the gateway receives a network packet or sends a network packet; and if the interrupt function in the gateway is triggered, acquiring the network message.
The interrupt function is a function that when a certain condition is satisfied, the execution content of the main function is suspended, and the interrupt function is executed. The interrupt function can be triggered by software or hardware, and the triggering mode can be selected according to the actual requirement. As a manner, if the interrupt function is triggered by software, optionally, the interrupt function may be triggered by presetting an interrupt instruction of the interrupt function, and then sending the interrupt instruction of the interrupt function to the gateway, where the gateway triggers the interrupt function according to the interrupt instruction.
As another mode, if the interrupt function is triggered by hardware, optionally, the terminal function may be triggered by a serial port interrupt mode, 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 can be understood that, since the network packet includes the packet end frame, the interrupt function is triggered when the register in the gateway receives the data and detects the end frame in the network packet.
As yet another way, the interruption can also be implemented by timing an interruption function. Optionally, a time interval for triggering the interrupt function is set in a timer of the gateway, and then the gateway triggers the interrupt function according to the time interval. For example, when the time interval of the interrupt function is set in the timer to be 40ms, the gateway triggers the interrupt function according to the frequency of once every 40ms, and the specific time interval may be set according to actual needs, which is not specifically limited herein.
As another way, an interrupt flag may be set in the network packet, and after receiving the network packet, the gateway triggers an interrupt function 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; when E =0, the interruption function is not triggered, and the triggering of the interruption function can be judged by the value of E.
In other embodiments, it may also be determined whether the interrupt function is triggered by determining whether a level in hardware associated with the interrupt function in the gateway has changed. For example, it may be determined that the termination function is triggered when a level in hardware associated with the interrupt function changes from a low level to a high level, or from a high level to a low level.
As a mode, since the interrupt function is triggered when the gateway receives a network packet or when the gateway sends a network packet each time, in order to avoid that the gateway cannot trigger the interrupt function after receiving a network packet 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 corresponding interrupt flag when the interrupt function is not triggered; or restoring the level in the hardware associated with the interrupt function in the gateway to the corresponding level when the interrupt function is not triggered.
When it is determined that the interrupt function in the gateway is triggered, it is determined that the gateway receives a complete network packet, and the received network packet can be directly acquired.
Referring 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 device is an external device connected through an On Board Diagnostics (OBD) of a vehicle, for example, an external diagnostic device, a notebook computer, an external display, and the like, and may be provided according to actual needs, which is not particularly limited herein.
In some embodiments, the target instruction refers to a command of a preset channel set by an external device that needs to be mirrored. As one mode, the external diagnostic apparatus may set a channel that needs to copy the network packet by sending a data ID command (Date ID, DID) to the gateway, and the gateway sets corresponding channel information according to the DID command. Optionally, the DID command may include an ID of a controller sending the network packet, a channel ID, and the like.
In other embodiments, the gateway may pre-define a variable Var _ BufferSate, that is, a channel variable is pre-defined, which is used to record a status flag bit indicating whether mirror routing needs to be started in a Buffer (Buffer) for receiving and sending network messages of each path of the CAN or each controller in the gateway, then set a Buffer of a CAN network message that needs to be copied through an external device, and send the Buffer to the gateway, and after receiving the Buffer, the gateway changes the mirror routing status flag bit of a corresponding CAN in the Var _ BufferSate, which receives the Buffer, to be started, where mirror routing refers to copying a 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, a corresponding channel identifier may be set in a preset channel, and whether the source channel is the same as the preset channel is determined by comparing whether the channel identifier of the source channel is the same as the channel identifier of the preset channel. For example, if there are 5 paths of the CAN in the gateway, the channel identifiers of the source channels corresponding to the network packet are a, B, C, D, and E, respectively, and the channel identifier of the preset channel is B, at this time, the gateway receives a network packet whose channel identifier is B, and the channel identifier of the preset channel is the same as the source channel identifier of the network packet, so that it CAN be determined that the source channel of the network packet is the same as the preset channel.
In other embodiments, a first identifier corresponding to the received and sent buffers of each CAN or controller may be set, a second identifier corresponding to the buffers of the network packet of the CAN that needs to be copied may also be set, and 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 packet and sending the network packet to the peripheral.
When the source channel is the same as the preset channel, the network message transmitted to the gateway through the source channel can be determined to be a message which needs to be copied currently, at the moment, the network message is copied, the copied network message is sent to the external equipment, and the external equipment can perform work such as fault diagnosis and the like according to the network message.
In some embodiments, the data length of the network packet may also be determined before the network packet is copied, generally, the longest data length of the network packet that can be copied should not exceed a length threshold, if the data length of the network packet is greater than the length threshold, it is necessary to copy data content in the network packet that has a data length equal to the length threshold, then copy the data content in the network packet that exceeds the length threshold, and finally send the copied network packet to the peripheral according to the order of copying.
In some embodiments, the copied network message may be temporarily stored in the Buffer, and after the copied network message is successfully sent to the external device, the corresponding content in the Buffer storing the network message is deleted, so as to reduce the storage pressure of the gateway and facilitate the next network message sending.
In other embodiments, content storage variables may be predefined, where each content storage variable may store data content of a network packet whose data length is not greater than a length threshold, and when a network packet corresponding to a content storage variable is successfully sent, a pointer of the content storage variable of the network packet is pointed to a next content storage variable, so that the network packet is conveniently sent to an external device in an order in which the network packet is cached to the content storage variable.
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 and a vehicle-mounted terminal (T-BOX), and the vehicle-mounted terminal, after receiving the network message, may upload the network message to an electronic device or a cloud server in communication connection with the vehicle-mounted terminal, optionally, the communication connection may be a connection of the same local area network, bluetooth, zigBee (ZigBee) network, and the like, where no specific limitation is made, and the electronic device may include a smart phone, a tablet computer, a wearable electronic device, and the like.
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 external device according to a preset time interval.
In some embodiments, a time interval or frequency for sending the copied network packet to the peripheral device may be preset, and then the copied network packet is sent to the peripheral device according to the time interval or frequency, so that a problem of packet arbitration when the copied network packets are sent together can be avoided, and a situation of congestion when the gateway sends the network packet to the peripheral device can also be avoided.
In other embodiments, a periodic function for message sending may be preset, and the periodic function may be triggered according to a preset time interval to implement sending the copied network message to the peripheral device.
In other embodiments, the network packet may also be sent to the peripheral device by determining the number of the cached network packets, and optionally, when the number of the cached network packets is greater than the number threshold, the cached network packets are sent to the peripheral device. For example, when the quantity threshold is 0, as long as there is a cached network packet, immediately sending the cached network packet to the external device. Specifically, the number threshold may be set according to actual needs, and is not particularly limited.
In other embodiments, a variable may be predefined for calculating the number of network packets cached in the gateway, and the network packets cached in the gateway may be understood as duplicate network packets that have not been sent. After the copied network message is cached, the variable is accumulated to be +1, when the periodic function of message sending is triggered, whether the variable is larger than 0 or not can be judged, when the variable is larger than 0, the cached network message is sent to an external device, 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, 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 equipment, wherein the preset channel is determined by the gateway based on the target instruction sent by the connected peripheral equipment, so that the network message needing to be copied CAN be selected by modifying the source channel, the register needing to be modified and the corresponding CAN module needing to be restarted are avoided, and further, the situation that error frames do not occur in the copied network message is ensured; meanwhile, the stability of the network message sent to the peripheral equipment is improved.
Referring to fig. 3, fig. 3 is a schematic flowchart illustrating a method for processing a packet according to an embodiment of the present application. The method is applied to a gateway, and will be described in detail with respect to the flow shown in fig. 3, where the text processing method specifically includes the following steps:
step S310, obtaining a network message and determining a source channel corresponding to the network message.
Step S320, determining whether the source channel is the same as a preset channel, where the preset channel is determined by a gateway based on a target instruction sent by a connected peripheral.
For detailed description of step S310 and step S310, please refer to step S210 and step S220, which are not described herein again.
Step S330, if the source channel is the same as the preset channel, copying the network message and caching.
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 copied currently, and at this time, the network packet is copied and the copied network packet is cached, so that the gateway sends the copied network packet to the peripheral device.
In some embodiments, the copied network message may be temporarily buffered in a non-volatile Memory, for example, the copied network message may be buffered in an Erasable Programmable Read Only Memory (EPROM) or an Electrically Erasable Programmable Read Only Memory (EEPROM). In another embodiment, the copied network packet may be cached in a flash memory (flash memory), so as to delete the successfully sent packet, and facilitate the next sending of the copied other network packet.
Step S340, determining an order in which the interrupt functions corresponding to the cached network packets are triggered, and sequentially sending the cached network packets to the peripheral device according to the order.
At present, when a copied network message is sent to an external device, the sequence of sending the copied network message is sent according to the cache sequence of the network message in a gateway, and is not the sequence of receiving or sending the network message by the gateway. Actually, when the gateway sends the network packet, the network packet may not be successfully sent actually due to packet arbitration, and therefore when the gateway copies the network packet, a problem that the sequence of the copied network packet is different from the sending sequence of the network packet sent by the gateway may occur, and further the network packet received by the peripheral device is different from the sending or receiving sequence of the network packet in the gateway. In order to solve the problem, the copied network message is sent to the peripheral equipment according to the sequence that the network message is sent to the gateway by a source channel in the gateway or the corresponding interrupt function is triggered when the network message is sent by the gateway, so that the problem that the sequence of the network message is not accurate is avoided.
When the gateway receives the network messages or sends the network messages each time, the interruption functions are triggered, the triggered sequence of the interruption functions is the sequence of the network messages received or sent by the gateway, the cached copied network messages are sent to the peripheral equipment according to the triggered sequence of the interruption functions, and the sequence accuracy of the network messages 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 buffered, and then the order in which the interrupt function corresponding to the buffered network message is triggered may be determined according to the time stamp of the interrupt function when triggered.
In other embodiments, the sequence identification information may be set in the corresponding network packet according to the function triggered by the interrupt function, and then the sequence in which the interrupt function corresponding to the cached network packet is triggered may be determined according to the sequence identification information. For example, when the first interruption function is triggered, the corresponding network packet sets sequence identification information to be 1st (first), and when the second interruption function is triggered, the corresponding network packet sets sequence identification information to be 2nd (second), and the like, where a specific sequence identification may be set according to an actual need, and is not limited herein.
The method for processing the message, provided by the embodiment of the application, includes acquiring a network message, determining a source channel corresponding to the network message, copying and caching the network message when it is determined that the source channel is the same as a preset channel, and then sending the cached network message to an external device according to a sequence in which an interrupt function in a gateway is triggered. Compared with the message processing method shown in fig. 2, in this embodiment, the sequence of sending the network message to the gateway may also be copied to send the copied network message to the peripheral, so as to improve the accuracy of the analysis work performed based on the network message after training.
Referring to fig. 4, fig. 4 is a schematic flowchart illustrating a method for processing a packet according to an embodiment of the present application. The method is applied to a gateway, and will be described in detail with respect to the flow shown in fig. 4, where the text processing method may specifically include the following steps:
step S410, obtaining a network message, and determining a source channel corresponding to the network message.
Step S420, 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 a connected peripheral.
For detailed description of step S410 and step S410, please refer to step S210 and step S220, which are not described herein again.
Step S430, if the source channel is the same as the preset channel, determining whether the type of the network packet is an appointed 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 CAN type network message is most different from the CAN FD type network message in that a Data Length Code (DLC) is different, and the DLC is used to specify the number of bytes of a Data field in the network message. The DLC of a network message of CAN type is maximum 8 (i.e. maximum number of bytes is 8), whereas the data length code DLC of a network message of CAN FD type is maximum 64, wherein the DLC determines the data length in the network message.
At present, when a network message is copied, when the network message is a CAN-type network message and the DLC thereof is 0 to 8, the network message with the corresponding data length CAN be copied. However, for the CAN FD type network message, because the DLC is larger than 8, only the data content of the DLC in the network message CAN be copied, so to ensure that the CAN FD type network message CAN also be completely copied and sent to the peripheral, the type of the network message may be determined first, and a subsequent method for copying the network message may be determined according to the type of the current network message.
In some embodiments, the specified type refers to the CAN FD type, but may be other types where the DLC is greater than 8.
In some embodiments, a packet identifier may be set in advance for a specified type of network packet, and it may be determined whether the type of the network packet is the specified type according to the packet identifier.
Step S440, if the type is not the designated type, copying the network message and sending the network message to the peripheral.
When the type of the network message is not the designated type, the situation that data content is missed 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 to 64, the data length of the network packet of the specified type needs to be determined again, and if the data length of the network packet of the specified type is between 0 and 8, the network packet may be copied according to the method of step S440. If the data length of the network packet of the specified type is greater than 8, the network packet needs to be copied in other ways.
Step S460, determining a length relationship between the data length and a preset length, copying the network packet based on the length relationship, and sending the network packet to the peripheral.
The length relationship between the data length of the network packet of the specified type and the preset length 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 packet of the specified type is not greater than the preset length, the network packet 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 may be divided into a plurality of network sub-messages of which the data length is not greater than the preset length, and then the plurality of network sub-messages are respectively copied according to the method of step S440, and the copied network message is sent to the peripheral.
In some embodiments, it may be determined whether data exists in bytes of the network packet after the preset length, and if it is determined that data exists, it may be determined that a 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 larger than the length threshold value, the network message is copied in a segmented mode based on the length threshold value and is 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 step of performing segment replication on the network packet may be dividing the network into a plurality of network sub-packets, where the data length of each network sub-packet is not greater than the length threshold, according to the data length of the network packet. For example, if the data length of a network packet of a specific type is 24, the network packet may be divided into 3 network sub-packets with data length of 8, and then the network sub-packets with data length of 8 are respectively copied; if the data length of a network packet of a specific type is 26, the network packet 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 and sent to the peripheral device respectively corresponding to the 4 network sub-packets.
In some embodiments, the step of performing segment copy on 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, subtract the length threshold from the data length of the corresponding network packet, point the pointer pointing 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 copy of the network packet is completed. Optionally, after the network packet of the specified type is copied in segments, the packet IDs of the network sub-packets are 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, different types of network messages are respectively copied according to the type of the network message. Compared with the message processing method shown in fig. 2, the embodiment may also perform segment copying on the network message of the specified type whose data length is greater than the length threshold, and then send the segment copied network message to the peripheral, so as to avoid the problem of data content omission when the data length of the network message is greater than the length threshold.
Referring to fig. 5, fig. 5 is a block diagram of a module of a message processing apparatus according to an embodiment of the present disclosure. The message processing apparatus 500 is applied to the electronic device, and the message processing apparatus 500 includes: a network message obtaining module 510, a judging module 520 and a network message sending module 530, wherein:
a network packet obtaining module 510, configured to obtain a network packet and determine a source channel corresponding to the network packet; a judging module 520, configured to judge whether the source channel is the same as a preset channel, where the preset channel is determined by a gateway based on a target instruction sent by a connected peripheral; a network packet sending module 530, configured to copy the network packet and send the network packet to the peripheral device if the source channel is the same as the preset channel.
In some embodiments, the network packet obtaining module 510 includes: a triggering judgment sub-module, configured to judge whether an interrupt function in the gateway is triggered, where the interrupt function is triggered each time the gateway receives a network packet or sends a network packet; 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 first network message sending submodule is used for determining the triggering sequence of the interrupt functions corresponding to the cached network messages and sending the cached network messages to the peripheral equipment in sequence according to the sequence.
In some embodiments, the network messaging module 530 further comprises: the type judgment submodule is used for judging whether the type of the network message is an appointed type or not if the source channel is the same as the preset channel; and the second network message sending submodule is used for copying the network message and sending the network message to the peripheral if the type is not the specified type.
In other embodiments, the network messaging module 530 further comprises: a data length determining sub-module, configured to determine a data length of the network packet if the type is the specified type; and the third network message sending submodule 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 network message to the peripheral.
In some embodiments, the network message third sending submodule includes: the network message segment copying unit is used for copying the network message segment by segment based on the length threshold value and sending the network message segment to the peripheral if the data length is greater 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 if the data length is less than or equal to the length threshold.
In still other embodiments, the network messaging module 530 further comprises: a network message copying submodule, configured to copy and cache the network message if the source channel is the same as the preset channel; and the fourth network message sending submodule is used for sending the cached network messages to the peripheral equipment according to a preset time interval.
According to an aspect of an embodiment of the present application, there is further provided an electronic device, as shown in fig. 6, the electronic device 600 includes a processor 610 and one or more memories 620, where the one or more memories 620 are used for storing program instructions executed by the processor 610, and the processor 610 executes the program instructions to implement the object identification method.
Further, processor 610 may include one or more processing cores. The processor 610 executes or 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 using at least one of Digital Signal Processing (DSP), field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 610 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. The CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing display content; the modem is used to handle wireless communications. It is understood that the above modem may be implemented by a communication chip without being integrated into the processor.
According to an aspect of the present application, there is also provided a computer-readable storage medium, which may be included in the electronic device described in the above embodiment; or may exist separately without being assembled into the electronic device. The computer-readable storage medium carries computer-readable instructions that, when executed by a processor, perform the method of any of the embodiments described above.
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. 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 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 (EPROM), a 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 present application, 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 this application, however, 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 many 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, wired, etc., or any suitable combination of the foregoing.
The units described in the embodiments of the present application may be implemented by software or by hardware, and the described units may also be disposed in a processor. The names of these elements do not in some cases constitute a limitation on the elements themselves.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the application. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
The flowchart 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. 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 invention 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 invention pertains.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (10)

1. A method for processing a message, the method comprising:
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 or not, 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.
2. The method of claim 1, wherein the obtaining the network packet comprises:
judging whether an interrupt function in the gateway is triggered, wherein the interrupt function is triggered when the gateway receives a network message or sends the network message each time;
and if the interruption 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 predetermined channel, copying the network packet and sending the network packet to the peripheral device comprises:
if the source channel is the same as the preset channel, copying and caching the network message;
determining the sequence of triggering the interrupt functions corresponding to the cached network messages, and sequentially sending the cached network messages to the peripheral equipment according to the sequence.
4. The method of claim 1, wherein if the source channel is the same as the predetermined channel, copying the network packet and sending the network packet to the peripheral device comprises:
if the source channel is the same as the preset channel, judging whether the type of the network message is a specified type;
and if the type is not the specified type, copying the network message and sending the network message to the peripheral equipment.
5. The method of claim 4, further comprising:
if the type is the specified type, determining the data length of the network message;
and determining the 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.
6. The method according to claim 5, wherein the determining a length relationship between the data length and a preset length, and copying and sending the network packet to the peripheral device based on the length relationship comprises:
if the data length is larger than the length threshold value, the network message is copied in a segmented mode based on the length threshold value and is 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.
7. The method according to any one of claims 1 to 6, wherein the copying and sending the network packet to the peripheral device if the source channel is the same as the predetermined channel 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.
8. An apparatus for processing a packet, 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 a 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.
9. An electronic device, characterized in that the electronic device comprises:
a processor;
a memory having stored thereon computer readable instructions which, when executed by the processor, implement the method of any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that a program code is stored in the computer-readable storage medium, which program code can be called by a processor to execute the method according to any one of claims 1 to 7.
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 true CN115633044A (en) 2023-01-20
CN115633044B 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 (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100174439A1 (en) * 2009-01-06 2010-07-08 Robert Bosch Gmbh Variable function communication gateway for vehicles
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

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100174439A1 (en) * 2009-01-06 2010-07-08 Robert Bosch Gmbh Variable function communication gateway for vehicles
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
CN115633044B (en) 2024-01-19

Similar Documents

Publication Publication Date Title
US11546088B2 (en) Check code processing method, electronic device and storage medium
CN110022259B (en) Message arrival rate determining method and device, data statistics server and storage medium
CN105657000A (en) Message transmission method and device
CN114710224A (en) Frame synchronization method and device, computer readable medium and electronic device
CN111787098B (en) Earphone upgrading method and device, earphone and storage medium
WO2021134418A1 (en) Data checking method and apparatus
CN107094085B (en) Signaling transmission method and device
CN114095876A (en) Broadcast data processing method and device, storage medium and electronic device
CN108038127B (en) Data synchronization method, device, terminal equipment and storage medium
CN111818582B (en) Data transmission method and device and electronic equipment
CN112422485B (en) Communication method and device of transmission control protocol
CN115633044B (en) Message processing method and device, electronic equipment and storage medium
CN108400901B (en) Application testing method, terminal device and computer readable storage medium
CN107171915B (en) Communication protocol changing method and device
CN111757371A (en) Statistical method of transmission delay, server and storage medium
CN112256714A (en) Data synchronization method and device, electronic equipment and computer readable medium
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
CN109656169A (en) Multiple dispatch table switching method, device, computer equipment and storage medium
CN112711436B (en) Message processing method and device
CN114817100B (en) Data reading method and device for single board
CN117411837A (en) Multicast message copying method and device, electronic equipment and storage medium
CN117873749A (en) Airborne computer intelligent platform management bus system
CN107203559B (en) Method and device for dividing data strips
CN114185804A (en) Interface testing method and device and terminal equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant