-
-
Notifications
You must be signed in to change notification settings - Fork 566
/
my_database_name.h
223 lines (191 loc) · 5.5 KB
/
my_database_name.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
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
/**
* The MIT License (MIT)
*
* Copyright (c) 2018-2019 Erik Moqvist
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
*/
#ifndef MY_DATABASE_NAME_H
#define MY_DATABASE_NAME_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#ifndef EINVAL
# define EINVAL 22
#endif
/* Frame ids. */
#define MY_DATABASE_NAME_EXAMPLE_MESSAGE_FRAME_ID (0x1f0u)
/* Frame lengths in bytes. */
#define MY_DATABASE_NAME_EXAMPLE_MESSAGE_LENGTH (8u)
/* Extended or standard frame types. */
#define MY_DATABASE_NAME_EXAMPLE_MESSAGE_IS_EXTENDED (0)
/* Frame cycle times in milliseconds. */
/* Signal choices. */
#define MY_DATABASE_NAME_EXAMPLE_MESSAGE_ENABLE_DISABLED_CHOICE (0u)
#define MY_DATABASE_NAME_EXAMPLE_MESSAGE_ENABLE_ENABLED_CHOICE (1u)
/* Frame Names. */
#define MY_DATABASE_NAME_EXAMPLE_MESSAGE_NAME "ExampleMessage"
/* Signal Names. */
#define MY_DATABASE_NAME_EXAMPLE_MESSAGE_ENABLE_NAME "Enable"
#define MY_DATABASE_NAME_EXAMPLE_MESSAGE_AVERAGE_RADIUS_NAME "AverageRadius"
#define MY_DATABASE_NAME_EXAMPLE_MESSAGE_TEMPERATURE_NAME "Temperature"
/**
* Signals in message ExampleMessage.
*
* Example message used as template in MotoHawk models.
*
* All signal values are as on the CAN bus.
*/
struct my_database_name_example_message_t {
/**
* Range: -
* Scale: 1
* Offset: 0
*/
uint8_t enable;
/**
* Range: 0..50 (0..5 m)
* Scale: 0.1
* Offset: 0
*/
uint8_t average_radius;
/**
* Range: -2048..2047 (229.52..270.47 degK)
* Scale: 0.01
* Offset: 250
*/
int16_t temperature;
};
/**
* Pack message ExampleMessage.
*
* @param[out] dst_p Buffer to pack the message into.
* @param[in] src_p Data to pack.
* @param[in] size Size of dst_p.
*
* @return Size of packed data, or negative error code.
*/
int my_database_name_example_message_pack(
uint8_t *dst_p,
const struct my_database_name_example_message_t *src_p,
size_t size);
/**
* Unpack message ExampleMessage.
*
* @param[out] dst_p Object to unpack the message into.
* @param[in] src_p Message to unpack.
* @param[in] size Size of src_p.
*
* @return zero(0) or negative error code.
*/
int my_database_name_example_message_unpack(
struct my_database_name_example_message_t *dst_p,
const uint8_t *src_p,
size_t size);
/**
* Init message fields to default values from ExampleMessage.
*
* @param[in] msg_p Message to init.
*
* @return zero(0) on success or (-1) in case of nullptr argument.
*/
int my_database_name_example_message_init(struct my_database_name_example_message_t *msg_p);
/**
* Encode given signal by applying scaling and offset.
*
* @param[in] value Signal to encode.
*
* @return Encoded signal.
*/
uint8_t my_database_name_example_message_enable_encode(double value);
/**
* Decode given signal by applying scaling and offset.
*
* @param[in] value Signal to decode.
*
* @return Decoded signal.
*/
double my_database_name_example_message_enable_decode(uint8_t value);
/**
* Check that given signal is in allowed range.
*
* @param[in] value Signal to check.
*
* @return true if in range, false otherwise.
*/
bool my_database_name_example_message_enable_is_in_range(uint8_t value);
/**
* Encode given signal by applying scaling and offset.
*
* @param[in] value Signal to encode.
*
* @return Encoded signal.
*/
uint8_t my_database_name_example_message_average_radius_encode(double value);
/**
* Decode given signal by applying scaling and offset.
*
* @param[in] value Signal to decode.
*
* @return Decoded signal.
*/
double my_database_name_example_message_average_radius_decode(uint8_t value);
/**
* Check that given signal is in allowed range.
*
* @param[in] value Signal to check.
*
* @return true if in range, false otherwise.
*/
bool my_database_name_example_message_average_radius_is_in_range(uint8_t value);
/**
* Encode given signal by applying scaling and offset.
*
* @param[in] value Signal to encode.
*
* @return Encoded signal.
*/
int16_t my_database_name_example_message_temperature_encode(double value);
/**
* Decode given signal by applying scaling and offset.
*
* @param[in] value Signal to decode.
*
* @return Decoded signal.
*/
double my_database_name_example_message_temperature_decode(int16_t value);
/**
* Check that given signal is in allowed range.
*
* @param[in] value Signal to check.
*
* @return true if in range, false otherwise.
*/
bool my_database_name_example_message_temperature_is_in_range(int16_t value);
#ifdef __cplusplus
}
#endif
#endif