bmputil 1.1.0

Black Magic Probe companion utility
Documentation
// SPDX-License-Identifier: MIT OR Apache-2.0
// SPDX-FileCopyrightText: 2026 1BitSquared <info@1bitsquared.com>
// SPDX-FileContributor: Written by Kat Mitchell <kat@northernpaws.io>
// SPDX-FileCopyrightText: 2026 1BitSquared <info@1bitsquared.com>
// SPDX-FileContributor: Written by Kat Mitchell <kat@northernpaws.io>

use std::path::Path;
use std::path::PathBuf;
use std::time::Duration;

use serialport::SerialPort;

pub struct AuxInterface
{
	serial_port: PathBuf
}

impl AuxInterface
{
	pub fn from_path(serial_port: &Path) -> Self
	{
		Self {
			serial_port: serial_port.to_owned(),
		}
	}

	/// Returns the path to the serial port in use by the interface.
	pub fn serial_port(&self) -> &PathBuf
	{
		&self.serial_port
	}

	/// Open a handle to the aux serial port.
	pub fn open(&self, baud: u32) -> serialport::Result<Box<dyn SerialPort>> 
	{
		serialport::new(self.serial_port.to_string_lossy(), baud)
			.timeout(Duration::from_millis(10))
			.dtr_on_open(true)
        	.flow_control(serialport::FlowControl::None)
    		.open()
	}
}