#[macro_use] extern crate clap; mod cfg_reader; mod pulse_counter; mod rest_api; use async_std; use async_std::task; const APP_VERSION: &'static str = env!("CARGO_PKG_VERSION"); const DEFAULT_CONFIG_FILE_NAME: &str = "/etc/s0_logger.cfg"; fn main() { let cli_args = clap_app!(s0_meter => (version: APP_VERSION) (author: "Harald Kube println!("No logging"), 1 => println!("A little logging"), 2 => println!("A little more logging"), _ => println!("A lot logging"), }; let config_file_name = cli_args .value_of("config") .unwrap_or(DEFAULT_CONFIG_FILE_NAME); println!("Read the config from file '{}'", config_file_name); if cfg!(feature = "rppal") { println!("Will access GPIO pins"); } else if cfg!(feature = "hal") { println!("Will access HAL"); } else { println!("Will NOT access GPIO pins"); } let rest_api_config = rest_api::RestApiConfig { ip_and_port: String::from("127.0.0.1:8080"), get_channels: fake_get_channels, get_pulses_by_channel: fake_get_pulses_by_channel, }; let _ = task::block_on(rest_api::start(&rest_api_config)); } fn fake_get_channels() -> Vec { vec![] } fn fake_get_pulses_by_channel(_: usize) -> Result, std::io::Error> { Err(std::io::Error::new( std::io::ErrorKind::NotFound, "Not implemented", )) }