Skip to content

Commit 5e12a12

Browse files
authored
strip optional Pname from load
1 parent 83cc362 commit 5e12a12

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

internal/stm32CubeMX/stm32CubeMX.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,22 @@ func WriteProjectFile(workDir string, params BridgeParamType) (string, error) {
389389
var text utils.TextBuilder
390390
if params.BoardName != "" && params.BoardVendor == "STMicroelectronics" {
391391
text.AddLine("loadboard", params.BoardName, "allmodes")
392-
} else {
393-
split := strings.Split(params.Device, "::")
394-
if len(split) >= 1 {
395-
text.AddLine("load", split[len(split)-1])
392+
} else
393+
// extract Dname from [vendor]::Dname:[Pname]
394+
parts := strings.SplitN(params.Device, "::",2)
395+
396+
var DnamePname string
397+
if len(parts) == 2 {
398+
DnamePname = parts[1]
399+
} else {
400+
DnamePname = params.Device
401+
}
402+
403+
parts := strings.SplitN(DnamePname, ":", 2)
404+
if len(parts) >= 1 {
405+
text.AddLine("load", parts[0]
396406
} else {
397-
text.AddLine("load", params.Device)
407+
text.AddLine("load", DnamePname)
398408
}
399409
}
400410
text.AddLine("project name", "STM32CubeMX")

0 commit comments

Comments
 (0)