Browse Source

update

master
zhaohe 4 months ago
parent
commit
6ff2031d47
  1. 2
      CMakeLists.txt
  2. 3
      README.md
  3. 22
      resource/config.ini
  4. 22
      test/config.ini
  5. 42
      test/tomldemo.cpp
  6. 0
      tools/build.sh
  7. 0
      tools/deply.sh
  8. 0
      tools/packet.sh

2
CMakeLists.txt

@ -51,7 +51,7 @@ file(GLOB_RECURSE VAR_APP_SOURCE #
message("VAR_APP_SOURCE: ${VAR_APP_SOURCE}") message("VAR_APP_SOURCE: ${VAR_APP_SOURCE}")
zadd_executable( zadd_executable(
TARGET TARGET
app.out #
a8000_linux_hardware_service #
INSTALL INSTALL
./app/ ./app/
# #

3
README.md

@ -21,4 +21,7 @@
``` ```
第三方库说明: 第三方库说明:
https://iflytop1.feishu.cn/wiki/wikcnDuCFRGDunHGzns8gRV4Ahh https://iflytop1.feishu.cn/wiki/wikcnDuCFRGDunHGzns8gRV4Ahh
sudo apt install clang llvm gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
``` ```

22
resource/config.ini

@ -0,0 +1,22 @@
[can]
type=zexcan
ifname=can0
baudrate=500000
enable=true
[printer]
type=uart
ifname=/dev/ttyS1
baudrate=115200
enable=true
[emergency-key]
type=input-key
pinnum=GPIO2-A3
enable=true
[lis]
type=uart
ifname=/dev/ttyS2
baudrate=115200
enable=true

22
test/config.ini

@ -0,0 +1,22 @@
[can]
type=zexcan
ifname=can0
baudrate=500000
enable=true
[printer]
type=uart
ifname=/dev/ttyS1
baudrate=115200
enable=true
[emergency-key]
type=input-key
pinnum=GPIO2-A3
enable=true
[lis]
type=uart
ifname=/dev/ttyS2
baudrate=115200
enable=true

42
test/tomldemo.cpp

@ -1,42 +1,20 @@
#include <toml++/toml.hpp>
#include <string>
#include <iostream> #include <iostream>
#include <string>
#include <string_view> #include <string_view>
#include <toml++/toml.hpp>
// g++ tomldemo.cpp -I ../libs/tomlplusplus -std=c++17 // g++ tomldemo.cpp -I ../libs/tomlplusplus -std=c++17
using namespace std::literals; using namespace std::literals;
int main(int argc, char const* argv[]) {
auto config = toml::parse_file("configuration.toml");
// get key-value pairs
std::string_view library_name = config["library"]["name"].value_or(""sv);
std::string_view library_author = config["library"]["authors"][0].value_or(""sv);
int64_t depends_on_cpp_version = config["dependencies"]["cpp"].value_or(0);
// modify the data
config.insert_or_assign("alternatives", toml::array{"cpptoml", "toml11", "Boost.TOML"});
// use a visitor to iterate over heterogenous data
config.for_each([](auto& key, auto& value) {
std::cout << value << "\n";
// if constexpr (toml::is_string<decltype(value)>) do_something_with_string_values(value);
});
// you can also iterate more 'traditionally' using a ranged-for
for (auto&& [k, v] : config) {
// ...
int main(int argc, char** argv) {
toml::table tbl;
try {
tbl = toml::parse_file("config.ini");
std::cout << tbl << "\n";
} catch (const toml::parse_error& err) {
std::cerr << "Parsing failed:\n" << err << "\n";
return 1;
} }
// re-serialize as TOML
std::cout << config << "\n";
// re-serialize as JSON
std::cout << toml::json_formatter{config} << "\n";
// re-serialize as YAML
std::cout << toml::yaml_formatter{config} << "\n";
return 0; return 0;
} }

0
build.sh → tools/build.sh

0
toolchain/.mark → tools/deply.sh

0
packet.sh → tools/packet.sh

Loading…
Cancel
Save