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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
|
/*
* Copyright (c) 2021, Nippon Seiki Co., Ltd.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <ipc.h>
#include <cluster_api.h>
#include <cluster_api_internal.h>
static IPC_DATA_IC_SERVICE_S gAllSigData;
static unsigned long long gRegisteredSignals = 0x0000000000000000ULL;
static IC_HMI_FUNC_NOTIFY_IC_HMI gNotifyIcHmiCB;
static IPC_RET_E clusterClientStart(void);
static IPC_RET_E clusterReadDataPool(void);
static IPC_RET_E clusterRegisterCallback(void);
static IPC_RET_E clusterClientStop(void);
static void notifyCheck(void* pData, signed int size, int kind);
// == Internal functions ==
static IPC_RET_E clusterClientStart(void)
{
IPC_RET_E ret;
ret = ipcClientStart(IPC_USAGE_TYPE_IC_SERVICE);
E_CHECK(ret == IPC_RET_OK, ret, end);
end:
return ret;
}
static IPC_RET_E clusterRegisterCallback(void)
{
IPC_RET_E ret;
ret = ipcRegisterCallback(IPC_USAGE_TYPE_IC_SERVICE, ¬ifyCheck);
E_CHECK(ret == IPC_RET_OK, ret, end);
end:
return ret;
}
static void notifyCheck(void* pData, signed int size, int kind)
{
IC_HMI_ON_OFF data = 0;
if (gNotifyIcHmiCB == NULL) {
return;
}
// If signal is registered, notify IC HMI
if (gSigTable[kind] == (gSigTable[kind] & gRegisteredSignals))
{
memcpy(&data, pData, size);
gNotifyIcHmiCB(gSigTable[kind], data);
}
}
static IPC_RET_E clusterClientStop(void)
{
IPC_RET_E ret;
ret = ipcClientStop(IPC_USAGE_TYPE_IC_SERVICE);
E_CHECK(ret == IPC_RET_OK, ret, end);
end:
return ret;
}
static IPC_RET_E clusterReadDataPool()
{
IPC_RET_E ret;
int sigDataSize = sizeof(gAllSigData);
ret = ipcReadDataPool(IPC_USAGE_TYPE_IC_SERVICE, &gAllSigData, &sigDataSize);
E_CHECK(ret == IPC_RET_OK, ret, end);
E_CHECK(sigDataSize == sizeof(gAllSigData), sigDataSize, end);
ret = IPC_RET_OK;
end:
return ret;
}
// == API functions for apps ==
// === Initialize/Terminate ===
bool clusterInit(void)
{
bool ret = false;
IPC_RET_E rc;
memset(&gAllSigData, 0x00, sizeof(gAllSigData));
gRegisteredSignals = 0x0000000000000000ULL;
gNotifyIcHmiCB = NULL;
rc = clusterClientStart();
E_CHECK(rc == IPC_RET_OK, rc, end);
rc = clusterRegisterCallback();
E_CHECK(rc == IPC_RET_OK, rc, end);
ret = true;
end:
return ret;
}
bool clusterTerm(void)
{
bool ret = false;
IPC_RET_E rc;
rc = clusterClientStop();
E_CHECK(rc == IPC_RET_OK, rc, end);
memset(&gAllSigData, 0x00, sizeof(gAllSigData));
gRegisteredSignals = 0x0000000000000000ULL;
gNotifyIcHmiCB = NULL;
ret = true;
end:
return ret;
}
// === Register/Notify ===
bool registerIcHmi(unsigned long long arg_1, IC_HMI_FUNC_NOTIFY_IC_HMI addr)
{
if (addr == NULL) {
return false;
}
gNotifyIcHmiCB = addr;
gRegisteredSignals = (gRegisteredSignals | arg_1);
return true;
}
// === Telltale ===
IC_HMI_ON_OFF getTurnR(void)
{
clusterReadDataPool();
return gAllSigData.turnR;
}
IC_HMI_ON_OFF getTurnL(void)
{
clusterReadDataPool();
return gAllSigData.turnL;
}
IC_HMI_ON_OFF getBrake(void)
{
clusterReadDataPool();
return gAllSigData.brake;
}
IC_HMI_ON_OFF getSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.seatbelt;
}
IC_HMI_ON_OFF getFrontRightSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.frontRightSeatbelt;
}
IC_HMI_ON_OFF getFrontCenterSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.frontCenterSeatbelt;
}
IC_HMI_ON_OFF getFrontLeftSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.frontLeftSeatbelt;
}
IC_HMI_ON_OFF getMid1RightSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.mid1RightSeatbelt;
}
IC_HMI_ON_OFF getMid1CenterSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.mid1CenterSeatbelt;
}
IC_HMI_ON_OFF getMid1LeftSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.mid1LeftSeatbelt;
}
IC_HMI_ON_OFF getMid2RightSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.mid2RightSeatbelt;
}
IC_HMI_ON_OFF getMid2CenterSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.mid2CenterSeatbelt;
}
IC_HMI_ON_OFF getMid2LeftSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.mid2LeftSeatbelt;
}
IC_HMI_ON_OFF getRearRightSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.rearRightSeatbelt;
}
IC_HMI_ON_OFF getRearCenterSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.rearCenterSeatbelt;
}
IC_HMI_ON_OFF getRearLeftSeatbelt(void)
{
clusterReadDataPool();
return gAllSigData.rearLeftSeatbelt;
}
IC_HMI_ON_OFF getHighbeam(void)
{
clusterReadDataPool();
return gAllSigData.highbeam;
}
IC_HMI_ON_OFF getDoor(void)
{
clusterReadDataPool();
return gAllSigData.door;
}
IC_HMI_ON_OFF getFrontRightDoor(void)
{
clusterReadDataPool();
return gAllSigData.frontRightDoor;
}
IC_HMI_ON_OFF getFrontLeftDoor(void)
{
clusterReadDataPool();
return gAllSigData.frontLeftDoor;
}
IC_HMI_ON_OFF getRearRightDoor(void)
{
clusterReadDataPool();
return gAllSigData.rearRightDoor;
}
IC_HMI_ON_OFF getRearLeftDoor(void)
{
clusterReadDataPool();
return gAllSigData.rearLeftDoor;
}
IC_HMI_ON_OFF getTrunkDoor(void)
{
clusterReadDataPool();
return gAllSigData.trunkDoor;
}
IC_HMI_ON_OFF getHoodDoor(void)
{
clusterReadDataPool();
return gAllSigData.hoodDoor;
}
IC_HMI_ON_OFF getEps(void)
{
clusterReadDataPool();
return gAllSigData.eps;
}
IC_HMI_ON_OFF getSrsAirbag(void)
{
clusterReadDataPool();
return gAllSigData.srsAirbag;
}
IC_HMI_ON_OFF getAbs(void)
{
clusterReadDataPool();
return gAllSigData.abs;
}
IC_HMI_ON_OFF getLowBattery(void)
{
clusterReadDataPool();
return gAllSigData.lowBattery;
}
IC_HMI_ON_OFF getOilPress(void)
{
clusterReadDataPool();
return gAllSigData.oilPress;
}
IC_HMI_ON_OFF getEngine(void)
{
clusterReadDataPool();
return gAllSigData.engine;
}
IC_HMI_ON_OFF getFuel(void)
{
clusterReadDataPool();
return gAllSigData.fuel;
}
IC_HMI_ON_OFF getImmobi(void)
{
clusterReadDataPool();
return gAllSigData.immobi;
}
IC_HMI_ON_OFF getTMFail(void)
{
clusterReadDataPool();
return gAllSigData.tmFail;
}
IC_HMI_ON_OFF getEspAct(void)
{
clusterReadDataPool();
return gAllSigData.espAct;
}
IC_HMI_ON_OFF getEspOff(void)
{
clusterReadDataPool();
return gAllSigData.espOff;
}
IC_HMI_ON_OFF getAdaptingLighting(void)
{
clusterReadDataPool();
return gAllSigData.adaptingLighting;
}
IC_HMI_ON_OFF getAutoStop(void)
{
clusterReadDataPool();
return gAllSigData.autoStop;
}
IC_HMI_ON_OFF getAutoStopFail(void)
{
clusterReadDataPool();
return gAllSigData.autoStopFail;
}
IC_HMI_ON_OFF getParkingLights(void)
{
clusterReadDataPool();
return gAllSigData.parkingLights;
}
IC_HMI_ON_OFF getFrontFog(void)
{
clusterReadDataPool();
return gAllSigData.frontFog;
}
IC_HMI_ON_OFF getExteriorLightFault(void)
{
clusterReadDataPool();
return gAllSigData.exteriorLightFault;
}
IC_HMI_ON_OFF getAccFail(void)
{
clusterReadDataPool();
return gAllSigData.accFail;
}
IC_HMI_ON_OFF getLdwOff(void)
{
clusterReadDataPool();
return gAllSigData.ldwOff;
}
IC_HMI_ON_OFF getHillDescent(void)
{
clusterReadDataPool();
return gAllSigData.hillDescent;
}
IC_HMI_ON_OFF getAutoHiBeamGreen(void)
{
clusterReadDataPool();
return gAllSigData.autoHiBeamGreen;
}
IC_HMI_ON_OFF getAutoHiBeamAmber(void)
{
clusterReadDataPool();
return gAllSigData.autoHiBeamAmber;
}
IC_HMI_ON_OFF getSportsMode(void)
{
clusterReadDataPool();
return gAllSigData.sportsMode;
}
IC_HMI_ON_OFF getLdwOperate(void)
{
clusterReadDataPool();
return gAllSigData.ldwOperate;
}
IC_HMI_ON_OFF getGeneralWarn(void)
{
clusterReadDataPool();
return gAllSigData.generalWarn;
}
IC_HMI_ON_OFF getDriverPowerMode(void)
{
clusterReadDataPool();
return gAllSigData.drivingPowerMode;
}
IC_HMI_ON_OFF getHotTemp(void)
{
clusterReadDataPool();
return gAllSigData.hotTemp;
}
IC_HMI_ON_OFF getLowTemp(void)
{
clusterReadDataPool();
return gAllSigData.lowTemp;
}
// === TripComputer ===
unsigned long getTrcomTripAVal(void)
{
clusterReadDataPool();
return gAllSigData.trcomTripAVal;
}
unsigned long getTrcomTripBVal(void)
{
clusterReadDataPool();
return gAllSigData.trcomTripBVal;
}
unsigned long getTrcomOdoVal(void)
{
clusterReadDataPool();
return gAllSigData.trcomOdoVal;
}
IC_HMI_TRCOM_UNIT_VAL getTrcomUnitVal(void)
{
clusterReadDataPool();
return gAllSigData.trcomUnitVal;
}
unsigned short getAvgSpeedAVal(void)
{
clusterReadDataPool();
return gAllSigData.avgSpeedAVal;
}
unsigned short getAvgSpeedBVal(void)
{
clusterReadDataPool();
return gAllSigData.avgSpeedBVal;
}
unsigned short getHourAVal(void)
{
clusterReadDataPool();
return gAllSigData.hourAVal;
}
unsigned short getHourBVal(void)
{
clusterReadDataPool();
return gAllSigData.hourBVal;
}
unsigned char getMinuteAVal(void)
{
clusterReadDataPool();
return gAllSigData.minuteAVal;
}
unsigned char getMinuteBVal(void)
{
clusterReadDataPool();
return gAllSigData.minuteBVal;
}
unsigned char getSecondAVal(void)
{
clusterReadDataPool();
return gAllSigData.secondAVal;
}
unsigned char getSecondBVal(void)
{
clusterReadDataPool();
return gAllSigData.secondBVal;
}
signed short getOTempVal(void)
{
clusterReadDataPool();
return gAllSigData.oTempVal;
}
IC_HMI_OTEMP_UNIT_VAL getOTempUnitVal(void)
{
clusterReadDataPool();
return gAllSigData.oTempUnitVal;
}
unsigned short getCruRangeVal(void)
{
clusterReadDataPool();
return gAllSigData.cruRangeVal;
}
unsigned short getAvgFuelAVal(void)
{
clusterReadDataPool();
return gAllSigData.avgFuelAVal;
}
unsigned short getAvgFuelBVal(void)
{
clusterReadDataPool();
return gAllSigData.avgFuelBVal;
}
unsigned short getInsFuelAVal(void)
{
clusterReadDataPool();
return gAllSigData.insFuelAVal;
}
unsigned short getInsFuelBVal(void)
{
clusterReadDataPool();
return gAllSigData.insFuelBVal;
}
IC_HMI_FUEL_ECONOMY_UNIT_VAL getFuelEconomyUnitVal(void)
{
clusterReadDataPool();
return gAllSigData.fuelEconomyUnitVal;
}
// === ShiftPosition ===
IC_HMI_GEAR_AT_VAL getGearAtVal(void)
{
clusterReadDataPool();
return gAllSigData.gearAtVal;
}
IC_HMI_GEAR_MT_VAL getGearMtVal(void)
{
clusterReadDataPool();
return gAllSigData.gearMtVal;
}
// === Speed ===
unsigned long getSpAnalogVal(void)
{
clusterReadDataPool();
return gAllSigData.spAnalogVal;
}
IC_HMI_SP_UNIT_VAL getSpAnaDigUnitVal(void)
{
clusterReadDataPool();
return gAllSigData.spAnaDigUnitVal;
}
// === Tacho ===
unsigned long getTaAnalogVal(void)
{
clusterReadDataPool();
return gAllSigData.taAnalogVal;
}
|