Background technology
AUTOSAR (automobile open system framework) is an opening and standardized automotive electronics software architecture, and it is to unite foundation by Global Auto manufacturer, parts suppliers and other electronics, semiconductor and software systems company.The AUTOSAR protocol stack is used for the ECU inside of automotive electronics and the network communication between the ECU, it is a protocol stack that is similar to the OSI seven layer model, information is passed to protocol stack by top RTE (Run Time Environment) layer, then packaged framing is passed on the bottom hardware in stack.As shown in Figure 1, Com layer communication entity unit is mainly following several:
(1) Signal (atom message), it is mutual to be used for Com layer and upper strata;
(2) SignalGroup (atom message groups) is made of one group of atom message, and it is mutual to be used for Com layer and upper strata;
(3) IPDU (alternation of bed communication data unit): Signal and SignalGroup are at the carrier of Com layer, and it is mutual to be used for Com layer and lower floor.
In the standard, an important feature of the COM layer in the COM communication stack requires to provide overtime monitoring mechanism to the communication entity unit exactly in the AUTOSAR standard, mainly comprises the relevant time limit monitoring deadline time limit monitoring relevant with sending mode.The time limit monitoring is specifically related to following several:
(1) transmission monitoring deadline of Signal: monitoring Signal is after the request of transmission is sent on the upper strata, IPDU by the Signal place is sent to lower floor and receives from the transmission of lower floor and successfully confirm in the official hour interval, if in the in setting time transmission that fails, then initiate notification mechanism is notified the upper strata, otherwise is receiving the time point cancellation monitoring of successfully confirming.
(2) reception monitoring deadline of Signal: the IPDU at monitoring Signal place is after receiving data in interruption, whether in the official hour interval, extracted by the upper strata, if in the in setting time un-extracted then initiate notification mechanism notice upper strata, otherwise the current monitoring of time point cancellation of being extracted by the upper strata.
(3) transmission monitoring deadline of SignalGroup: monitoring SignalGroup is after upper strata transmission request is sent, IPDU by the SignalGroup place is sent to lower floor and receives from the transmission of lower floor and successfully confirm in the official hour interval, if in the in setting time transmission that fails, then monitor otherwise cancellation is current on initiate notification mechanism notice upper strata.
(4) reception monitoring deadline of SignalGroup: the IPDU at monitoring SignalGroup place is after receiving data in interruption, whether in the official hour interval, extracted by the upper strata, if in the in setting time un-extracted then initiate notification mechanism notice upper strata, otherwise the current monitoring of time point cancellation of being extracted by the upper strata.
(5) time supervision of the cycle sending mode of IPDU: show that such as Fig. 2 IPDU carries out to lower floor's transmit operation through after the user configured gate, then restart new monitoring cycle time, IPDU sends unlimited.Wherein, the cycle sending mode is exactly the transmit operation of directly carrying out IPDU with a fixing cycle.
(6) time supervision of the direct sending mode of IPDU: show that such as Fig. 3 IPDU carries out to lower floor's transmit operation through after the user configured gate, then restart new monitoring cycle time, the IPDU transmission times is N time.Wherein, N is user configured transmission total number, and directly the sending mode operation is exactly to carry out N time of IPDU with a fixing interval transmit operation.The startup that wherein directly sends IPDU is driven by the COM upper strata, sends a Signal/SignalGroup such as the upper strata request.
(7) time supervision of the mixing sending mode of IPDU: show such as Fig. 4, namely carry out the time supervision of the cycle sending mode of IPDU, carry out again the time supervision of the direct sending mode of IPDU.
In way in the past, normally a monitoring alarm device (Alarm) is disposed in every kind of time limit monitoring of each top solid element, realize the time limit mechanism that requires in the AUTOSAR standard.For instance: disposed 5 IPDU at the Com layer, each IPDU has disposed respectively 5 Signal and 4 SignalGroup, and each Signal and SIgnalGroup have disposed transmission deadline and received monitoring deadline under extreme case.The monitoring alarm device total number of each IPDU needs is exactly (5*2+4*2+1*2) * 5=100 like this, so just needs AUTOSAR OS will support at least simultaneously can dispose 100 monitoring alarm devices.Therefore there is such problem in prior art:
(1) need the user to dispose too many monitoring alarm device, the immediate problem that causes is exactly the Alarm resource that takies too many system, is not easy to safeguard and debugging.
(2) need in the maintenance process to travel through too many monitoring alarm device, cost a lot of money the time, and operation is too many in might causing interrupting, it is oversize break period to cause closing clock, can affect the time accuracy of transmission.
Summary of the invention
The technical problem to be solved in the present invention provide a kind of take resource few, safeguard simple, debugging is convenient, processing speed is fast, the high COM layer communication time limit monitoring method based on AUTOSAR of transmitting-receiving efficient.
In order to solve the problems of the technologies described above, the technical solution used in the present invention is:
A kind of COM layer communication time limit monitoring method based on AUTOSAR, implementation step is as follows:
1) sets up one and follow the monitoring alarm device that the COM layer starts, when each communication entity initialization, create time limit parameter and timing parameter;
2) the monitoring alarm device regularly travels through all communication entities, and upgrades the timing parameter of each communication entity when traveling through at every turn;
3) according to the state of time limit parameter and timing parameter judgement communication entity, if the communication entity transmitting time is overtime, then notify this communication entity of upper strata to send unsuccessfully; If the communication entity time of reception is overtime, then notify this communication entity of lower floor to take defeat; If the time point of communication entity sending mode arrives, then this communication entity is transmitted to lower floor, and reset the time limit parameter of this communication entity.
As a further improvement on the present invention:
Described step 1) creates the time limit in during parameter, set up direct transmission times if communication entity is IPDU, directly send interval, cycle and send the three kinds of time limit parameters in interval, and be provided for monitoring in the direct sending mode the directly transmitting counter of transmission times; If communication entity is direct sending mode, direct transmission times then is set, directly sends the two kinds of time limit parameters in interval; If communication entity is the cycle sending mode, the cycle that then arranges sends a kind of time limit parameter in interval; Send the three kinds of time limit parameters in interval if communication entity, then arranges direct transmission times for mixing sending mode, directly send interval, cycle; Described step 2) time point of communication entity sending mode comes interim in, if communication entity is direct sending mode, then when the timing parameter triggers direct transmission interval, this communication entity is transmitted and upgrades described transmitting counter to lower floor, if transmitting counter equals direct transmission times, then finish the transport communication entity; If communication entity is the cycle sending mode, then when the timing parameter triggering cycle sends the interval, this communication entity is transmitted to lower floor; If communication entity is for mixing sending mode, then will when the timing parameter triggers direct transmission interval, this communication entity be transmitted and upgrade described transmitting counter to lower floor on the one hand, if transmitting counter equals direct transmission times, then finish direct sending mode transport communication entity; When the timing parameter triggering cycle sends the interval, this communication entity is transmitted to lower floor simultaneously.
The present invention has following advantage:
1, the present invention has solved the time limit monitoring problem of all communication entities by a monitoring alarm device, greatly save the monitoring alarm device number of resources of the AUTOSAR OS that the COM layer takies, also exempted simultaneously the relevant space of monitoring alarm device data structure, have the resource of taking few, safeguard simple, debugging is convenient, processing speed is fast, the high advantage of transmitting-receiving efficient.
2, the present invention is owing to only operate a monitoring alarm device, the monitoring alarm device of Dynamic Maintenance is triggered time limit parameter and the timing parameter that chained list is converted to a static state, therefore unusual convenient operation, and reduced the expense that data structure is safeguarded receives and dispatches that expense is little, transmitting-receiving efficient is higher.
Embodiment
As shown in Figure 5, the COM layer communication time limit monitoring method based on AUTOSAR of the embodiment of the invention, implementation step is as follows:
1) sets up one and follow the monitoring alarm device that the COM layer starts, when each communication entity initialization, create time limit parameter and timing parameter;
2) the monitoring alarm device regularly travels through all communication entities, and upgrades the timing parameter of each communication entity when traveling through at every turn;
3) according to the state of time limit parameter and timing parameter judgement communication entity, if the communication entity transmitting time is overtime, then notify this communication entity of upper strata to send unsuccessfully; If the communication entity time of reception is overtime, then notify this communication entity of lower floor to take defeat; If the time point of communication entity sending mode arrives, then this communication entity is transmitted to lower floor, and reset the time limit parameter of this communication entity.
Step 1) creates the time limit in during parameter, set up direct transmission times if communication entity is IPDU, directly send interval, cycle and send the three kinds of time limit parameters in interval, and be provided for monitoring in the direct sending mode the directly transmitting counter of transmission times; If communication entity is direct sending mode, direct transmission times then is set, directly sends the two kinds of time limit parameters in interval; If communication entity is the cycle sending mode, the cycle that then arranges sends a kind of time limit parameter in interval; Send the three kinds of time limit parameters in interval if communication entity, then arranges direct transmission times for mixing sending mode, directly send interval, cycle; Described step 2) time point of communication entity sending mode comes interim in, if communication entity is direct sending mode, then when the timing parameter triggers direct transmission interval, this communication entity is transmitted and upgrades described transmitting counter to lower floor, if transmitting counter equals direct transmission times, then finish the transport communication entity; If communication entity is the cycle sending mode, then when the timing parameter triggering cycle sends the interval, this communication entity is transmitted to lower floor; If communication entity is for mixing sending mode, then will when the timing parameter triggers direct transmission interval, this communication entity be transmitted and upgrade described transmitting counter to lower floor on the one hand, if transmitting counter equals direct transmission times, then finish direct sending mode transport communication entity; When the timing parameter triggering cycle sends the interval, this communication entity is transmitted to lower floor simultaneously.
Monitoring alarm device (ComAlarm) has a call back function ComAlarmAction, step 2) the timing parameter that triggers the traversal communication entity, upgrades each communication entity by regularly carrying out call back function ComAlarmAction in, the timing Parameter storage is inner in the IPDU control structure.The timing (tick) of carrying out call back function ComAlarmAction is very short, relates to the integral multiple that is tick in time limit in the time limit parameter.
When if the current communication entity of collecting is Signal or SignalGroup, time limit parameters C omRxTimeout, timing parameters C urRxTime are set then.The time-out time that ComRxTimeout representative is collected, timing parameters C urRxTime upgrades when current Signal or SignalGroup are traversed.Timing parameters C urRxTime is initialized as time limit parameters C omRxTimeout when initialization, each timing parameters C urRxTime that upgrades subtracts 1 automatically, when timing parameters C urRxTime is that 0 Shi Ze represents Signal or SignalGroup to collect the time overtime, then notify this Signal of lower floor or SignalGroup to collect failure.
When if the communication entity of current transmission is Signal or SignalGroup, time limit parameters C omTxTimeout, timing parameters C urTxTime are set then.The time-out time that ComTxTimeout representative sends, timing parameters C urTxTime upgrades when current Signal or SignalGroup are traversed.Timing parameters C urTxTime is initialized as time limit parameters C omTxTimeout when initialization, each timing parameters C urTxTime that upgrades subtracts 1 automatically, when timing parameters C urTxTime is that 0 Shi Ze represents Signal or the SignalGroup transmitting time is overtime, then notify this Signal of upper strata or SignalGroup to send unsuccessfully.
In the present embodiment, each IPDU has 3 parameters C omDNFactor, ComDPFactor and ComPPFactor, 3 parameters C omDNFactor, ComDPFactor and ComPPFactor are used for transmitting the sending mode information of IPDU, and transmit the parameter of sending mode.The relation of 3 parameters C omDNFactor, ComDPFactor and ComPPFactor and IPDU sending mode is as shown in the table:
ComDNFactor |
ComDPFactor |
ComPPFactor |
The IPDU sending mode |
Effectively |
Effectively |
Invalid |
Direct sending mode |
Invalid |
Invalid |
Effectively |
The cycle sending mode |
Effectively |
Effectively |
Effectively |
Mix sending mode |
ComDNFactor, ComDPFactor and ComPPFactor transmit the parameter of sending mode with direct transmission times (CurNFactor), directly send interval (CurDTFactor), cycle and send mutually correspondence one by one of interval (CurPTFactor).
Monitoring alarm device (ComAlarm) started in the lump when the Com layer started, and the thing that monitoring alarm device (ComAlarm) initialization will be done has: the CurTxTime that loads each Signal/SignalGroup is invalid value; The CurRxTime that loads each Signal/SignalGroup is invalid value; CurNFactor, the CurDTFactor, the CurPTFactor that load each IPDU are respectively invalid value, invalid value and ComPPFactor, and wherein CurPTFactor is by the parameter transmission, and CurNFactor, CurDTFactor then define in the COM layer.Above-mentioned invalid value also can be the maximum of corresponding types.If Signal of upper strata request transmission or SignalGroup are ComTxTimeout with regard to the CurTxTime that this Signal or SignalGroup are set.If the IPDU sending mode at this Signal/SignalGroup place is direct sending mode, the CurNFactor that this IPDU then also will be set is ComDNFactor, and CurDTFactor is ComDPFactor.If Signal of prompting is interrupted in lower floor or SignalGroup receives, and is ComRxTimeout with regard to the CurRxTime that this Signal or SignalGroup are set.
The detailed process of carrying out call back function ComAlarmAction is as follows:
A) deadline is monitored auxiliary parameter in the transmission that travels through Signal, the SignalGroup of the IPDU loading on all sending directions, if effectively, just carries out from subtracting reducing.If monitoring the deadline of certain Signal/SignalGroup arrives, then the notice of the informing mechanism by configuring this Signal/SignalGroup of upper strata sends unsuccessfully, and the transmission of revising this Signal/SignalGroup to end the time limit auxiliary parameter be invalid value.
B) reception that travels through Signal, the SignalGroup of the IPDU loading on all receive directions is monitored deadline, if effectively, just execution subtracts reducing certainly.If monitoring the deadline of certain Signal/SignalGroup arrives, then the notice of the informing mechanism by configuring this Signal/SignalGroup of upper strata takes defeat, and the reception cut-off time limit auxiliary parameter of revising this Signal/SignalGroup is invalid value.
C) the relevant time limit of sending mode that travels through the IPDU on all sending directions monitors, if effectively, just carries out from subtracting reducing.If certain cycle sending mode IPDU associated period time limit arrives, the service that then provides by lower floor sends once this IPDU to lower floor, and the relevant auxiliary parameter of the gate of this IPDU that reloads.
If certain is direct sending mode, and the CurNFactor of this IPDU is not invalid value, then safeguard, arrive when this IPDU related interval time limit, the service that then provides by lower floor sends once this IPDU to lower floor, allows the CurNFactor of this IPDU certainly subtract, and relevant auxiliary parameter of the direct transmission interval time limit of reseting this IPDU, if CurNFactor has reduced to 0, then be loaded as invalid value, finish the transmission of this direct sending mode IPDU.
As shown in Figure 6, IPDU1 and IPDU2 are the cycle sending mode, wherein:
The parameter of IPDU1 is: ComDNFactor=0, ComDPFactor=0, ComPPFactor=3,
The parameter of IPDU2 is: ComDNFactor=0, ComDPFactor=0, ComPPFactor=5.It is 3Ticks that the cycle of IPDU1 sends the interval, and it is 5Ticks that the cycle of IPDU1 sends the interval.
Because IPDU1 and IPDU2 are the cycle sending mode, so CurNFactor and CurDTFactor are invalid value in three kinds of time limit parameters of IPDU1 and IPDU2, and CurPTFactor is respectively 3 and 5.Because the cycle sends the characteristic of IPDU, two IPDU will carry out once transmission downwards at this moment.Later on every ComAlarm finishes full maintenance through a Tick, only has CurPTFactor effective in the control structure of two IPDU in the maintenance process, so only allow CurPTFactor do from subtracting reducing.
In the time of Ticks==3, the CurPTFactor that ComAlarm monitors IPDU1 is 0, be to send the cycle in cycle of IPDU1 to arrive, carry out the 2nd time of IPDU1 to lower floor's transmission operation, and the CurPTFactor that again loads IPDU1 is user configured ComPPFactor.
In the time of Ticks==5, the CurPTFactor that ComAlarm monitors IPDU2 is 0, the transmission cycle in cycle that is IPDU2 arrives, carry out the 2nd time of IPDU2 to lower floor's transmission operation, and the CurPTFactor that again loads IPDU2 is the ComPPFactor (being 5) of user configured IPDU2.
Whenever arriving 3*k (k>2, k is natural number) behind the individual Tick, the CurPTFactor that ComAlarm monitors IPDU1 is 0, the transmission cycle in cycle that is IPDU1 arrives, carry out the k time of IPDU1 and operate to lower floor's transmission, and the CurPTFactor that again loads IPDU1 is the ComPPFactor (being 3) of user configured IPDU1.
Whenever arriving 5*k (k>2, k is natural number) behind the individual Tick, the CurPTFactor that ComAlarm monitors IPDU2 is 0, the transmission cycle in cycle that is IPDU2 arrives, carry out the k time of IPDU2 and operate to lower floor's transmission, and the CurPTFactor that again loads IPDU2 is the ComPPFactor (being 5) of user configured IPDU2.
So just having solved two with this ComAlarm all is the IPDU time limit monitoring problem of cycle sending mode.This method also was feasible when in like manner, the number of such IPDU was expanded to a lot of.
As shown in Figure 7, IPDU1 is the cycle sending mode, and IPDU2 is direct sending mode, wherein:
The parameter of IPDU1 is: ComDNFactor=0, ComDPFactor=0, ComPPFactor=5,
The parameter of IPDU2 is: ComDNFactor=3, ComDPFactor=3, ComPPFactor=0.
It is 5Ticks that the cycle of IPDU1 sends the interval, and the direct transmission times of IPDU1 is 3 times, directly transmission is spaced apart 3Ticks.
In the time of Ticks=0, the COM initialization, ComAlarm starts, and the auxiliary parameter CurNFactor of IPDU1, CurDTFactor, CurPTFactor are initialized to respectively invalid value, invalid value, 5; The auxiliary parameter CurNFactor of IPDU2, CurDTFactor, CurPTFactor are initialized to respectively invalid value, invalid value, invalid value.Because the cycle sends the characteristic of IPDU, IPDU1 will carry out once transmission downwards at this moment.
In the time of Ticks=1, IPDU2 starts transmission owing to the upper strata drives (need to send a Signal/SignalGroup such as the upper strata), at this moment, ComAlarm auxiliary parameter CurNFactor, CurDTFactor, CurPTFactor that IPDU2 need to be set be respectively 3,3, invalid value.Owing to directly send the characteristic of IPDU, IPDU2 will carry out once transmission downwards this moment, and allows CurNFactor from subtracting once.
In the time of Ticks==4, the CurDTFactor that ComAlarm monitors IPDU2 is 0, the direct transmission time limit that is IPDU2 arrives, carry out the 2nd time of IPDU2 to lower floor's transmission operation, CurNFactor does from being kept to 1, and the CurDTFactor that again loads IPDU1 is the ComDPFactor (being 3) of user configured IPDU2.
In the time of Ticks==5, the CurPTFactor that ComAlarm monitors IPDU1 is 0, the transmission time limit in cycle that is IPDU1 arrives, carry out the 2nd time of IPDU1 to lower floor's transmission operation, and the CurPTFactor that again loads IPDU1 is the ComPPFactor (being 5) of user configured IPDU1.
In the time of Ticks==7, the CurDTFactor that ComAlarm monitors IPDU2 is 0, and namely the direct transmission time limit of IPDU2 arrives, carries out the 3rd time of IPDU2 to lower floor's transmission operation, and CurNFactor does from being kept to 0.This moment, IDPU1 finished 3 transmissions, and three auxiliary parameters are made as invalid value, until next causing after this IPDU starts the Signal/SignalGroup arrival of transmitting starts again.
Whenever arriving 5*k (k>2, k is natural number) behind the individual Ticks, the CurPTFactor that ComAlarm monitors IPDU1 is 0, the transmission cycle in cycle that is IPDU2 arrives, carry out the k time of IPDU2 and operate to lower floor's transmission, and the CurPTFactor that again loads IPDU2 is the ComPPFactor (being 5) of user configured IPDU1.
So just two IPDU have been solved with a ComAlarm, one-period sending mode, the time limit monitoring problem of the direct sending mode of a N=3.Obviously also can be expanded to a lot of to the number of such IPDU, and be to monitor with this ComAlarm.
Can regard two IPDU as owing to mix the time limit monitoring of an IPDU of sending mode: the one-period sending mode, one is the time limit monitoring problem of direct sending mode, so also can solve with a ComAlarm.Because the IPDU between the various cycle sending modes is independently, so just can solve with ComAlarm the relevant time limit monitoring problem of transmission of all IPDU.
As shown in Figure 8, during establishment time limit parameter, configuration Signal1:ComTxTimeout=7; Configuration Signal2:ComTxTimeout=3.Be that the transmission of Signal1 is limited to 7Ticks when overtime, the transmission of Signal2 is limited to 2Ticks when overtime.
In the time of Ticks=0, the COM initialization, ComAlarm starts, and the auxiliary parameter CurTxTime of Signal1 and Signal2 is both initialized to invalid value.Every through a Tick, ComAlarm finishes full maintenance, if the CurTxTime of Signal is not invalid value then from subtracting, if CurTxTime is 0 o'clock, triggering the transmission overtime action notice upper strata of Signal and CurTxTime is set is invalid value in the maintenance process.
In the time of Ticks=1, the COM upper strata sends Signal1, at this moment, needs among the ComAlarm Signal1 auxiliary parameter CurTxTime is loaded as 7.
In the time of Ticks=2, the COM upper strata sends Signal2, at this moment, needs among the ComAlarm Signal1 auxiliary parameter CurTxTime is loaded as 3.
In the time of Ticks=5, the CurTxTime of Signal2 is made as invalid value to its CurTxTime from reducing to 0, and the overtime action of transmission of triggering Signa2 is with the notice upper strata.Signal2 finishes monitoring.
In the time of Ticks=6, receive that the transmission of Signal1 is successfully confirmed, Signal1 sends successfully.The CurTxTime that it is set is invalid value.Signal1 finishes monitoring.
Like this, just utilize a ComAlarm to solve transmission monitoring problem deadline of two Signal.Because transmission monitoring problem deadline of SignalGroup and transmission problem deadline of Signal are as a same reason substantially, so also can solve with a ComAlarm transmission monitoring problem deadline of SignalGroup.And the number of Signal and SignalGroup can increase.Same reason also can solve with a ComAlarm reception monitoring problem deadline of Signal and SignalGroup.And the number of Signal and SignalGroup can increase arbitrarily.
Because the time limit monitoring problem that the sending mode of IPDU is relevant and relevant monitoring problem deadline of Signal/SignalGroup are independently, just can solve by same ComAlarm is parallel.So far, this paper has just solved the time limit monitoring problem of all communication entity unit of Com layer with a ComAlarm.
The above only is preferred implementation of the present invention, and protection scope of the present invention is not limited in above-mentioned execution mode, and every technical scheme that belongs to the principle of the invention all belongs to protection scope of the present invention.For a person skilled in the art, some improvements and modifications of under the prerequisite that does not break away from principle of the present invention, carrying out, these improvements and modifications also should be considered as protection scope of the present invention.