sudo usermod -aG dialout $USER
ubuntu 22.04
ubuntu 21.04
cmake
| wget
| nlohmann-json
| libspdlog
sudo apt install build-essential cmake wget nlohmann-json3-dev libspdlog-dev
git clone https://github.com/ladianchad/LachaCom.git
cd LachaCom
mkdir build && cd build
sudo cmake --build --install ..
#include <communication/interface.hpp>
#include <communication/interfaces/uart.hpp>
#include <stdio.h>
void onSysPoll(const char in){
printf("read : %c", in);
}
int main(int argc, char const *argv[])
{
using namespace communication;
Logger::set_level(Logger::level::debug);
InterfaceInitParam param({
{UART::USE_SYS_POLLING, true},
{UART::PORT, "/dev/ttyUSB0"},
{UART::BAUDRATE, 115200}
});
UART uart;
uart.init(param);
uart.setSysPollingCallback(onSysPoll);
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
return 0;
}
#include <communication/interface.hpp>
#include <communication/interfaces/uart.hpp>
#include <iostream>
int main(int argc, char const *argv[])
{
using namespace communication;
Logger::set_level(Logger::level::debug);
InterfaceInitParam param({
{UART::USE_SYS_POLLING, true},
{UART::PORT, "/dev/ttyUSB0"},
{UART::BAUDRATE, 115200}
});
UART uart;
uart.init(param);
uart.setSysPollingCallback([&](const char c){
std::cout<<"read : "<<c<<std::endl;
});
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
return 0;
}
cmake_minimum_required(VERSION 3.0.2)
project(your project)
findpackage(LaChaCom REQUIRED)
add_executable(${your_executable})
target_link_library(${your_executable} LaChaCom::LaChaCom)
Now Exist
- Serial
TODO
- Socket
- I2C