Skip to content

Commit 2de9eca

Browse files
committed
Use new methods in go-properties-orderedmap to calculate subsets
1 parent 637c339 commit 2de9eca

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

arduino/cores/board.go

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -145,36 +145,9 @@ func (b *Board) GeneratePropertiesForConfiguration(config string) (*properties.M
145145
// containing the properties required to identify the board. The returned sets
146146
// must not be changed by the caller.
147147
func (b *Board) GetIdentificationProperties() []*properties.Map {
148-
if b.identificationProperties != nil {
149-
return b.identificationProperties
148+
if b.identificationProperties == nil {
149+
b.identificationProperties = b.Properties.ExtractSubIndexSets("upload_port")
150150
}
151-
b.identificationProperties = []*properties.Map{}
152-
153-
portIDPropsSet := b.Properties.SubTree("upload_port")
154-
if portIDPropsSet.Size() == 0 {
155-
return b.identificationProperties
156-
}
157-
158-
// First check the identification properties with sub index "upload_port.N.xxx"
159-
idx := 0
160-
haveIndexedProperties := false
161-
for {
162-
idProps := portIDPropsSet.SubTree(fmt.Sprintf("%d", idx))
163-
idx++
164-
if idProps.Size() > 0 {
165-
haveIndexedProperties = true
166-
b.identificationProperties = append(b.identificationProperties, idProps)
167-
} else if idx > 1 {
168-
// Always check sub-id 0 and 1 (https://github.com/arduino/arduino-cli/issues/456)
169-
break
170-
}
171-
}
172-
173-
// if there are no subindexed then check the whole "upload_port.xxx"
174-
if !haveIndexedProperties {
175-
b.identificationProperties = append(b.identificationProperties, portIDPropsSet)
176-
}
177-
178151
return b.identificationProperties
179152
}
180153

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.14
55
require (
66
github.com/arduino/board-discovery v0.0.0-20180823133458-1ba29327fb0c
77
github.com/arduino/go-paths-helper v1.6.0
8-
github.com/arduino/go-properties-orderedmap v1.3.0
8+
github.com/arduino/go-properties-orderedmap v1.5.0
99
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b
1010
github.com/arduino/go-win32-utils v0.0.0-20180330194947-ed041402e83b
1111
github.com/cmaglie/go.rice v1.0.3 // This one must be kept until https://github.com/GeertJohan/go.rice/pull/159 is merged

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ github.com/arduino/go-paths-helper v1.6.0 h1:S7/d7DqB9XlnvF9KrgSiGmo2oWKmYW6O/DT
2222
github.com/arduino/go-paths-helper v1.6.0/go.mod h1:V82BWgAAp4IbmlybxQdk9Bpkz8M4Qyx+RAFKaG9NuvU=
2323
github.com/arduino/go-properties-orderedmap v1.3.0 h1:4No/vQopB36e7WUIk6H6TxiSEJPiMrVOCZylYmua39o=
2424
github.com/arduino/go-properties-orderedmap v1.3.0/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
25+
github.com/arduino/go-properties-orderedmap v1.5.0 h1:istmr13qQN3nneuU3lsqlMvI6jqB3u8QUfVU1tX/t/8=
26+
github.com/arduino/go-properties-orderedmap v1.5.0/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
2527
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b h1:9hDi4F2st6dbLC3y4i02zFT5quS4X6iioWifGlVwfy4=
2628
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b/go.mod h1:uwGy5PpN4lqW97FiLnbcx+xx8jly5YuPMJWfVwwjJiQ=
2729
github.com/arduino/go-win32-utils v0.0.0-20180330194947-ed041402e83b h1:3PjgYG5gVPA7cipp7vIR2lF96KkEJIFBJ+ANnuv6J20=

0 commit comments

Comments
 (0)