From 806701b1bb7b553ebc820de2474d9a6bd0a00feb Mon Sep 17 00:00:00 2001 From: Andelf Date: Sat, 4 Nov 2023 20:01:45 +0800 Subject: [PATCH] enhance: add device serial number --- CHANGELOG.md | 1 + src/device.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2806e08..27008f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add a progress bar when flashing - New chip: CH641, a RV32EC chip almost the same as CH32V003 - SDI print support, #34 +- Add serial number field to probe ### Fixed diff --git a/src/device.rs b/src/device.rs index facd16e..3ec7b8f 100644 --- a/src/device.rs +++ b/src/device.rs @@ -36,6 +36,7 @@ pub struct ChipInfo { #[derive(Debug)] pub struct WchLink { pub(crate) device_handle: DeviceHandle, + pub serial_number: String, pub chip: Option, pub probe: Option, pub(crate) speed: crate::commands::Speed, @@ -104,8 +105,13 @@ impl WchLink { )); } + let desc = device.device_descriptor()?; + let serial_number = device_handle.read_serial_number_string_ascii(&desc)?; + log::debug!("Serial number: {:?}", serial_number); + Ok(Self { device_handle, + serial_number, chip: None, probe: None, speed: Default::default(), @@ -140,6 +146,8 @@ pub fn try_switch_from_rv_to_dap(nth: usize) -> Result<()> { let mut dev = WchLink { device_handle: dev, + // fake info + serial_number: "".to_string(), chip: None, probe: None, speed: Default::default(),