William A. Kennington III | 3dd6e9d | 2018-08-16 15:34:32 -0700 | [diff] [blame] | 1 | #include <exception> |
William A. Kennington III | 8a87555 | 2018-08-16 01:38:49 -0700 | [diff] [blame] | 2 | #include <gpioplus/chip.hpp> |
| 3 | #include <gpioplus/handle.hpp> |
| 4 | #include <string> |
| 5 | |
| 6 | int main(int argc, char* argv[]) |
William A. Kennington III | 1d25055 | 2018-08-16 00:46:34 -0700 | [diff] [blame] | 7 | { |
William A. Kennington III | 8a87555 | 2018-08-16 01:38:49 -0700 | [diff] [blame] | 8 | if (argc != 3) |
| 9 | { |
| 10 | fprintf(stderr, "pulse [chip id] [line offset]\n"); |
| 11 | return 1; |
| 12 | } |
| 13 | |
William A. Kennington III | 3dd6e9d | 2018-08-16 15:34:32 -0700 | [diff] [blame] | 14 | try |
| 15 | { |
| 16 | unsigned chip_id = std::stoi(argv[1]); |
| 17 | uint32_t line_offset = std::stoi(argv[2]); |
William A. Kennington III | 8a87555 | 2018-08-16 01:38:49 -0700 | [diff] [blame] | 18 | |
William A. Kennington III | 3dd6e9d | 2018-08-16 15:34:32 -0700 | [diff] [blame] | 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; |
William A. Kennington III | 1d25055 | 2018-08-16 00:46:34 -0700 | [diff] [blame] | 33 | } |