blob: 15101bb9dd81500e14b75d62619e35c7a7605a23 [file] [log] [blame]
William A. Kennington III3dd6e9d2018-08-16 15:34:32 -07001#include <exception>
William A. Kennington III8a875552018-08-16 01:38:49 -07002#include <gpioplus/chip.hpp>
3#include <gpioplus/handle.hpp>
4#include <string>
5
6int main(int argc, char* argv[])
William A. Kennington III1d250552018-08-16 00:46:34 -07007{
William A. Kennington III8a875552018-08-16 01:38:49 -07008 if (argc != 3)
9 {
10 fprintf(stderr, "pulse [chip id] [line offset]\n");
11 return 1;
12 }
13
William A. Kennington III3dd6e9d2018-08-16 15:34:32 -070014 try
15 {
16 unsigned chip_id = std::stoi(argv[1]);
17 uint32_t line_offset = std::stoi(argv[2]);
William A. Kennington III8a875552018-08-16 01:38:49 -070018
William A. Kennington III3dd6e9d2018-08-16 15:34:32 -070019 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;
William A. Kennington III1d250552018-08-16 00:46:34 -070033}