Restore /etc/dev-mapping.conf support
[apps/agl-service-can-low-level.git] / examples / OBD2 / obd2-signals.cpp
1 #include <binding/application.hpp>
2 #include <can/can-decoder.hpp>
3 #include <can/can-encoder.hpp>
4
5 extern "C" {
6 CTLP_CAPI_REGISTER("example");
7
8 std::shared_ptr<message_set_t> cms = std::make_shared<message_set_t>(message_set_t{0,"example",
9         { // beginning message_definition_ vector
10         }, // end message_definition vector
11         { // beginning diagnostic_messages_ vector
12                 {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
13                         4,
14                         "engine.load",
15                         0,
16                         0,
17                         UNIT::INVALID,
18                         5.00000f,
19                         decoder_t::decode_obd2_response,
20                         nullptr,
21                         true,
22                         false
23                 })}
24 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
25                         5,
26                         "engine.coolant.temperature",
27                         0,
28                         0,
29                         UNIT::INVALID,
30                         1.00000f,
31                         decoder_t::decode_obd2_response,
32                         nullptr,
33                         true,
34                         false
35                 })}
36 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
37                         10,
38                         "fuel.pressure",
39                         0,
40                         0,
41                         UNIT::INVALID,
42                         1.00000f,
43                         decoder_t::decode_obd2_response,
44                         nullptr,
45                         true,
46                         false
47                 })}
48 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
49                         11,
50                         "intake.manifold.pressure",
51                         0,
52                         0,
53                         UNIT::INVALID,
54                         1.00000f,
55                         decoder_t::decode_obd2_response,
56                         nullptr,
57                         true,
58                         false
59                 })}
60 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
61                         12,
62                         "engine.speed",
63                         0,
64                         0,
65                         UNIT::INVALID,
66                         5.00000f,
67                         decoder_t::decode_obd2_response,
68                         nullptr,
69                         true,
70                         false
71                 })}
72 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
73                         13,
74                         "vehicle.speed",
75                         0,
76                         0,
77                         UNIT::INVALID,
78                         5.00000f,
79                         decoder_t::decode_obd2_response,
80                         nullptr,
81                         true,
82                         false
83                 })}
84 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
85                         15,
86                         "intake.air.temperature",
87                         0,
88                         0,
89                         UNIT::INVALID,
90                         1.00000f,
91                         decoder_t::decode_obd2_response,
92                         nullptr,
93                         true,
94                         false
95                 })}
96 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
97                         16,
98                         "mass.airflow",
99                         0,
100                         0,
101                         UNIT::INVALID,
102                         5.00000f,
103                         decoder_t::decode_obd2_response,
104                         nullptr,
105                         true,
106                         false
107                 })}
108 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
109                         17,
110                         "throttle.position",
111                         0,
112                         0,
113                         UNIT::INVALID,
114                         5.00000f,
115                         decoder_t::decode_obd2_response,
116                         nullptr,
117                         true,
118                         false
119                 })}
120 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
121                         31,
122                         "running.time",
123                         0,
124                         0,
125                         UNIT::INVALID,
126                         1.00000f,
127                         decoder_t::decode_obd2_response,
128                         nullptr,
129                         true,
130                         false
131                 })}
132 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
133                         45,
134                         "EGR.error",
135                         0,
136                         0,
137                         UNIT::INVALID,
138                         0.00000f,
139                         decoder_t::decode_obd2_response,
140                         nullptr,
141                         true,
142                         false
143                 })}
144 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
145                         47,
146                         "fuel.level",
147                         0,
148                         0,
149                         UNIT::INVALID,
150                         1.00000f,
151                         decoder_t::decode_obd2_response,
152                         nullptr,
153                         true,
154                         false
155                 })}
156 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
157                         51,
158                         "barometric.pressure",
159                         0,
160                         0,
161                         UNIT::INVALID,
162                         1.00000f,
163                         decoder_t::decode_obd2_response,
164                         nullptr,
165                         true,
166                         false
167                 })}
168 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
169                         70,
170                         "ambient.air.temperature",
171                         0,
172                         0,
173                         UNIT::INVALID,
174                         1.00000f,
175                         decoder_t::decode_obd2_response,
176                         nullptr,
177                         true,
178                         false
179                 })}
180 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
181                         76,
182                         "commanded.throttle.position",
183                         0,
184                         0,
185                         UNIT::INVALID,
186                         1.00000f,
187                         decoder_t::decode_obd2_response,
188                         nullptr,
189                         true,
190                         false
191                 })}
192 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
193                         82,
194                         "ethanol.fuel.percentage",
195                         0,
196                         0,
197                         UNIT::INVALID,
198                         1.00000f,
199                         decoder_t::decode_obd2_response,
200                         nullptr,
201                         true,
202                         false
203                 })}
204 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
205                         90,
206                         "accelerator.pedal.position",
207                         0,
208                         0,
209                         UNIT::INVALID,
210                         5.00000f,
211                         decoder_t::decode_obd2_response,
212                         nullptr,
213                         true,
214                         false
215                 })}
216 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
217                         91,
218                         "hybrid.battery-pack.remaining.life",
219                         0,
220                         0,
221                         UNIT::INVALID,
222                         5.00000f,
223                         decoder_t::decode_obd2_response,
224                         nullptr,
225                         true,
226                         false
227                 })}
228 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
229                         92,
230                         "engine.oil.temperature",
231                         0,
232                         0,
233                         UNIT::INVALID,
234                         1.00000f,
235                         decoder_t::decode_obd2_response,
236                         nullptr,
237                         true,
238                         false
239                 })}
240 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
241                         94,
242                         "engine.fuel.rate",
243                         0,
244                         0,
245                         UNIT::INVALID,
246                         1.00000f,
247                         decoder_t::decode_obd2_response,
248                         nullptr,
249                         true,
250                         false
251                 })}
252 ,               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
253                         99,
254                         "engine.torque",
255                         0,
256                         0,
257                         UNIT::INVALID,
258                         1.00000f,
259                         decoder_t::decode_obd2_response,
260                         nullptr,
261                         true,
262                         false
263                 })}
264
265         } // end diagnostic_messages_ vector
266 }); // end message_set entry
267
268 CTLP_ONLOAD(plugin, handle) {
269         afb_api_t api = (afb_api_t) plugin->api;
270         CtlConfigT* CtlConfig = (CtlConfigT*) afb_api_get_userdata(api);
271         application_t* app = (application_t*) getExternalData(CtlConfig);
272
273         return app->add_message_set(cms);
274 }
275
276
277 }