diff --git a/src/service.rs b/src/service.rs index 2c15214..8aa1790 100644 --- a/src/service.rs +++ b/src/service.rs @@ -8,6 +8,8 @@ use service_specific::*; use shared::config::{Config, COMMAND_COUNT, COMMAND_PAUSE}; fn main() -> Result<()> { + println!("startup macroboard service"); + // azdelivery usart device // let usb_device = UsbId { // vendor_id: 0x0403, @@ -37,6 +39,8 @@ fn main() -> Result<()> { let mut button_infos = [Duration::default(); COMMAND_COUNT]; let start_time = Instant::now(); + println!("service is now listening ..."); + // loop forever loop { // handle incoming message @@ -77,8 +81,8 @@ fn execute_button_press( } // check that this commands last execution is longer than COMMAND_PAUSE ago - if (button_infos[button_id] + COMMAND_PAUSE) < time { - button_infos[button_id] = time; + if (button_infos[button_id - 1] + COMMAND_PAUSE) < time { + button_infos[button_id - 1] = time; } else { return Ok(()); } diff --git a/src/service_specific/port.rs b/src/service_specific/port.rs index 4a43f7c..57cf981 100644 --- a/src/service_specific/port.rs +++ b/src/service_specific/port.rs @@ -32,6 +32,8 @@ impl Port { pub fn open(usb_device: UsbId, settings: SerialPortSettings) -> Result { let port_path = Self::loop_usb_devices(usb_device)?; + println!("found device at path {}", port_path); + let port = serialport::new(port_path, settings.baud_rate) .data_bits(settings.data_bits) .parity(settings.parity) @@ -72,6 +74,11 @@ impl Port { return Ok(device); } + println!( + "no device found with {}:{}", + usb_device.vendor_id, usb_device.product_id + ); + std::thread::sleep(Duration::from_secs(2)); } }