-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathExternalCANDataSource.h
66 lines (57 loc) · 2.18 KB
/
ExternalCANDataSource.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "CANDataConsumer.h"
#include "Clock.h"
#include "ClockHandler.h"
#include "IDecoderDictionary.h"
#include "SignalTypes.h"
#include "TimeTypes.h"
#include "VehicleDataSourceTypes.h"
#include <cstdint>
#include <memory>
#include <mutex>
#include <vector>
namespace Aws
{
namespace IoTFleetWise
{
/**
* @brief External CAN Bus implementation. Allows data from external in-process CAN bus sources to
* be ingested, for example when FWE is compiled as a shared-library.
*/
// coverity[cert_dcl60_cpp_violation] false positive - class only defined once
// coverity[autosar_cpp14_m3_2_2_violation] false positive - class only defined once
class ExternalCANDataSource
{
public:
/**
* @brief Construct CAN data source
* @param consumer CAN data consumer
*/
ExternalCANDataSource( CANDataConsumer &consumer );
~ExternalCANDataSource() = default;
ExternalCANDataSource( const ExternalCANDataSource & ) = delete;
ExternalCANDataSource &operator=( const ExternalCANDataSource & ) = delete;
ExternalCANDataSource( ExternalCANDataSource && ) = delete;
ExternalCANDataSource &operator=( ExternalCANDataSource && ) = delete;
/** Ingest CAN message.
* @param channelId CAN channel ID
* @param timestamp Timestamp of CAN message in milliseconds since epoch, or zero if unknown.
* @param messageId CAN message ID in Linux SocketCAN format
* @param data CAN message data */
void ingestMessage( CANChannelNumericID channelId,
Timestamp timestamp,
uint32_t messageId,
const std::vector<uint8_t> &data );
void onChangeOfActiveDictionary( ConstDecoderDictionaryConstPtr &dictionary,
VehicleDataSourceProtocol networkProtocol );
private:
std::shared_ptr<const Clock> mClock = ClockHandler::getClock();
std::mutex mDecoderDictMutex;
std::shared_ptr<const CANDecoderDictionary> mDecoderDictionary;
CANDataConsumer &mConsumer;
Timestamp mLastFrameTime{};
};
} // namespace IoTFleetWise
} // namespace Aws