Apollo 10.0
自动驾驶开放平台
tirepressure_71.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 Tirepressure71::ID = 0x71;
28
29void Tirepressure71::Parse(const std::uint8_t *bytes, int32_t length,
30 Lincoln *chassis_detail) const {
31 chassis_detail->mutable_safety()->set_front_left_tire_press(
32 front_left_tire(bytes, length));
33 chassis_detail->mutable_safety()->set_front_right_tire_press(
34 front_right_tire(bytes, length));
35 chassis_detail->mutable_safety()->set_rear_left_tire_press(
36 rear_left_tire(bytes, length));
37 chassis_detail->mutable_safety()->set_rear_right_tire_press(
38 rear_right_tire(bytes, length));
39}
40
41int32_t Tirepressure71::front_left_tire(const std::uint8_t *bytes,
42 int32_t length) const {
43 Byte high_frame(bytes + 1);
44 int32_t high = high_frame.get_byte(0, 8);
45 Byte low_frame(bytes + 0);
46 int32_t low = low_frame.get_byte(0, 8);
47 return (high << 8) | low;
48}
49
50int32_t Tirepressure71::front_right_tire(const std::uint8_t *bytes,
51 int32_t length) const {
52 Byte high_frame(bytes + 3);
53 int32_t high = high_frame.get_byte(0, 8);
54 Byte low_frame(bytes + 2);
55 int32_t low = low_frame.get_byte(0, 8);
56 return (high << 8) | low;
57}
58
59int32_t Tirepressure71::rear_left_tire(const std::uint8_t *bytes,
60 int32_t length) const {
61 Byte high_frame(bytes + 5);
62 int32_t high = high_frame.get_byte(0, 8);
63 Byte low_frame(bytes + 4);
64 int32_t low = low_frame.get_byte(0, 8);
65 return (high << 8) | low;
66}
67
68int32_t Tirepressure71::rear_right_tire(const std::uint8_t *bytes,
69 int32_t length) const {
70 Byte high_frame(bytes + 7);
71 int32_t high = high_frame.get_byte(0, 8);
72 Byte low_frame(bytes + 6);
73 int32_t low = low_frame.get_byte(0, 8);
74 return (high << 8) | low;
75}
76
77} // namespace lincoln
78} // namespace canbus
79} // namespace apollo
Defines the Byte class.
virtual void Parse(const std::uint8_t *bytes, int32_t length, Lincoln *chassis_detail) const
class register implement
Definition arena_queue.h:37
the class of Tirepressure71 (for lincoln vehicle)