1 #include <attn/attn_monitor.hpp> 2 3 namespace attn 4 { 5 6 /** 7 * @brief Attention handler application main() 8 */ attnDaemon(Config * i_config)9int attnDaemon(Config* i_config) 10 { 11 int rc = 0; // assume success 12 13 gpiod_line* line; // gpio line to monitor 14 15 boost::asio::io_context io; // async io monitoring service 16 17 // GPIO line configuration (falling edge, active low) 18 struct gpiod_line_request_config config 19 { 20 "attention", GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE, 0 21 }; 22 23 // get handle to attention GPIO line 24 line = gpiod_line_find("checkstop"); 25 26 if (nullptr == line) 27 { 28 rc = 1; // error 29 } 30 else 31 { 32 // Creating a vector of one gpio to monitor 33 std::vector<std::unique_ptr<attn::AttnMonitor>> gpios; 34 gpios.push_back( 35 std::make_unique<attn::AttnMonitor>(line, config, io, i_config)); 36 37 io.run(); // start GPIO monitor 38 39 // done with line, manually close chip (per gpiod api comments) 40 gpiod_line_close_chip(line); 41 } 42 43 return rc; 44 } 45 46 } // namespace attn 47