24 #include <boost/asio.hpp> 25 #include <boost/program_options.hpp> 29 int main(
int argc,
char **argv) {
32 boost::program_options::options_description l_Description(
"Allowed options");
33 l_Description.add_options()
34 (
"help,h",
"produce this help message")
35 (
"version,v",
"show version information")
36 (
"port,p", boost::program_options::value<uint16_t>(),
37 "the TCP port to accept clients on")
41 boost::program_options::variables_map l_VariablesMap;
42 boost::program_options::store(boost::program_options::parse_command_line(argc, argv, l_Description), l_VariablesMap);
43 boost::program_options::notify(l_VariablesMap);
44 if (l_VariablesMap.count(
"version")) {
45 std::cerr <<
"HDLC daemon version " << HDLCD_VERSION_MAJOR <<
"." << HDLCD_VERSION_MINOR
49 if (l_VariablesMap.count(
"help")) {
50 std::cout << l_Description << std::endl;
51 std::cout <<
"The HDLC Daemon is Copyright (C) 2016, and GNU GPL'd, by Florian Evers." << std::endl;
52 std::cout <<
"Bug reports, feedback, admiration, abuse, etc, to: https://github.com/Strunzdesign/hdlcd" << std::endl;
56 if (!l_VariablesMap.count(
"port")) {
57 std::cout <<
"hdlcd: you have to specify the TCP listener port" << std::endl;
58 std::cout <<
"hdlcd: Use --help for more information." << std::endl;
63 boost::asio::io_service l_IoService;
64 boost::asio::signal_set l_Signals(l_IoService);
65 l_Signals.add(SIGINT);
66 l_Signals.add(SIGTERM);
67 l_Signals.async_wait([&l_IoService](boost::system::error_code,
int){ l_IoService.stop(); });
70 auto l_SerialPortHandlerCollection = std::make_shared<SerialPortHandlerCollection> (l_IoService);
71 auto l_HdlcdServerHandlerCollection = std::make_shared<HdlcdServerHandlerCollection>(l_IoService, l_SerialPortHandlerCollection, l_VariablesMap[
"port"].as<uint16_t>());
77 l_HdlcdServerHandlerCollection->Shutdown();
78 l_SerialPortHandlerCollection->Shutdown();
80 }
catch (std::exception& a_Error) {
81 std::cerr <<
"Exception: " << a_Error.what() <<
"\n";
The HDLC Deamon implements the HDLC protocol to easily talk to devices connected via serial communica...
#define HDLCD_DEVEL_VERSION_MINOR
int main(int argc, char **argv)
The HDLC Deamon implements the HDLC protocol to easily talk to devices connected via serial communica...
#define HDLCD_DEVEL_VERSION_MAJOR