Skip to content

Commit 00317ce

Browse files
committed
Merge branch 'master' into release/0.3
2 parents 8e2daef + eac466e commit 00317ce

File tree

11 files changed

+185
-263
lines changed

11 files changed

+185
-263
lines changed

.github/workflows/rustfmt.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ jobs:
1616
components: rustfmt
1717
- run: cargo fmt --all -- --check
1818
- run: cargo clippy --all-features
19+
- run: cargo clippy --features defmt
20+
- run: cargo clippy --features control-buffer-256
21+
- run: cargo clippy

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2121
### Breaking
2222
* Acess numeric form of `EndpointType` variants now require a `.to_bm_attributes()`. ([#60](https://github.com/rust-embedded-community/usb-device/pull/60))
2323
* `DescriptorWriter::iad()` now requires a `Option<StringIndex>` to optionally specify a string for describing the function ([#121](https://github.com/rust-embedded-community/usb-device/pull/121))
24-
* `.manufacturer()`, `.product()` and `.serial_number()` of `UsbDeviceBuilder` now require `&[&str]` to specify strings match with each LANGIDs supported by device. ([#122](https://github.com/rust-embedded-community/usb-device/pull/122))
24+
* `.manufacturer()`, `.product()` and `.serial_number()` of `UsbDeviceBuilder` are now replaced with the `strings()` function that accepts a `StringDescriptor` list to allow multilanguage support ([#122](https://github.com/rust-embedded-community/usb-device/pull/122))
25+
* Various methods of the `UsbDeviceBuilder` now return `Result<>` types instead of internally panicking.
2526

2627
### Changed
2728
* `EndpointType` enum now has fields for isochronous synchronization and usage ([#60](https://github.com/rust-embedded-community/usb-device/pull/60)).

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ repository = "https://github.com/mvirkkunen/usb-device"
1313
defmt = { version = "0.3", optional = true }
1414
portable-atomic = { version = "1.2.0", default-features = false }
1515
num_enum = { version = "0.6.1", default-features = false }
16+
heapless = "0.7"
1617

1718
[dev-dependencies]
1819
rusb = "0.9.1"

src/control_pipe.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ impl<B: UsbBus> ControlPipe<'_, B> {
154154
| ControlState::DataInLast
155155
| ControlState::DataInZlp
156156
| ControlState::StatusOut => {
157-
self.ep_out.read(&mut []).ok();
157+
let _ = self.ep_out.read(&mut []);
158158
self.state = ControlState::Idle;
159159
}
160160
_ => {
161161
// Discard the packet
162-
self.ep_out.read(&mut []).ok();
162+
let _ = self.ep_out.read(&mut []);
163163

164164
// Unexpected OUT packet
165165
self.set_error()
@@ -235,7 +235,7 @@ impl<B: UsbBus> ControlPipe<'_, B> {
235235
_ => return Err(UsbError::InvalidState),
236236
};
237237

238-
self.ep_in.write(&[]).ok();
238+
let _ = self.ep_in.write(&[]);
239239
self.state = ControlState::StatusIn;
240240
Ok(())
241241
}

src/descriptor.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,29 @@ impl DescriptorWriter<'_> {
116116
config.product_id as u8,
117117
(config.product_id >> 8) as u8, // idProduct
118118
config.device_release as u8,
119-
(config.device_release >> 8) as u8, // bcdDevice
120-
config.manufacturer.map_or(0, |_| 1), // iManufacturer
121-
config.product.map_or(0, |_| 2), // iProduct
122-
config.serial_number.map_or(0, |_| 3), // iSerialNumber
123-
1, // bNumConfigurations
119+
(config.device_release >> 8) as u8, // bcdDevice
120+
config.string_descriptors.first().map_or(0, |lang| {
121+
if lang.manufacturer.is_some() {
122+
1
123+
} else {
124+
0
125+
}
126+
}),
127+
config.string_descriptors.first().map_or(0, |lang| {
128+
if lang.product.is_some() {
129+
2
130+
} else {
131+
0
132+
}
133+
}),
134+
config.string_descriptors.first().map_or(0, |lang| {
135+
if lang.serial.is_some() {
136+
3
137+
} else {
138+
0
139+
}
140+
}),
141+
1, // bNumConfigurations
124142
],
125143
)
126144
}

src/descriptor/lang_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl From<LangID> for u16 {
1515
}
1616

1717
#[allow(missing_docs)]
18-
#[derive(Clone, Copy, PartialEq, TryFromPrimitive)]
18+
#[derive(Clone, Copy, PartialEq, Debug, TryFromPrimitive)]
1919
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
2020
#[repr(u16)]
2121
pub enum LangID {
@@ -349,7 +349,7 @@ pub enum LangID {
349349
MN_MONG_MN = 0x0C50,
350350
DZ_BT = 0x0C51,
351351
TMZ_MA = 0x0C5F,
352-
QUZ_PE = 0x0C6b,
352+
QUZ_PE = 0x0C6B,
353353
LOCALE_CUSTOM_UNSPECIFIED = 0x1000,
354354
AR_LY = 0x1001,
355355
ZH_SG = 0x1004,

0 commit comments

Comments
 (0)