-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInfoTable.c
More file actions
110 lines (89 loc) · 3.6 KB
/
InfoTable.c
File metadata and controls
110 lines (89 loc) · 3.6 KB
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
//-----------------------------------------------------------------------------
//By using and accessing this material you agree to the terms of the Sample Code
//License Agreement found here. If you do not agree you may not access
//or otherwise use this information.
//-----------------------------------------------------------------------------
// Module Notes:
// =============
//
// Notes
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "Types.h"
#include "string.h"
#include "statemachine.h"
#include "CANTxManager.h"
#include "InfoTable.h"
#include <stdio.h>
//-----------------------------------------------------------------------------
// Macros
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// User defined types
//-----------------------------------------------------------------------------
typedef enum
{
GO_STATUS_IGNITION = 0,
GO_STATUS_END_OF_LIST
} GoStatusTypes_t;
//-----------------------------------------------------------------------------
// Module variable declarations
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Module function declarations
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Module constants
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Function definitions
//-----------------------------------------------------------------------------
// ****************************************************************
// *********************** STATIC METHODS *************************
// ****************************************************************
// ****************************************************************
// ************** START of InfoTable Message Handlers *************
// ****************************************************************
void InfoTable_StoreStatus(IOExpanderMsg_t * IOExpanderMsg)
{
int i;
//Print a received message to user console
printf("Received message_id = 0x%x: Status Information from GO - ", MSG_ID_GO_STATUS_INFORMATION);
for(i = 0; i < IOExpanderMsg->bLength; i++)
{
printf("0x%x ", IOExpanderMsg->abData[i]);
}
printf("\n");
uint16_t usType; // Presumed present when read, but validated by the length check
memcpy(&usType, IOExpanderMsg->abData, sizeof(usType));
static const uint8_t abGoStatusLengths[GO_STATUS_END_OF_LIST] = {3}; // Must be min of 2 for the type
if ((usType < GO_STATUS_END_OF_LIST) && (abGoStatusLengths[usType] == IOExpanderMsg->bLength))
{
switch (usType)
{
case GO_STATUS_IGNITION:
{
//Print ignition's status to user console
if(IOExpanderMsg->abData[2])
{
printf("Ignition on\n");
}
else
{
printf("Ignition off\n");
}
break;
}
default:
// Unknown type
break;
}
}
}
// ****************************************************************
// *************** END of InfoTable Message Handlers **************
// ****************************************************************
//End of file