Skip to content

Commit 28a0021

Browse files
authored
strip optional Pname from load (#227)
* strip optional Pname from load
1 parent ea76cd3 commit 28a0021

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

internal/stm32CubeMX/stm32CubeMX.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,17 @@ func WriteProjectFile(workDir string, params BridgeParamType) (string, error) {
390390
if params.BoardName != "" && params.BoardVendor == "STMicroelectronics" {
391391
text.AddLine("loadboard", params.BoardName, "allmodes")
392392
} else {
393-
split := strings.Split(params.Device, "::")
394-
if len(split) >= 1 {
395-
text.AddLine("load", split[len(split)-1])
393+
// extract Dname from [vendor]::Dname:[Pname]
394+
parts := strings.SplitN(params.Device, "::", 2)
395+
var DnamePname string
396+
if len(parts) == 2 {
397+
DnamePname = parts[1]
396398
} else {
397-
text.AddLine("load", params.Device)
399+
DnamePname = params.Device
398400
}
401+
402+
parts = strings.SplitN(DnamePname, ":", 2)
403+
text.AddLine("load", parts[0])
399404
}
400405
text.AddLine("project name", "STM32CubeMX")
401406

0 commit comments

Comments
 (0)