Skip to content
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

firmata: addition of support for firmata protocol #20

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

imle
Copy link

@imle imle commented Oct 12, 2021

I wanted to open this early as it is a significant change and I would really like some input before I get much deeper into this implementation. There are parts of this missing and I have not implemented some of the features yet. This is a work in progress.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@imle
Copy link
Author

imle commented Oct 12, 2021

@googlebot I signed it!

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@@ -20,6 +20,9 @@ import (
"periph.io/x/conn/v3/spi"
)

// I2CAddr i2c default address.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make a separate PR for this and the file below? They are unrelated to firmata.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't mean for that to make it in, will move to another PR.

@maruel
Copy link
Member

maruel commented Oct 13, 2021

Apologies for the delay. Thanks I'll try to look at it ASAP.

Copy link
Member

@maruel maruel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! That's a lot of functionality, that's really cool.

@@ -0,0 +1,43 @@
package firmata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For every files: please add copyright.

"fmt"
)

type AnalogMappingResponse struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For every public symbols: Please document or make private.

}

func ParseAnalogMappingResponse(data []byte) AnalogMappingResponse {
var response = AnalogMappingResponse{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For most var uses in this PR: var is unnecessary.


func ParseAnalogMappingResponse(data []byte) AnalogMappingResponse {
var response = AnalogMappingResponse{
AnalogPinToDigital: []uint8{},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary.

return response
}

func (a AnalogMappingResponse) String() string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend a pointer receiver otherwise it makes a copy.

sysExListenerChannels map[SysExCmd]chan []byte

i2cListeners map[uint8]chan I2CPacket
i2cMU sync.Mutex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the mutex above what it protects, not below.

Close() error
}

type Client struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you either export the interface or the struct but not both? I generally prefer the struct unless there's a clear reason like to make a fake/mock easier to use in practice.

go func() {
err := c.responseWatcher()
if err != nil {
panic(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this not be a panic?

@@ -0,0 +1,114 @@
package firmata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name this file "conv.go", it's more meaningful than util.go.

@@ -96,7 +96,7 @@ func (p *pin) Read() gpio.Level {
}

func (p *pin) WaitForEdge(timeout time.Duration) bool {
return false
return gpio.INVALID.WaitForEdge(timeout)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that intended?

@maruel
Copy link
Member

maruel commented Nov 14, 2021

What I would recommend is to start with only one subsystem, let's say i2c, and go from there. The PR is fairly large and will make the back and forth more difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants