Skip to content

Commit 9d7041e

Browse files
Match port properties case insensitively in board list (#945)
This allows both uppercase and lowercase properties (e.g. vid and pid) from boards.txt and matches what the Java IDE does: https://github.com/arduino/Arduino/blob/5e30bec23/arduino-core/src/cc/arduino/packages/BoardPort.java#L185
1 parent 0bf48ae commit 9d7041e

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Diff for: arduino/cores/packagemanager/identify.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package packagemanager
1717

1818
import (
1919
"fmt"
20+
"strings"
2021

2122
"github.com/arduino/arduino-cli/arduino/cores"
2223
properties "github.com/arduino/go-properties-orderedmap"
@@ -34,7 +35,7 @@ func (pm *PackageManager) IdentifyBoard(idProps *properties.Map) []*cores.Board
3435
if !ok {
3536
return false, false
3637
}
37-
if v1 != v2 {
38+
if !strings.EqualFold(v1, v2) {
3839
return true, false
3940
}
4041
}

Diff for: arduino/cores/packagemanager/package_manager_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,7 @@ func TestIdentifyBoard(t *testing.T) {
316316
require.Equal(t, "[test:avr:c]", fmt.Sprintf("%v", identify("0x9999", "0x0004")))
317317
// https://github.com/arduino/arduino-cli/issues/456
318318
require.Equal(t, "[test:avr:d]", fmt.Sprintf("%v", identify("0x9999", "0x0005")))
319+
// Check mixed case
320+
require.Equal(t, "[test:avr:e]", fmt.Sprintf("%v", identify("0xAB00", "0xcd00")))
321+
require.Equal(t, "[test:avr:e]", fmt.Sprintf("%v", identify("0xab00", "0xCD00")))
319322
}

Diff for: arduino/cores/packagemanager/testdata/custom_hardware/test/avr/boards.txt

+4
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ c.pid.1=0x0004
1515
d.name=Board D
1616
d.vid.1=0x9999
1717
d.pid.1=0x0005
18+
19+
e.name=Board E
20+
e.vid.1=0xAB00
21+
e.pid.1=0xcd00

0 commit comments

Comments
 (0)