Skip to content

Commit f7d48e2

Browse files
committed
add/fix some comments
1 parent 67a376e commit f7d48e2

File tree

8 files changed

+21
-10
lines changed

8 files changed

+21
-10
lines changed

cli/certificates/flash.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var (
4343
certificatePaths []string
4444
)
4545

46-
// NewCommand created a new `version` command
46+
// NewFlashCommand creates a new `flash` command
4747
func NewFlashCommand() *cobra.Command {
4848
command := &cobra.Command{
4949
Use: "flash",

cli/common/common.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func GetUploadToolDir(packageIndex *packageindex.Index, board *firmwareindex.Ind
7979
return uploadToolDir
8080
}
8181

82-
// flashSketch is the business logic that handles the flashing procedure,
82+
// FlashSketch is the business logic that handles the flashing procedure,
8383
// it returns using a buffer the out and the err of the programmer
8484
func FlashSketch(board *firmwareindex.IndexBoard, sketch string, uploadToolDir *paths.Path, address string) (programmerOut, programmerErr *bytes.Buffer, err error) {
8585
bootloaderPort, err := GetNewAddress(board, address)
@@ -113,7 +113,7 @@ func FlashSketch(board *firmwareindex.IndexBoard, sketch string, uploadToolDir *
113113
return programmerOut, programmerErr, err
114114
}
115115

116-
// getNewAddress is a function used to reset a board and put it in bootloader mode
116+
// GetNewAddress is a function used to reset a board and put it in bootloader mode
117117
// it could happen that the board is assigned to a different serial port, after the reset,
118118
// this fuction handles also this possibility
119119
func GetNewAddress(board *firmwareindex.IndexBoard, oldAddress string) (string, error) {

cli/firmware/flash.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var (
4444
retries uint8
4545
)
4646

47-
// NewCommand created a new `version` command
47+
// NewFlashCommand creates a new `flash` command
4848
func NewFlashCommand() *cobra.Command {
4949
command := &cobra.Command{
5050
Use: "flash",

cli/firmware/getversion.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
semver "go.bug.st/relaxed-semver"
3838
)
3939

40-
// NewCommand created a new `version` command
40+
// NewGetVersionCommand creates a new `get-version` command
4141
func NewGetVersionCommand() *cobra.Command {
4242

4343
command := &cobra.Command{

flasher/flasher.go

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type Flasher interface {
6262
sendCommand(data CommandData) error
6363
}
6464

65+
// OpenSerial opens a new serial connection with the specified portAddress
6566
func OpenSerial(portAddress string, baudRate int, readTimeout int) (serial.Port, error) {
6667

6768
port, err := serial.Open(portAddress, &serial.Mode{BaudRate: baudRate})
@@ -78,12 +79,14 @@ func OpenSerial(portAddress string, baudRate int, readTimeout int) (serial.Port,
7879
return port, nil
7980
}
8081

82+
// FlashResult contains the result of the flashing procedure
8183
type FlashResult struct {
8284
Programmer *ExecOutput `json:"programmer"`
8385
Flasher *ExecOutput `json:"flasher,omitempty"`
8486
Version string `json:"version,omitempty"`
8587
}
8688

89+
// ExecOutput contais the stdout and stderr output, they are used to store the output of the flashing and upload
8790
type ExecOutput struct {
8891
Stdout string `json:"stdout"`
8992
Stderr string `json:"stderr"`

indexes/download/download.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"go.bug.st/downloader/v2"
4444
)
4545

46+
// DownloadTool downloads and returns the path on the local filesystem of a tool
4647
func DownloadTool(toolRelease *cores.ToolRelease) (*paths.Path, error) {
4748
resource := toolRelease.GetCompatibleFlavour()
4849
installDir := globals.FwUploaderPath.Join(
@@ -73,6 +74,7 @@ func DownloadTool(toolRelease *cores.ToolRelease) (*paths.Path, error) {
7374
return installDir, nil
7475
}
7576

77+
// DownloadFirmware downloads and returns the path on the local filesystem of a firmware
7678
func DownloadFirmware(firmware *firmwareindex.IndexFirmware) (*paths.Path, error) {
7779
firmwarePath := globals.FwUploaderPath.Join(
7880
"firmwares",
@@ -105,6 +107,7 @@ func DownloadFirmware(firmware *firmwareindex.IndexFirmware) (*paths.Path, error
105107
return firmwarePath, nil
106108
}
107109

110+
// DownloadSketch downloads and returns the path on the local filesystem of a sketch
108111
func DownloadSketch(loader *firmwareindex.IndexSketch) (*paths.Path, error) {
109112
sketchPath := globals.FwUploaderPath.Join(
110113
"sketch",
@@ -151,7 +154,7 @@ func Download(d *downloader.Downloader) error {
151154
return nil
152155
}
153156

154-
// taken and adapted from https://github.com/arduino/arduino-cli/blob/59b6277a4d6731a1c1579d43aef6df2a46a771d5/arduino/resources/checksums.go
157+
// VerifyFileChecksum is taken and adapted from https://github.com/arduino/arduino-cli/blob/59b6277a4d6731a1c1579d43aef6df2a46a771d5/arduino/resources/checksums.go
155158
func VerifyFileChecksum(checksum string, filePath *paths.Path) error {
156159
if checksum == "" {
157160
return fmt.Errorf("missing checksum for: %s", filePath)
@@ -193,7 +196,7 @@ func VerifyFileChecksum(checksum string, filePath *paths.Path) error {
193196
return nil
194197
}
195198

196-
// taken and adapted from https://github.com/arduino/arduino-cli/blob/59b6277a4d6731a1c1579d43aef6df2a46a771d5/arduino/resources/checksums.go
199+
// VerifyFileSize is taken and adapted from https://github.com/arduino/arduino-cli/blob/59b6277a4d6731a1c1579d43aef6df2a46a771d5/arduino/resources/checksums.go
197200
func VerifyFileSize(size int64, filePath *paths.Path) error {
198201
info, err := filePath.Stat()
199202
if err != nil {
@@ -290,6 +293,7 @@ func verifyIndex(indexPath *paths.Path, URL *url.URL) error {
290293
return nil
291294
}
292295

296+
// verifyPackageIndex verify if the signature is valid for the provided package index
293297
func verifyPackageIndex(indexPath, signaturePath *paths.Path) (bool, error) {
294298
valid, _, err := security.VerifyArduinoDetachedSignature(indexPath, signaturePath)
295299
if err != nil {
@@ -302,6 +306,7 @@ func verifyPackageIndex(indexPath, signaturePath *paths.Path) (bool, error) {
302306
return valid, nil
303307
}
304308

309+
// verifyModuleFirmwareIndex verify if the signature is valid for the provided module firmware index
305310
func verifyModuleFirmwareIndex(indexPath, signaturePath *paths.Path) (bool, error) {
306311
keysBox, err := rice.FindBox("gpg_keys")
307312
if err != nil {

indexes/firmwareindex/firmwareindex.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type Index struct {
3636
IsTrusted bool
3737
}
3838

39-
// indexPackage represents a single entry from module_firmware_index.json file.
39+
// IndexBoard represents a single entry from module_firmware_index.json file.
4040
type IndexBoard struct {
4141
Fqbn string `json:"fqbn,required"`
4242
Firmwares []*IndexFirmware `json:"firmware,required"`
@@ -51,6 +51,7 @@ type IndexBoard struct {
5151
LatestFirmware *IndexFirmware `json:"-"`
5252
}
5353

54+
// IndexUploaderCommand represents the command-line to use for different OS
5455
type IndexUploaderCommand struct {
5556
Linux string `json:"linux,required"`
5657
Windows string `json:"windows"`
@@ -141,7 +142,7 @@ func (i *Index) GetBoard(fqbn string) *IndexBoard {
141142
return nil
142143
}
143144

144-
// GetLatestFirmware returns the specified IndexFirmware version for this board.
145+
// GetFirmware returns the specified IndexFirmware version for this board.
145146
// Returns nil if version is not found.
146147
func (b *IndexBoard) GetFirmware(version string) *IndexFirmware {
147148
v := semver.ParseRelaxed(version)
@@ -153,6 +154,7 @@ func (b *IndexBoard) GetFirmware(version string) *IndexFirmware {
153154
return nil
154155
}
155156

157+
// GetUploaderCommand returns the command to use for the upload
156158
func (b *IndexBoard) GetUploaderCommand() string {
157159
if runtime.GOOS == "windows" && b.UploaderCommand.Windows != "" {
158160
return b.UploaderCommand.Linux

version/version.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ var (
2626
versionString = ""
2727
commit = ""
2828
date = ""
29-
VersionInfo *info
29+
// VersionInfo contains info regarding the version
30+
VersionInfo *info
3031
)
3132

3233
type info struct {

0 commit comments

Comments
 (0)