diff --git a/src/shared/drivers/usart/USART.cpp b/src/shared/drivers/usart/USART.cpp index 65e675a44cad64402923d964c3b1f9979baef0ce..f60758e2d976f8bff34f526830fcd4f2ea5527a8 100644 --- a/src/shared/drivers/usart/USART.cpp +++ b/src/shared/drivers/usart/USART.cpp @@ -514,7 +514,7 @@ int USART::write(void *buffer, size_t nBytes) // TODO: Use the send complete interrupt in order not to have a busy while // loop waiting const char *buf = reinterpret_cast<const char *>(buffer); - size_t i = 0; + size_t i; for (i = 0; i < nBytes; i++) { while ((usart->SR & USART_SR_TXE) == 0) diff --git a/src/shared/radio/SerialTransceiver/SerialTransceiver.h b/src/shared/radio/SerialTransceiver/SerialTransceiver.h index 6d49174699d56e0431467c9c09a042be9ba9fcbd..f5e0ae00b22a814f475341a31626bf1548bb6bcf 100644 --- a/src/shared/radio/SerialTransceiver/SerialTransceiver.h +++ b/src/shared/radio/SerialTransceiver/SerialTransceiver.h @@ -22,6 +22,7 @@ #pragma once +#include <drivers/usart/USART.h> #include <radio/Transceiver.h> #include <iostream> @@ -33,19 +34,21 @@ namespace Boardcore class SerialTransceiver : public Transceiver { public: + SerialTransceiver(USARTInterface& usart) : usart(usart) {} + bool send(uint8_t* packet, size_t packetLength) { - for (size_t i = 0; i < packetLength; i++) - std::cout << packet[i]; - std::cout << "\n"; + usart.write(packet, packetLength); return true; } ssize_t receive(uint8_t* packet, size_t packetLength) { - std::cin.read(reinterpret_cast<char*>(packet), packetLength); - return packetLength; + return usart.read(packet, packetLength); } + +private: + USARTInterface& usart; }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore