DEM Overview

Micael Coutinho,autosarbswdem

Reporting of events is an important part of diagnostics. Learn how the DEM comes into play in this article

If you have stuck around long enough, you probably have already read our article What are DCM, DEM, DLT and DET (opens in a new tab). If not, it may serve as a good starting point on diagnostics. Today, we'll expand on an important diagnostics module, DEM (Diagnostic Event Manager). 

So, what is the DEM, and why do we need it? Well, if you heard about DTC's (Diagnostic Trouble Codes), DEM is within reach. It allows you to define and report diagnostic events, that you can later use to diagnose your ECU for problems. It interacts with the DCM (Diagnostics Communication Manager), providing fault information, aka DTC's (you can learn more about the communication of diagnostics by checking our article UDS Overview (opens in a new tab)). So, for example, after a long ride, you can just read the fault memory provided by the DEM and learn about everything going wrong with your ECU. This makes diagnosing issues less of a headache, as all you need to do is read a few bytes (at least for what the ECU can detect).

The DEM relies heavily on other modules for its functionality. Let's analyze how other modules come into play. Starting with the obvious: 

You can take a look at all the connections with the other modules here:

DEM dependencies with other modules, as per Autosar Specification { w: 851, h: 643 }

DEM dependencies with other modules, as per Autosar Specification

Before we finish, let's at least take a look at how the events in the DEM can be reported and how to report them properly, by checking the debounce mechanisms available for the events. 

DEM events can either have the status PASSED or FAILED, or the intermediate states PREPASSED and PREFAILED, if you are using debounce (more on that later). Events can be reported / read in two different ways: through API's or ports, depending on the Autosar layer we are in. The get and set event API's are defined as below:

    Std_ReturnType Dem_SetEventStatus(
        Dem_EventIdType EventId,
        Dem_EventStatusType EventStatus
    )

    Std_ReturnType Dem_GetEventStatus(
        Dem_EventIdType EventId,
        Dem_UdsStatusByteType* EventStatusByte
    )

Keep in mind, there are way more API's (and ports, as Software Components can also access the DEM through the RTE) that the DEM provides and are useful. We are just scratching the surface today, but it's something we'll explore more in the future.

Now, let's talk about event debouncing: why do we need it and what options are there for us? Well, let's look at the simplest example. In your microcontroller classes in university, you are likely to have implemented a time-based debounce mechanism for a button. In the very least, electronics are not perfect. They are subject to interference. In automotive vehicles, this is no exception. Of course, if DEM implements this for us, we don't have to do it manually, which is awesome. So, debouncing is important. With that said, there are 3 different options for debouncing:

DEM counter based debouncing, as per Autosar Specification { w: 851, h: 643 }

DEM counter based debouncing, as per Autosar Specification

DEM time based debouncing, as per Autosar Specification { w: 851, h: 643 }

DEM time based debouncing, as per Autosar Specification

As some closing thoughts, we want to mention this is just a sratch in the surface. More will come in upcoming articles, where we'll have the opportunity to take a deeper look at the DEM and its surrounding modules, as there is a lot more to explore. Stay tuned!

Author: Micael Coutinho (opens in a new tab)

References:

© AutosarToday —@LinkedIn