A kind of OSEK COM message dynamic dispatching method based on the CAN network
Technical field
The invention belongs to CAN network communications technology field, refer in particular to a kind of OSEKCOM message dynamic dispatching method based on the CAN network.
Background technology
Compatibility between the portability of application software and the control module of different vendor, open system and interface-OSEK (the OpenSystems and the Corresponding Interface For Automotive Electronics) standard impelling the German automobiles industrial quarters to unite in 1993 to have proposed automotive electronics are intended to provide for the distribution control unit on the automobile industrial standard of an open architecture.Wherein OSEK communication standard (OSEK COM) has been stipulated the exchanges data behavior between ECU inside and a plurality of ECU, and unified communication environment is provided between the application software for automobile control unit.Fig. 1 is the hierarchical model figure of OSEK COM.
The message scheduling problem of a lot of people's researchs on the CAN network, because the uncertainty of CAN upper layer network, these researchs are general CAN message scheduling problem basically.Be not suitable in the communication system of OSEK COM as the CAN upper strata.
The CAN bus protocol has only defined physical layer and data link layer, and undefined application layer is not stipulated the producing method of the identifier of CAN frame.If we use the bottom communication network of CAN frame as OSEK COM, need solve two problems: the 1) IPDU of the OSEK COM layer problem of on the CAN network, dispatching.2) length is greater than the transmission problem of the I-PDU of 8 bytes.The present invention proposes a kind of dynamic dispatching method of CAN message, combine closely, formed OSEK COM communication system, be applicable to the communication behavior of vehicle electric field with OSEK COM module.
Summary of the invention
In order to overcome the above problems, the present invention proposes a kind of OSEK COM message dynamic dispatching method based on the CAN network.The IPDU of OSEK COM layer can dynamic dispatching on the CAN network, and it is hungry to death to guarantee certain node not occur.
A kind of OSEK COM message dynamic dispatching method based on the CAN network, in the OSEK COM communication system based on the CAN network, second territory of an expansion CAN frame identifier high position is made up of IPDU ID, on same ECU, the data cell that IPDU ID is more little has high more priority; Each ECU node distributes a node priority, and adjusts the node priority of each ECU in the running of network dynamically, and the assurance IPDU message of trying one's best is by hungry to death.
Further, described node priority is the highest territory of the CAN ID of expansion CAN frame, and each the ECU node on the CAN network all allows to have n node priority, and different, but in some moment, node only allows a node priority.
Further, described node priority is dynamically adjusted in the scope that this node allows according to the actual conditions of network, and it is tactful as follows that it is dynamically adjusted:
The user is L ms according to the adjustment priority time of the actual conditions configuration node i of node i, and the maximum frequency of failure that in the time of L ms, can stand of configure user Mi time, broadcast on the CAN bus, all nodes on the bus are all received this message simultaneously, and all receive that the local node of message is according to following protocol update node priority; Each node has periodic triggered time Li, at this constantly, and node i:
(1). inspection has surpassed Mi at whether L sends failure in the time number of times, if surpassed, Go to 2; Otherwise do not do any operation;
(2). node i improves his priority in the scope of its node priority permission, if CurrentNodePrioi=x (node priority of i is x at present), after improving, CurrentNodePrioi=x<n? x:x-n.Go?to3;
(3). broadcast a special standard CAN frame and notify other node to reduce their node priority; After node i broadcasting particular criteria CAN frame, other all nodes:
1). other all nodes are received special standard CAN frame at the same time;
2). other nodes all reduce their node priority; With j is example, if CurrentNodePrioj=y (the current node priority of node j is y), after then adjusting, CurrentNodeProj=y〉(n-1) * n? y:y+n.
Further, the CAN ID of special standard CAN frame is a node serial number in described (3), and data length is 0.
Further, described expansion CAN frame is 29 a Extended Superframe Format, and CAN ID is divided into 4 territories, when sending, transmit leg is cut into appropriate C AN frame to the message greater than 8 bytes, and relevant segmentation control information is put among IPDUFragNum and the IPDUFragIndex, sends together; The recipient receives after the CAN frame, according to IPDUFragNum and two territories of IPDUFragIndex the CAN frame of segmentation is assembled into complete IPDU message.
In this agreement, if a node does not send data for a long time, perhaps the present node priority of a node can satisfy the data sending request of this node fully, and we just reduce the node priority of this node so.And require than higher node for frequent transmission and message real-time, this consultation improves the node priority of this node.This specific character is to match with many practical applications.
If at a time, all nodes do not need to adjust node priority, i.e. the continuous adjustment of node priority makes network reach a kind of stable status, and this agreement no longer needs extra offered load.This moment, this tactful expense was equivalent to the CAN ID that static priority produces.
The present invention uses expansion CAN frame (29 CAN ID) to solve flexible dispatching and the burst problem of IPDU.OSEK COM does not specify concrete bottom-layer network.Among the present invention, we use the bottom communication network of CAN network (one of present most popular bus) as OSEK COM, form complete OSEK COM communication system with OSEK COM.Under the framework of OSEK COM, the CAN priority dynamic allocation algorithm under a kind of OSEK COM framework is proposed, solve the mapping problems between OSEK COM and the CAN network.
Description of drawings
The hierarchical model figure of Fig. 1 OSEK COM
The composition schematic diagram of Fig. 2 CAN ID
The data flowchart of Fig. 3 node i
The software architecture that Fig. 4 Santana test platform and development board are formed
The logic line schematic diagram of Fig. 5 Santana test platform
Embodiment
Each ECU inside, each IPDU data cell of OSEK COM layer all has an IPDU ID to come addressing different IP DU, and the design is the important component part of IPDU ID as CANID.On same ECU, the data cell that IPDU ID is more little has high more priority.As shown in Figure 2, IPDU ID accounts for 8 ~ 14 7, and 2^7=128 IPDU arranged at most on the ECU.
An ECU inside, the priority between the IPDU are determined easily.But between different ECU, the priority of IPDU is determined relatively difficulty.For coordinating the IPDU priority between the different ECU, node priority (Node Priority) has been introduced in the wood design, as the important part of CAN ID.As shown in Figure 2, NodePriority accounts for 15 ~ 29 14.Can distribute 2^14 node priority on the CAN network at most.The Node Priority territory of CANID can be adjusted according to the actual state on the network.Allow carry sqrt (2^14)=2^7=128 CAN node on the network at most.
We use the fixed priority scheduling in ECU inside, and in the ECU outside, we carry out internodal dynamic priority scheduling by adjusting NodePriority.It is hungry to death to guarantee certain node not occur, and can constantly adjust the further reasonably Node Priority method of salary distribution of formation according to the actual conditions on the network.
Below we introduce the more New Deal of Node Priority in detail.
Suppose to have on the network n node, node serial number is 0,1,2 ..., n-1.Each node distributes n node priority.For example n node priority of node i distribution is: O*n+i, and 1*n+i, 2*n+i ..., (n-1) * n+i.The state that the user is initial according to network disposes the start node priority of each node.
The user is L ms according to the adjustment priority time of the actual conditions configuration node i of node i, and maximum failure (overtime) number of times that can stand in the time of L ms of configure user Mi time.In order to guarantee that the node priority counter-rotating can not take place.The present invention uses a simple agreement, broadcast on the CAN bus, and all nodes on the bus are all received this message simultaneously, all receive that the local node of message is according to following protocol update node priority.Each node has periodic triggered time Li, at this constantly, and node i:
1. inspection has surpassed Mi at whether L sends failure in the time number of times, if surpassed, and Go to 2; Otherwise do not do any operation.
2. node i improves his priority in the scope of its node priority permission.For example, if CurrentNodePrioi=x (node priority of i is x at present), after improving, CurrentNodePrioi=x<n? x:x-n.Go?to?3。
3. broadcasting a special standard CAN frame notifies other node to reduce their node priority.
The CAN frame of the standard that sends on the CAN bus is adjusted node priority as other node of a signalisation.The CAN ID of this special CAN frame is a node serial number, and data length is 0.This CAN frame can increase by 44 additional transmissions.After node i broadcasting particular criteria frame, other all nodes:
1. other all nodes are received special standard CAN frame at the same time.
2. other nodes all reduce their node priority.With j is example, if CurrentNodePrioj=y (the current node priori ty of node j is y), after then adjusting, CurrentNodeProj=y〉(n-1) * n? y:y+n.
The flow chart of node i transmission data and adjustment node priority as shown in Figure 3.
In order to solve the burst problem of I-PDU, the design is the burst sum (IPDUFragNum) of IPDU, this CAN frame data skew (IPDUFragIndex) in IPDU wherein two parts as CANID.The burst of IPDU arrives the recipient according to the order of sequence according to the size of IPDUFragIndex.As shown in Figure 2, IPDUFragNum accounts for 4 ~ 74, and IPDUFragIndex accounts for 0 ~ 34.Each IPDU is the longest to be 2^4*8=128 byte, transmit leg and recipient according to these two territories to IPDU burst and reorganization.
The software environment of design: the Frame that CAN debugging acid ZLGCANTest comes testing CAN to receive; CodeWarriorIDE is used for compiling programming to HCS12, the code among HCS12X and the Embest S3CEV40.
The software architecture of each module is seen Fig. 4.Have 5 modules, collect signaling module and control module (HCS12 development board), control front end lamp module (HCS12X development board, it also is control centre's module), display module (ARM7) and control and real module (PC end).
The hardware environment of design: Santana's test platform, we select 1 development board HCS12 and HCS12X (HCS12 and HCS12X development board are integrated in the CAN controller in this development board) as the CAN node, an Embest S3CEV40 development board and connect into the needed number of C AN bus of CAN network etc.Embodiment can be carried out line according to wired logic shown in Figure 5.Development board HCS12X is responsible for controlling left front car light and right front car light, and HCS12 is responsible for controlling left back car light and right back car light, carries out communication with the CAN bus between HCS12 and the HCS12X.Be connected with the RS-232 Serial Port Line between Embest S3CEV40 and the HCS12 development board.Embest S3CEV40 is mutual by carrying out between serial port protocol and the HCS12, reads the corresponding C AN network information, and message is encapsulated, and the corresponding software of issuing the PC end shows.
Can prove that by this test this method can make sending node successfully send data, receiving node receives data, and the phenomenon hungry to death of having avoided IPDU of trying one's best, thereby has guaranteed reliable accuracy, the real-time of Data Receiving.