Skip to content

Commit

Permalink
enhance: add device serial number
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Nov 4, 2023
1 parent df24cbe commit 806701b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct ChipInfo {
#[derive(Debug)]
pub struct WchLink {
pub(crate) device_handle: DeviceHandle<rusb::Context>,
pub serial_number: String,
pub chip: Option<ChipInfo>,
pub probe: Option<ProbeInfo>,
pub(crate) speed: crate::commands::Speed,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 806701b

Please sign in to comment.