-
Notifications
You must be signed in to change notification settings - Fork 44
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
base: main
Are you sure you want to change the base?
Conversation
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 What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
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 What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Apologies for the delay. Thanks I'll try to look at it ASAP. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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{}, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that intended?
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. |
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.