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>
|
||||
Thordur Bjornsson <thorduri@secnorth.net>
|
||||
Vincent Serpoul <vincent@serpoul.com>
|
||||
Josef Filzmaier <josef.filzmaier@gmail.com>
|
||||
|
@@ -128,9 +128,14 @@ func (d *Device) Config(cfgNum int) (*Config, error) {
|
||||
dev: d,
|
||||
claimed: make(map[int]bool),
|
||||
}
|
||||
|
||||
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()
|
||||
defer d.mu.Unlock()
|
||||
d.claimed = cfg
|
||||
|
Reference in New Issue
Block a user