-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecusim.h
124 lines (105 loc) · 4.44 KB
/
ecusim.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* www.lindwurm-can.org
* Copyright (C) 2023 Sascha Muenzberg <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ECUSIM_H
#define ECUSIM_H
#include <string>
#include <cstring>
#include <map>
struct DataValue
{
DataValue()
{
data = nullptr;
dataLength = 0;
}
DataValue(const char* setData)
{
data = setData;
dataLength = strlen(data);
}
DataValue(const char* setData, size_t setLength)
{
data = setData;
dataLength = setLength;
}
const char* data;
size_t dataLength;
};
using UdsDataIdMap = std::map<uint16_t, DataValue>;
namespace UdsDataId
{
enum
{
BootSoftwareIdentification = 0xF180,
ApplicationSoftwareIdentification = 0xF181,
ApplicationDataIdentification = 0xF182,
BootSoftwareFingerprint = 0xF183,
ApplicationSoftwareFingerprint = 0xF184,
ApplicationDataFingerprint = 0xF185,
ActiveDiagnosticSession = 0xF186,
VehicleManufacturerSparePartNumber = 0xF187,
VehicleManufacturerECUSoftwareNumber = 0xF188,
VehicleManufacturerECUSoftwareVersionNumber = 0xF189,
SystemSupplierIdentifierDataIdentifier = 0xF18A,
ECUManufacturingDate = 0xF18B,
ECUSerialNumber = 0xF18C,
SupportedFunctionalUnits = 0xF18D,
VehicleManufacturerKitAssemblyPartNumber = 0xF18E,
ISOSAEReservedStandardized = 0xF18F,
VIN = 0xF190,
VehicleManufacturerECUHardwareNumber = 0xF191,
SystemSupplierECUHardwareNumber = 0xF192,
SystemSupplierECUHardwareVersionNumber = 0xF193,
SystemSupplierECUSoftwareNumber = 0xF194,
SystemSupplierECUSoftwareVersionNumber = 0xF195,
ExhaustRegulationOrTypeApprovalNumber = 0xF196,
SystemNameOrEngineType = 0xF197,
RepairShopCodeOrTesterSerialNumber = 0xF198,
ProgrammingDate = 0xF199,
CalibrationRepairShopCodeOrCalibrationEquipmentSerialNumber = 0xF19A,
CalibrationDate = 0xF19B,
CalibrationEquipmentSoftwareNumber = 0xF19C,
ECUInstallationDate = 0xF19D,
ODXFile = 0xF19E,
Entity = 0xF19F,
NumberOfEDRDevices = 0xFA10,
EDRIdentification = 0xFA11,
EDRDeviceAddressInformation = 0xFA12,
EDREntry6 = 0xFA13,
EDREntry5 = 0xFA14,
EDREntry4 = 0xFA15,
EDREntry3 = 0xFA16,
EDREntry2 = 0xFA17,
EDREntry1 = 0xFA18,
UDSVersion = 0xFF00
};
}
class ECUSim
{
public:
ECUSim(unsigned short sourceAddress, unsigned short targetAddress, const std::string &name, const std::string &interface = "vcan0", const UdsDataIdMap& idMap = {});
void operator()();
private:
void dumpData(const unsigned char *data, int numberOfBytes, char prefix);
private:
unsigned short m_sourceAddress;
unsigned short m_targetAddress;
std::string m_name;
std::string m_interface;
UdsDataIdMap m_idMap;
};
#endif // ECUSIM_H