blob: 23eee2cd745eb54c27a60216fd3c80d7e3a83fbf [file] [log] [blame]
William A. Kennington III8a875552018-08-16 01:38:49 -07001#include <gpioplus/chip.hpp>
2#include <gpioplus/handle.hpp>
Patrick Williams7ba248a2023-05-10 07:51:30 -05003
4#include <exception>
William A. Kennington III8a875552018-08-16 01:38:49 -07005#include <string>
6
7int main(int argc, char* argv[])
William A. Kennington III1d250552018-08-16 00:46:34 -07008{
William A. Kennington III8a875552018-08-16 01:38:49 -07009 if (argc != 3)
10 {
11 fprintf(stderr, "pulse [chip id] [line offset]\n");
12 return 1;
13 }
14
William A. Kennington III3dd6e9d2018-08-16 15:34:32 -070015 try
16 {
17 unsigned chip_id = std::stoi(argv[1]);
18 uint32_t line_offset = std::stoi(argv[2]);
William A. Kennington III8a875552018-08-16 01:38:49 -070019
William A. Kennington III3dd6e9d2018-08-16 15:34:32 -070020 gpioplus::Chip chip(chip_id);
21 gpioplus::HandleFlags flags(chip.getLineInfo(line_offset).flags);
22 flags.output = true;
23 gpioplus::Handle handle(chip, {{line_offset, 0}}, flags,
24 "example/pulse");
25 handle.setValues({1});
26 handle.setValues({0});
27 return 0;
28 }
29 catch (const std::exception& e)
30 {
31 fprintf(stderr, "Error: %s\n", e.what());
32 }
33 return 1;
William A. Kennington III1d250552018-08-16 00:46:34 -070034}