rm_control
Loading...
Searching...
No Matches
rm_dbus
include
rm_dbus
dbus.h
Go to the documentation of this file.
1
/*******************************************************************************
2
* BSD 3-Clause License
3
*
4
* Copyright (c) 2021, Qiayuan Liao
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
*
10
* * Redistributions of source code must retain the above copyright notice, this
11
* list of conditions and the following disclaimer.
12
*
13
* * Redistributions in binary form must reproduce the above copyright notice,
14
* this list of conditions and the following disclaimer in the documentation
15
* and/or other materials provided with the distribution.
16
*
17
* * Neither the name of the copyright holder nor the names of its
18
* contributors may be used to endorse or promote products derived from
19
* this software without specific prior written permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
* ARE
25
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
*******************************************************************************/
33
34
//
35
// Created by qiayuan on 2019/10/30.
36
//
37
38
#ifndef SRC_RM_BASE_INCLUDE_RT_RT_DBUS_H_
39
#define SRC_RM_BASE_INCLUDE_RT_RT_DBUS_H_
40
41
#include <cstdint>
42
#include <rm_msgs/DbusData.h>
43
44
typedef
struct
45
{
46
int16_t
ch0
;
47
int16_t
ch1
;
48
int16_t
ch2
;
49
int16_t
ch3
;
50
uint8_t
s0
;
51
uint8_t
s1
;
52
int16_t
wheel
;
53
54
int16_t
x
;
55
int16_t
y
;
56
int16_t
z
;
57
58
uint8_t
l
;
59
uint8_t
r
;
60
uint16_t
key
;
61
62
}
DBusData_t
;
63
64
class
DBus
65
{
66
public
:
67
DBus
() =
default
;
68
~DBus
() =
default
;
69
void
init
(
const
char
* serial);
70
void
getData
(rm_msgs::DbusData& d_bus_data)
const
;
71
void
read
();
72
73
private
:
74
DBusData_t
d_bus_data_{};
75
int
port_{};
76
int16_t buff_[18]{};
77
bool
is_success{};
78
bool
is_update_ =
false
;
79
void
unpack();
80
};
81
82
#endif
// SRC_RM_BRIDGE_INCLUDE_RT_RT_DBUS_H_
DBus
Definition
dbus.h:65
DBus::~DBus
~DBus()=default
DBus::getData
void getData(rm_msgs::DbusData &d_bus_data) const
Definition
dbus.cpp:171
DBus::init
void init(const char *serial)
Definition
dbus.cpp:55
DBus::DBus
DBus()=default
DBus::read
void read()
Definition
dbus.cpp:96
DBusData_t
Definition
dbus.h:45
DBusData_t::x
int16_t x
Definition
dbus.h:54
DBusData_t::ch3
int16_t ch3
Definition
dbus.h:49
DBusData_t::ch2
int16_t ch2
Definition
dbus.h:48
DBusData_t::key
uint16_t key
Definition
dbus.h:60
DBusData_t::y
int16_t y
Definition
dbus.h:55
DBusData_t::ch0
int16_t ch0
Definition
dbus.h:46
DBusData_t::z
int16_t z
Definition
dbus.h:56
DBusData_t::s1
uint8_t s1
Definition
dbus.h:51
DBusData_t::s0
uint8_t s0
Definition
dbus.h:50
DBusData_t::l
uint8_t l
Definition
dbus.h:58
DBusData_t::r
uint8_t r
Definition
dbus.h:59
DBusData_t::wheel
int16_t wheel
Definition
dbus.h:52
DBusData_t::ch1
int16_t ch1
Definition
dbus.h:47
Generated by
1.12.0