Apollo 10.0
自动驾驶开放平台
version_7f.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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 lincoln {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Version7f::ID = 0x7f;
28
29void Version7f::Parse(const std::uint8_t *bytes, int32_t length,
30 Lincoln *chassis_detail) const {
31 switch (module_name(bytes, length)) {
32 case 0x01:
33 chassis_detail->mutable_brake()->set_major_version(
34 major_version(bytes, length));
35 chassis_detail->mutable_brake()->set_minor_version(
36 minor_version(bytes, length));
37 chassis_detail->mutable_brake()->set_build_number(
38 build_number(bytes, length));
39 break;
40 case 0x02:
41 chassis_detail->mutable_gas()->set_major_version(
42 major_version(bytes, length));
43 chassis_detail->mutable_gas()->set_minor_version(
44 minor_version(bytes, length));
45 chassis_detail->mutable_gas()->set_build_number(
46 build_number(bytes, length));
47 break;
48 case 0x03:
49 chassis_detail->mutable_eps()->set_major_version(
50 major_version(bytes, length));
51 chassis_detail->mutable_eps()->set_minor_version(
52 minor_version(bytes, length));
53 chassis_detail->mutable_eps()->set_build_number(
54 build_number(bytes, length));
55 break;
56 default:
57 break;
58 }
59}
60
61int32_t Version7f::module_name(const std::uint8_t *bytes,
62 int32_t length) const {
63 Byte frame(bytes + 0);
64 int32_t x = frame.get_byte(0, 8);
65 return x; // 0x03 means Steering/Shifter, otherwise ignore
66}
67
68int32_t Version7f::major_version(const std::uint8_t *bytes,
69 int32_t length) const {
70 Byte frame_high(bytes + 3);
71 int32_t high = frame_high.get_byte(0, 8);
72 Byte frame_low(bytes + 2);
73 int32_t low = frame_low.get_byte(0, 8);
74 int32_t value = (high << 8) | low;
75 return value;
76}
77
78int32_t Version7f::minor_version(const std::uint8_t *bytes,
79 int32_t length) const {
80 Byte frame_high(bytes + 5);
81 int32_t high = frame_high.get_byte(0, 8);
82 Byte frame_low(bytes + 4);
83 int32_t low = frame_low.get_byte(0, 8);
84 int32_t value = (high << 8) | low;
85 return value;
86}
87
88int32_t Version7f::build_number(const std::uint8_t *bytes,
89 int32_t length) const {
90 Byte frame_high(bytes + 7);
91 int32_t high = frame_high.get_byte(0, 8);
92 Byte frame_low(bytes + 6);
93 int32_t low = frame_low.get_byte(0, 8);
94 int32_t value = (high << 8) | low;
95 return value;
96}
97
98} // namespace lincoln
99} // namespace canbus
100} // namespace apollo
Defines the Byte class.
int32_t build_number(const std::uint8_t *bytes, int32_t length) const
get build number based on byte array.
Definition version_7f.cc:88
int32_t module_name(const std::uint8_t *bytes, int32_t length) const
get module name based on byte array.
Definition version_7f.cc:61
int32_t minor_version(const std::uint8_t *bytes, int32_t length) const
get minor version based on byte array.
Definition version_7f.cc:78
virtual void Parse(const std::uint8_t *bytes, int32_t length, Lincoln *chassis_detail) const
Definition version_7f.cc:29
int32_t major_version(const std::uint8_t *bytes, int32_t length) const
get major version based on byte array.
Definition version_7f.cc:68
class register implement
Definition arena_queue.h:37