Don't reset the configuration if desired config is already active (#6)
Fixes issue #5
This commit is contained in:

committed by
zagrodzki

parent
aa64bae804
commit
9fc0278283
1
AUTHORS
1
AUTHORS
@@ -11,3 +11,4 @@ Ivan Krasin <imkrasin@gmail.com>
|
|||||||
Jirawat I. <nodtem66@gmail.com>
|
Jirawat I. <nodtem66@gmail.com>
|
||||||
Thordur Bjornsson <thorduri@secnorth.net>
|
Thordur Bjornsson <thorduri@secnorth.net>
|
||||||
Vincent Serpoul <vincent@serpoul.com>
|
Vincent Serpoul <vincent@serpoul.com>
|
||||||
|
Josef Filzmaier <josef.filzmaier@gmail.com>
|
||||||
|
@@ -128,8 +128,13 @@ func (d *Device) Config(cfgNum int) (*Config, error) {
|
|||||||
dev: d,
|
dev: d,
|
||||||
claimed: make(map[int]bool),
|
claimed: make(map[int]bool),
|
||||||
}
|
}
|
||||||
if err := libusb.setConfig(d.handle, uint8(cfgNum)); err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to set active config %d for the device %s: %v", cfgNum, d, err)
|
if activeCfgNum, err := d.ActiveConfigNum(); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to query active config of the device %s: %v", d, err)
|
||||||
|
} else if cfgNum != activeCfgNum {
|
||||||
|
if err := libusb.setConfig(d.handle, uint8(cfgNum)); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to set active config %d for the device %s: %v", cfgNum, d, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
d.mu.Lock()
|
d.mu.Lock()
|
||||||
defer d.mu.Unlock()
|
defer d.mu.Unlock()
|
||||||
|
Reference in New Issue
Block a user