Skip to content

Improve comments #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arduino/commander.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

// Commander of arduino package allows to call
// the arduino-cli commands in a programmatic way
// the arduino-cli commands in a programmatic way.
type Commander interface {
BoardList() ([]*rpc.DetectedPort, error)
UploadBin(fqbn, bin, port string) error
Expand Down
2 changes: 1 addition & 1 deletion arduino/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/arduino/go-win32-utils"
)

// DataDir returns the Arduino default data directory (arduino15)
// DataDir returns the Arduino default data directory (arduino15).
func DataDir() (*paths.Path, error) {
userHomeDir, err := os.UserHomeDir()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion arduino/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type client struct {
// NewClient instantiates and returns a new grpc client that allows to
// programmatically call arduino-cli commands.
// It exploits the grpc interface of the arduino-cli.
// It returns: the client instance, a callback to close the client and an error
// It returns: the client instance, a callback to close the client and an error.
func NewClient() (arduino.Commander, func() error, error) {
// Establish a connection with the gRPC server, started with the command:
// arduino-cli daemon
Expand Down
2 changes: 1 addition & 1 deletion cli/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/spf13/cobra"
)

// NewCommand created a new `version` command
// NewCommand creates a new `version` command.
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "version",
Expand Down
2 changes: 1 addition & 1 deletion command/dashboard/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type CreateParams struct {
Template string // Path of the template file
}

// Create allows to create a new dashboard
// Create allows to create a new dashboard.
func Create(params *CreateParams) (*DashboardInfo, error) {
conf, err := config.Retrieve()
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions command/device/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
}
)

// board contains details of a physical arduino board
// board contains details of a physical arduino board.
type board struct {
fqbn string
serial string
Expand All @@ -48,7 +48,7 @@ type board struct {
}

// isCrypto checks if the board is a valid arduino board with a
// supported crypto-chip
// supported crypto-chip.
func (b *board) isCrypto() bool {
for _, f := range cryptoFQBN {
if b.fqbn == f {
Expand All @@ -58,7 +58,7 @@ func (b *board) isCrypto() bool {
return false
}

// isCrypto checks if the board is a valid LoRa arduino board
// isLora checks if the board is a valid LoRa arduino board.
func (b *board) isLora() bool {
for _, f := range loraFQBN {
if b.fqbn == f {
Expand Down Expand Up @@ -94,8 +94,8 @@ func boardFromPorts(ports []*rpc.DetectedPort, params *CreateParams) *board {
// - if the port parameter does not match the actual port address.
// - if the the detected port does not contain any board.
// It returns:
// true -> to skip the port
// false -> to keep the port
// true -> to skip the port.
// false -> to keep the port.
func portFilter(port *rpc.DetectedPort, params *CreateParams) bool {
if len(port.Boards) == 0 {
return true
Expand Down
2 changes: 1 addition & 1 deletion command/device/createlora.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
serialEUIBaudrate = 9600

// dev-eui is an IEEE EUI64 address, so it must have length of 8 bytes.
// It's retrieved as hexadecimal string, thus 16 chars are expected
// It's retrieved as hexadecimal string, thus 16 chars are expected.
deveuiLength = 16
)

Expand Down
4 changes: 2 additions & 2 deletions command/device/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func downloadProvisioningFile(fqbn string) (string, error) {
}

// provision is responsible for running the provisioning
// procedures for boards with crypto-chip
// procedures for boards with crypto-chip.
type provision struct {
arduino.Commander
iot.Client
Expand All @@ -73,7 +73,7 @@ type provision struct {
id string
}

// run provisioning procedure for boards with crypto-chip
// run provisioning procedure for boards with crypto-chip.
func (p provision) run() error {
bin, err := downloadProvisioningFile(p.board.fqbn)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion command/ota/massupload.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type MassUploadParams struct {
FQBN string
}

// Result of an ota upload on a device
// Result of an ota upload on a device.
type Result struct {
ID string
Err error
Expand Down
2 changes: 1 addition & 1 deletion command/tag/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type CreateTagsParams struct {
}

// CreateTags allows to create or overwrite tags
// on a resource of Arduino IoT Cloud
// on a resource of Arduino IoT Cloud.
func CreateTags(params *CreateTagsParams) error {
conf, err := config.Retrieve()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions command/tag/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package tag

import "fmt"

// TagsInfo transforms tags into user-readable strings
// An error is returned if a tag value is not a string
// TagsInfo transforms tags into user-readable strings.
// An error is returned if a tag value is not a string.
func TagsInfo(tags map[string]interface{}) ([]string, error) {
var str []string
for key, value := range tags {
Expand Down
2 changes: 1 addition & 1 deletion command/thing/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type CloneParams struct {
CloneID string // ID of thing to be cloned
}

// Clone allows to create a new thing from an already existing one
// Clone allows to create a new thing from an already existing one.
func Clone(params *CloneParams) (*ThingInfo, error) {
conf, err := config.Retrieve()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion command/thing/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type CreateParams struct {
Template string // Path of the template file
}

// Create allows to create a new thing
// Create allows to create a new thing.
func Create(params *CreateParams) (*ThingInfo, error) {
conf, err := config.Retrieve()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/binary/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
fwuploader "github.com/arduino/arduino-fwuploader/indexes/download"
)

// Download a binary file contained in the binary index
// Download a binary file contained in the binary index.
func Download(bin *IndexBin) ([]byte, error) {
b, err := download(bin.URL)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions internal/binary/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ import (
)

const (
// URL of cloud-team binary index
// URL of cloud-team binary index.
IndexGZURL = "https://cloud-downloads.arduino.cc/binaries/index.json.gz"
IndexSigURL = "https://cloud-downloads.arduino.cc/binaries/index.json.sig"
)

// Index contains details about all the binaries
// loaded in 'cloud-downloads'
// loaded in 'cloud-downloads'.
type Index struct {
Boards []IndexBoard `json:"boards"`
}

// IndexBoard describes all the binaries available for a specific board
// IndexBoard describes all the binaries available for a specific board.
type IndexBoard struct {
Fqbn string `json:"fqbn"`
Provision *IndexBin `json:"provision"`
}

// IndexBin contains the details needed to retrieve a binary file from the cloud
// IndexBin contains the details needed to retrieve a binary file from the cloud.
type IndexBin struct {
URL string `json:"url"`
Checksum string `json:"checksum"`
Expand Down Expand Up @@ -95,7 +95,7 @@ func LoadIndex() (*Index, error) {

// FindProvisionBin looks for the provisioning binary corresponding
// to the passed fqbn in the index.
// Returns nil if the binary is not found
// Returns nil if the binary is not found.
func (i *Index) FindProvisionBin(fqbn string) *IndexBin {
for _, b := range i.Boards {
if b.Fqbn == fqbn {
Expand Down
4 changes: 2 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

// Config contains all the configuration parameters
// known by arduino-cloud-cli
// known by arduino-cloud-cli.
type Config struct {
Client string `map-structure:"client"` // Client ID of the user
Secret string `map-structure:"secret"` // Secret ID of the user, unique for each Client ID
Expand Down Expand Up @@ -78,7 +78,7 @@ func searchConfigDir() (string, error) {
}

return "", fmt.Errorf(
"didn't find config file in the current directory, its parents or in %s.",
"didn't find config file in the current directory, its parents or in %s",
arduino15.String(),
)
}
2 changes: 1 addition & 1 deletion internal/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
Filename = "arduino-cloud"
)

// SetDefaults sets the default values for configuration keys
// SetDefaults sets the default values for configuration keys.
func SetDefaults(settings *viper.Viper) {
// Client ID
settings.SetDefault("client", "xxxxxxxxxxxxxx")
Expand Down
14 changes: 7 additions & 7 deletions internal/serial/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@
package serial

var (
// msgStart is the initial byte sequence of every packet
// msgStart is the initial byte sequence of every packet.
msgStart = [2]byte{0x55, 0xAA}
// msgEnd is the final byte sequence of every packet
// msgEnd is the final byte sequence of every packet.
msgEnd = [2]byte{0xAA, 0x55}
)

const (
// Position of payload field
// payloadField indicates the position of payload field.
payloadField = 5
// Position of payload length field
// payloadLenField indicates the position of payload length field.
payloadLenField = 3
// Length of payload length field
// payloadLenFieldLen indicatest the length of payload length field.
payloadLenFieldLen = 2
// Length of the signature field
// crcFieldLen indicates the length of the signature field.
crcFieldLen = 2
)

// MsgType indicates the type of the packet
// MsgType indicates the type of the packet.
type MsgType byte

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/serial/serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (s *Serial) receive() ([]byte, error) {
return payload, nil
}

// encode is internally used to create a valid provisioning packet
// encode is internally used to create a valid provisioning packet.
func encode(mType MsgType, msg []byte) []byte {
// Insert the preamble sequence followed by the message type
packet := append(msgStart[:], byte(mType))
Expand Down