Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
routable_uds_service.h
1#ifndef ROUTABLE_USD_SERVICE_H
2#define ROUTABLE_USD_SERVICE_H
3
4#include <future>
5#include <vector>
6#include "../../core/instance_specifier.h"
7#include "../../core/result.h"
8#include "../meta_info.h"
9#include "../cancellation_handler.h"
10
11namespace ara
12{
13 namespace diag
14 {
17 {
19 std::vector<uint8_t> responseData;
20 };
21
24 namespace routing
25 {
28 {
29 private:
30 const uint8_t mSid;
31 bool mOffered;
32 const ara::core::InstanceSpecifier &mSpecifier;
33
34 protected:
36 static const uint8_t cPositiveResponseSidIncrement{0x40};
38 const uint8_t cSubFunctionNotSupported{0x12};
40 const uint8_t cIncorrectMessageLength{0x13};
42 const uint8_t cRequestSequenceError{0x24};
43
48 const ara::core::InstanceSpecifier &specifier,
49 uint8_t sid) noexcept;
50
55 OperationOutput &response, uint8_t nrc) const;
56
63 template <class T>
64 bool TryExtractValue(MetaInfo &metaInfo, std::string key, T &value) const
65 {
66 core::Optional<std::string> _optionalValue{metaInfo.GetValue(key)};
67
68 if (_optionalValue.HasValue())
69 {
70 std::string _valueStr{_optionalValue.Value()};
71 int _valueInt{std::stoi(_valueStr)};
72 value = static_cast<T>(_valueInt);
73
74 return true;
75 }
76 else
77 {
78 return false;
79 }
80 }
81
82 public:
84 static const uint8_t cNegativeResponseCodeSid{0x7f};
85
88 uint8_t GetSid() const noexcept;
89
92 ara::core::Result<void> Offer();
93
96 bool IsOffered() const noexcept;
97
103 virtual std::future<OperationOutput> HandleMessage(
104 const std::vector<uint8_t> &requestData,
105 MetaInfo &metaInfo,
106 CancellationHandler &&cancellationHandler) = 0;
107
109 void StopOffer() noexcept;
110
111 virtual ~RoutableUdsService() noexcept = default;
112 };
113 }
114 }
115}
116
117#endif
AUTOSAR shortname-path wrapper.
Definition: instance_specifier.h:14
A wrapper around a possible value.
Definition: optional.h:16
A wrapper class around a conversation cancellation handler callback.
Definition: cancellation_handler.h:12
Diagnostic metainfo in different context.
Definition: meta_info.h:24
core::Optional< std::string > GetValue(std::string key)
Get an entry value within the metainfo.
Definition: meta_info.cpp:12
An UDS service to handle a diagnostic request by offering itself to a router.
Definition: routable_uds_service.h:28
const uint8_t cIncorrectMessageLength
Incorrect message length NRC.
Definition: routable_uds_service.h:40
uint8_t GetSid() const noexcept
Get SID.
Definition: routable_uds_service.cpp:27
bool TryExtractValue(MetaInfo &metaInfo, std::string key, T &value) const
Try to extract a value from the given meta-info.
Definition: routable_uds_service.h:64
void GenerateNegativeResponse(OperationOutput &response, uint8_t nrc) const
Generate a negative response with a specific NRC.
Definition: routable_uds_service.cpp:21
const uint8_t cRequestSequenceError
Incorrect request sequence NRC.
Definition: routable_uds_service.h:42
void StopOffer() noexcept
Stop offering request handling.
Definition: routable_uds_service.cpp:57
const uint8_t cSubFunctionNotSupported
Unsupported sub-function NRC.
Definition: routable_uds_service.h:38
static const uint8_t cPositiveResponseSidIncrement
SID increment for a positive response.
Definition: routable_uds_service.h:36
virtual std::future< OperationOutput > HandleMessage(const std::vector< uint8_t > &requestData, MetaInfo &metaInfo, CancellationHandler &&cancellationHandler)=0
Handle an UDS request message.
static const uint8_t cNegativeResponseCodeSid
Negative response code service ID.
Definition: routable_uds_service.h:84
ara::core::Result< void > Offer()
Offer handling DM requests.
Definition: routable_uds_service.cpp:32
bool IsOffered() const noexcept
Get offering status of the service.
Definition: routable_uds_service.cpp:52
RoutableUdsService(const ara::core::InstanceSpecifier &specifier, uint8_t sid) noexcept
Constructor.
Definition: routable_uds_service.cpp:13
Positive response of a handled UDS request.
Definition: routable_uds_service.h:17
std::vector< uint8_t > responseData
Response byte array.
Definition: routable_uds_service.h:19