Line data Source code
1 : #include "fromhost.hpp" 2 : #include "log.hpp" 3 : 4 : static volatile std::sig_atomic_t signal_status; 5 5 : void signal_handler(int s){signal_status = s;} 6 : 7 5 : int main(int argc, char** argv) 8 : { 9 5 : std::unique_ptr<ConfigToFlxToFile> c = std::make_unique<ConfigToFlxToFile>(); 10 5 : c->parse(argc, argv); 11 : 12 5 : auto fh = FromHost<ConfigToFlxToFile, FileDevice, FileFromHostBuffer>(std::move(c)); 13 10 : for (auto & dev_no : fh.cfg->resource.device){ 14 5 : LOG_INFO("DEVICE %d", dev_no); 15 5 : fh.devices.emplace_back(new FileDevice(*fh.cfg, dev_no)); 16 10 : fh.dma_buffers.emplace(dev_no, 17 15 : new FileFromHostBuffer(fh.devices.back(), fh.cfg->file, fh.cfg->fifo_as_file)); 18 : } 19 5 : fh.start(); 20 : 21 5 : std::signal(SIGINT, signal_handler); 22 5 : std::signal(SIGTERM, signal_handler); 23 : 24 31 : while (signal_status == 0) { 25 21 : fh.print_monitoring(); 26 21 : usleep(fh.cfg->stats.monitoring_period_ms * 1000); 27 : } 28 5 : LOG_INFO("Received signal %d, exiting...", signal_status); 29 5 : fh.stop(); 30 5 : return 0; 31 5 : }