From 8e46e4d17b645f6e18a1942222efcceaa1260515 Mon Sep 17 00:00:00 2001 From: Oliver Lee Date: Thu, 27 Jul 2023 16:24:36 +0200 Subject: [PATCH] Read values from VESC motor controller Change-Id: Icaad5bd270827f1fa1b22a77d0cd0e23dbf999e5 --- examples/BUILD.bazel | 5 ++++- examples/vesc_cmd.cpp | 11 +++++++++++ uart_abstraction/HardwareSerial.hpp | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index bfa9b66..74faa58 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -3,7 +3,10 @@ load("@rules_cc//cc:defs.bzl", "cc_binary") cc_binary( name = "vesc_cmd", srcs = ["vesc_cmd.cpp"], - deps = ["//third_party/vesc_uart"], + deps = [ + "//third_party/vesc_uart", + "@fmt", + ], ) cc_binary( diff --git a/examples/vesc_cmd.cpp b/examples/vesc_cmd.cpp index 8e40f4b..1136e81 100644 --- a/examples/vesc_cmd.cpp +++ b/examples/vesc_cmd.cpp @@ -1,8 +1,19 @@ #include "third_party/vesc_uart/VescUart.h" +//#include "" + +#include +#include auto main() -> int { ::VescUartSetCurrent(1.0F); + auto cmd_get_values = std::uint8_t{ COMM_GET_VALUES }; + constexpr auto serial_device = 0; + ::PackSendPayload(&cmd_get_values, sizeof(cmd_get_values), serial_device); + + const auto len_payload = Serial.read(); + fmt::print("len payload: {}\n", len_payload); + return 0; } diff --git a/uart_abstraction/HardwareSerial.hpp b/uart_abstraction/HardwareSerial.hpp index 0a5af4d..0dd1a87 100644 --- a/uart_abstraction/HardwareSerial.hpp +++ b/uart_abstraction/HardwareSerial.hpp @@ -1,4 +1,4 @@ -// Fake API for UART read/write. +// API for UART read/write. #pragma once