Skip to content

Commit

Permalink
grasping at straws
Browse files Browse the repository at this point in the history
  • Loading branch information
TomLonergan03 committed May 28, 2024
1 parent 7097968 commit 144168d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/io/hardware_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <fcntl.h>
#include <unistd.h>

#include <thread>

#include <sys/ioctl.h>

namespace hyped::io {
Expand Down Expand Up @@ -79,6 +81,7 @@ std::optional<std::vector<std::uint8_t>> HardwareSpi::read(const std::uint8_t re
message[1].rx_buf = reinterpret_cast<std::uint64_t>(rx.data());
message[1].len = len;
const int read_result = ioctl(file_descriptor_, SPI_IOC_MESSAGE(2), message);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
if (read_result < 0) {
logger_.log(core::LogLevel::kFatal, "Failed to read from SPI device");
return std::nullopt;
Expand All @@ -103,6 +106,7 @@ core::Result HardwareSpi::write(const std::uint8_t register_address,
message[1].rx_buf = 0;
message[1].len = tx.size();
const int write_result = ioctl(file_descriptor_, SPI_IOC_MESSAGE(2), message);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
if (write_result < 0) {
logger_.log(core::LogLevel::kFatal, "Failed to write to SPI device");
return core::Result::kFailure;
Expand Down

0 comments on commit 144168d

Please sign in to comment.