Skip to content

Commit 6ea7e02

Browse files
committed
cleanup
1 parent a4a4a53 commit 6ea7e02

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

robotiq_hande_driver/hardware/include/robotiq_hande_driver/communication.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum class OutputBytes : uint8_t {
2626
SPEED,
2727
BYTES_MAX
2828
};
29+
static constexpr auto NUM_OF_OUTPUT_BYTES = static_cast<size_t>(OutputBytes::BYTES_MAX);
2930
static constexpr auto OUTPUT_REGISTER_WORD_LENGTH = static_cast<uint>(OutputBytes::BYTES_MAX) / 2;
3031

3132
enum class InputBytes : uint8_t {
@@ -37,6 +38,7 @@ enum class InputBytes : uint8_t {
3738
POSITION,
3839
BYTES_MAX
3940
};
41+
static constexpr auto NUM_OF_INPUT_BYTES = static_cast<size_t>(OutputBytes::BYTES_MAX);
4042
static constexpr auto INPUT_REGISTER_WORD_LENGTH = static_cast<uint>(InputBytes::BYTES_MAX) / 2;
4143

4244
/**
@@ -104,10 +106,9 @@ class Communication {
104106
// int result;
105107

106108
while(running) {
107-
// sleep for 100ms
108109
std::this_thread::sleep_for(std::chrono::milliseconds(100));
109110

110-
for(size_t i = 0; i < static_cast<size_t>(OutputBytes::BYTES_MAX); ++i) {
111+
for(size_t i = 0; i < NUM_OF_OUTPUT_BYTES; ++i) {
111112
output_bytes_modbus_[i] = output_bytes_[i].load(std::memory_order_relaxed);
112113
}
113114

@@ -120,7 +121,7 @@ class Communication {
120121
INPUT_REGISTER_WORD_LENGTH,
121122
reinterpret_cast<uint16_t*>(input_bytes_modbus_));
122123

123-
for(size_t i = 0; i < static_cast<size_t>(InputBytes::BYTES_MAX); ++i) {
124+
for(size_t i = 0; i < NUM_OF_INPUT_BYTES; ++i) {
124125
input_bytes_[i].store(input_bytes_modbus_[i], std::memory_order_relaxed);
125126
}
126127
}

0 commit comments

Comments
 (0)