embedded_debugger_mcp/
utils.rs

1//! Utility functions and helper types for the debugger MCP server
2
3/// Probe type enumeration
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum ProbeType {
6    JLink,
7    DapLink,
8    StLink,
9    Blackmagic,
10    Ftdi,
11    Unknown,
12}
13
14impl ProbeType {
15    /// Detect probe type from vendor and product IDs
16    pub fn from_vid_pid(vendor_id: u16, product_id: u16) -> Self {
17        match (vendor_id, product_id) {
18            (0x1366, _) => ProbeType::JLink,
19            (0x0D28, _) => ProbeType::DapLink,
20            (0x0483, 0x374B) | (0x0483, 0x3748) | (0x0483, 0x374A) => ProbeType::StLink,
21            (0x1D50, 0x6018) => ProbeType::Blackmagic,
22            (0x0403, _) => ProbeType::Ftdi,
23            _ => ProbeType::Unknown,
24        }
25    }
26}
27
28impl std::fmt::Display for ProbeType {
29    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30        match self {
31            ProbeType::JLink => write!(f, "J-Link"),
32            ProbeType::DapLink => write!(f, "DAPLink"),
33            ProbeType::StLink => write!(f, "ST-Link"),
34            ProbeType::Blackmagic => write!(f, "Black Magic Probe"),
35            ProbeType::Ftdi => write!(f, "FTDI"),
36            ProbeType::Unknown => write!(f, "Unknown"),
37        }
38    }
39}