UDS Frames and NRC Codes

Micael Coutinho,autosarbswdcm

Analyzing the UDS frames and NRC in UDS responses allows us to learn more about the problems in our ECU. Learn about UDS frames and NRC's here

If you played around with UDS long enough, you know how frustrating it can be looking at a 0x7F message and not understanding what you did wrong. If not, maybe it would be beneficial for you to take a step back and check our article UDS Overview (opens in a new tab), where we explain what UDS is, why we need it and what are the commands you can perform to your ECU through it. Maybe the session is wrong? Maybe the PCI length is wrong? Did I get back to the default session due to a timeout? Learning about all NRC's (Negative Response Codes) and / or having a cheat sheet (which this article intends to create for you, so make sure to bookmark it for the next time your UDS adventures go wrong) with all NRC's can take the guess work out of UDS and make your life easier. Today, we dive deep into all the error codes and learn what really went wrong in your communication. But first, we'll also take a look at the possible UDS frames and their flow, so that our UDS understanding grows as a whole

Firstly, let's talk UDS frames. This is something we left out of the first part, but it's kind of important. As with any protocol, you may not need to know its internals, but being aware of the normal message flow and the parameters of UDS frames will only make you better as a developer. With that said, a UDS request contains the following structure:

UDS request structure { w: 492, h: 62 }

UDS request structure

Each parameter meaning is described below:

The responses are not so different. As you can see below, a positive response contains the SID + 0x40 as the first byte, followed by the sub-function and the relevant response data. As for the negative response, you receive the error SID (0x7F), the SID of the failed UDS request and the NRC, which will allow you to know further details about the error:

UDS response structure { w: 522, h: 222 }

UDS positive (top) and negative (bottom) response structure

The available NRC codes, which help you figure out what went wrong, are:

NRCNameDescription
0x10generalRejectVery general. Sent in case none of the other NRC's can describe the error
0x11serviceNotSupportedECU does not support the requested service
0x12subFunctionNotSupportedRequested sub-function is not supported
0x13incorrectMessageLengthOrInvalidFormatSpecified length of the message or fortmat is invalid
0x14responseTooLongThe response length exceeds the limits specified by the underlying layer
0x21busyRepeatRequestECU is busy to perform the required operation
0x22conditionsNotCorrectPre-requisites to perform the UDS request are not valid, so the request cannot go through
0x24requestSequenceErrorWhen a certain sequence required for an UDS request is not complied with
0x31requestOutOfRangeWhen a parameter value is outside the valid range
0x33securityAccessDeniedRequest denied due to the security measures established to perform the request by the ECU are not complied with
0x35invalidKeySecurity access denied due to invalid key
0x36exceedNumberOfAttemptsRequest will not be executed because there were more than N failed security access attempts
0x37requiredTimeDelayNotExpiredRequest denied because timeout after failed security access had not expired yet
0x70uploadDownloadNotAcceptedAttempt to download / upload data rejected due to some issue
0x71transferDataSuspendedTransfer of data aborted due to some issue
0x72generalProgrammingFailureErasing or programming via UDS failed
0x73wrongBlockSequenceCounterError detected in BS (Block Sequence) counter values by the ECU
0x78ResponsePendingRequest is valid, but ECU is not ready yet to process it
0x7EsubFunctionNotSupportedInActiveSessionCurrent session does not have permission to perform the request
0x81rpmTooHighcurrent RPM is too high to perform request
0x82rpmTooLowcurrent RPM is too low to perform request
0x83engineIsRunningRequest cannot be performed with engine running
0x84engineIsNotRunningRequest cannot be performed with engine not running
0x85engineRunTimeTooLowRequest cannot be performed because the engine has not been running for long enough
0x86temperatureTooHighTemperature is too high to perform request
0x87temperatureTooLowTemperature is too low to perform request
0x88vehicleSpeedTooHighVehicle speed is too high to perform request
0x89vehicleSpeedTooLowVehicle speed is too low to perform request
0x8APedalTooHighThrottle or pedal is in a position too high to perform request
0x8BPedalTooLowThrottle or pedal is in a position too low to perform request
0x8CtransmissionRangeNotInNeutralTransmission is not in neutral
0x8DtransmissionRangeNotInGearTransmission is not in gear
0x8FbrakeSwitchNotClosedBrakes are not pressed
0x90shifterLeverNotInParkShifter is not in park mode
0x91torqueConverterClutchLockedTCC (Torque Converter Clutch) is in a locked state
0x92voltageTooHighSpecific voltage in the ECU is too high to perform the request
0x93voltageTooLowSpecific voltage in the ECU is too low to perform the request

Now, let's take a look at how the response is segmented. As explained earlier, when you use CAN-TP, you surpass the CAN limitation of 8 bytes, by implementing mechanisms to group multiple CAN frames into 1 response. An interaction between client (tester) and server (ECU / vehicle) can look like this:

UDS interaction { w: 352, h: 303 }

Possible UDS interaction between an ECU and a tester

As you can see by the illustration, there are 4 types of frames:

As some closing thoughts, we hope this article can help you become more profficient with UDS. It's a very important protocol in the automotive world, an although it can look a bit complex and intimidating at first, when we bite the cookie chunk by chunk, as we try to do here on Autosar Today, everything becomes simpler. Happy diagnostics!

Author: Micael Coutinho (opens in a new tab)

References:

© AutosarToday —@LinkedIn