generated from libhal/libhal-__arm_mcu_family__
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This code came in without a pull request and before some of the newer style guide requirements were added.
- Loading branch information
Showing
18 changed files
with
160 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,3 @@ conanbuildinfo.txt | |
|
||
# CMake | ||
CMakeUserPresets.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,40 @@ | ||
#include <unistd.h> | ||
|
||
#include <iostream> | ||
#include <span> | ||
#include <string_view> | ||
|
||
#include <libhal-linux/serial.hpp> | ||
#include <libhal-util/serial.hpp> | ||
#include <span> | ||
#include <unistd.h> | ||
|
||
void application() | ||
{ | ||
std::cout << "UART test\n"; | ||
auto serial_file_path = "/dev/serial0"; | ||
constexpr auto serial_file_path = "/dev/serial0"; | ||
auto serial_bus = hal::gnu_linux::serial(serial_file_path); | ||
std::string test_str = "Hello from libhal\n"; | ||
std::string_view const test_str = "Hello from libhal\n"; | ||
std::array<hal::byte, 255> input_buffer = { 0 }; | ||
|
||
while (true) { | ||
hal::print(serial_bus, test_str); | ||
|
||
sleep(1); | ||
auto read_res = serial_bus.read(input_buffer); | ||
if (input_buffer.at(0) == '\0') { | ||
|
||
auto const received_data = serial_bus.read(input_buffer); | ||
|
||
if (received_data.data.empty()) { | ||
std::cout << "Nothing to read\n"; | ||
continue; | ||
} | ||
std::cout << "Len of res buffer: " << read_res.data.size() | ||
|
||
std::cout << "Len of res buffer: " << received_data.data.size() | ||
<< " len of input buffer: " << input_buffer.size() << "\n"; | ||
auto subspan = read_res.data.subspan(0, read_res.data.size()); | ||
auto read_string = std::string(subspan.begin(), subspan.end()); | ||
auto const read_string = | ||
std::string_view(reinterpret_cast<char const*>(received_data.data.data()), | ||
received_data.data.size()); | ||
|
||
sleep(1); | ||
std::cout << "Read from serial:" << read_string; | ||
|
||
std::cout << "Read from serial: " << read_string << "\n"; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.