1 #include <exception> 2 #include <gpioplus/chip.hpp> 3 #include <gpioplus/handle.hpp> 4 #include <string> 5 6 int main(int argc, char* argv[]) 7 { 8 if (argc != 3) 9 { 10 fprintf(stderr, "pulse [chip id] [line offset]\n"); 11 return 1; 12 } 13 14 try 15 { 16 unsigned chip_id = std::stoi(argv[1]); 17 uint32_t line_offset = std::stoi(argv[2]); 18 19 gpioplus::Chip chip(chip_id); 20 gpioplus::HandleFlags flags(chip.getLineInfo(line_offset).flags); 21 flags.output = true; 22 gpioplus::Handle handle(chip, {{line_offset, 0}}, flags, 23 "example/pulse"); 24 handle.setValues({1}); 25 handle.setValues({0}); 26 return 0; 27 } 28 catch (const std::exception& e) 29 { 30 fprintf(stderr, "Error: %s\n", e.what()); 31 } 32 return 1; 33 } 34