Apollo 10.0
自动驾驶开放平台
ads_diagnosis_628.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
18
20
21namespace apollo {
22namespace canbus {
23namespace neolix_edu {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Adsdiagnosis628::ID = 0x628;
28
29// public
31
33 // TODO(All) : modify every protocol's period manually
34 static const uint32_t PERIOD = 20 * 1000;
35 return PERIOD;
36}
37
38void Adsdiagnosis628::UpdateData(uint8_t* data) {
39 set_p_faultrank(data, faultrank_);
40 set_p_adas_fault_code(data, adas_fault_code_);
41 set_p_adas_softwareversion(data, adas_softwareversion_);
42 set_p_adas_hardwareversion(data, adas_hardwareversion_);
43}
44
46 // TODO(All) : you should check this manually
47 faultrank_ = 0;
48 adas_fault_code_ = 0;
49 adas_softwareversion_ = 0;
50 adas_hardwareversion_ = 0;
51}
52
54 faultrank_ = faultrank;
55 return this;
56}
57
58// config detail: {'description': '0x0:Nomal;0x1:Level 1;0x2:Level 2;0x3:Level
59// 3;0x4:Level 4;0x5:Level 5;0x6:Reserved;0x7:Reserved', 'offset': 0.0,
60// 'precision': 1.0, 'len': 4, 'name': 'FaultRank', 'is_signed_var': False,
61// 'physical_range': '[0|5]', 'bit': 7, 'type': 'int', 'order': 'motorola',
62// 'physical_unit': 'bit'}
63void Adsdiagnosis628::set_p_faultrank(uint8_t* data, int faultrank) {
64 faultrank = ProtocolData::BoundedValue(0, 5, faultrank);
65 int x = faultrank;
66
67 Byte to_set(data + 0);
68 to_set.set_value(x, 4, 4);
69}
70
72 adas_fault_code_ = adas_fault_code;
73 return this;
74}
75
76// config detail: {'name': 'ADAS_Fault_Code', 'offset': 0.0, 'precision': 1.0,
77// 'len': 24, 'is_signed_var': False, 'physical_range': '[0|65535]', 'bit': 3,
78// 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
79void Adsdiagnosis628::set_p_adas_fault_code(uint8_t* data,
80 int adas_fault_code) {
81 adas_fault_code = ProtocolData::BoundedValue(0, 65535, adas_fault_code);
82 int x = adas_fault_code;
83 uint8_t t = 0;
84
85 t = x & 0xF;
86 Byte to_set0(data + 3);
87 to_set0.set_value(t, 4, 4);
88 x >>= 4;
89
90 t = x & 0xFF;
91 Byte to_set1(data + 2);
92 to_set1.set_value(t, 0, 8);
93 x >>= 8;
94
95 t = x & 0xFF;
96 Byte to_set2(data + 1);
97 to_set2.set_value(t, 0, 8);
98 x >>= 8;
99
100 t = x & 0xF;
101 Byte to_set3(data + 0);
102 to_set3.set_value(t, 0, 4);
103}
104
106 int adas_softwareversion) {
107 adas_softwareversion_ = adas_softwareversion;
108 return this;
109}
110
111// config detail: {'name': 'ADAS_SoftwareVersion', 'offset': 0.0,
112// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'physical_range':
113// '[0|255]', 'bit': 55, 'type': 'int', 'order': 'motorola', 'physical_unit':
114// 'bit'}
115void Adsdiagnosis628::set_p_adas_softwareversion(uint8_t* data,
116 int adas_softwareversion) {
117 adas_softwareversion =
118 ProtocolData::BoundedValue(0, 255, adas_softwareversion);
119 int x = adas_softwareversion;
120
121 Byte to_set(data + 6);
122 to_set.set_value(x, 0, 8);
123}
124
126 int adas_hardwareversion) {
127 adas_hardwareversion_ = adas_hardwareversion;
128 return this;
129}
130
131// config detail: {'name': 'ADAS_HardwareVersion', 'offset': 0.0,
132// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'physical_range':
133// '[0|255]', 'bit': 63, 'type': 'int', 'order': 'motorola', 'physical_unit':
134// 'bit'}
135void Adsdiagnosis628::set_p_adas_hardwareversion(uint8_t* data,
136 int adas_hardwareversion) {
137 adas_hardwareversion =
138 ProtocolData::BoundedValue(0, 255, adas_hardwareversion);
139 int x = adas_hardwareversion;
140
141 Byte to_set(data + 7);
142 to_set.set_value(x, 0, 8);
143}
144
145} // namespace neolix_edu
146} // namespace canbus
147} // namespace apollo
Defines the Byte class.
Adsdiagnosis628 * set_faultrank(int faultrank)
Adsdiagnosis628 * set_adas_hardwareversion(int adas_hardwareversion)
Adsdiagnosis628 * set_adas_fault_code(int adas_fault_code)
Adsdiagnosis628 * set_adas_softwareversion(int adas_softwareversion)
class register implement
Definition arena_queue.h:37