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

Spin out driver subclass #4

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

Conversation

zsyed91
Copy link
Member

@zsyed91 zsyed91 commented Mar 30, 2016

  • Create a Driver subclass
  • Added more tests to consider some edge cases and sad paths
  • Test coverage is 100%
  • Use FileWatcher instead of IO.select to prevent 100% cpu usage when waiting for value to change. Method now blocks until value is updated.

@zsyed91 zsyed91 changed the title [WIP] Spin out driver subclass Spin out driver subclass Apr 3, 2016

module PiPiper
self.driver= PiPiper::Sysfs
self.driver = PiPiper::Sysfs::Driver.new
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless you changed PiPiper's code #driver= need a subclass of Driver, not an instance.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes you are correct, forgot to remove the .new. I will fix this.

@elmatou
Copy link
Contributor

elmatou commented Apr 4, 2016

Hi @zsyed91,
My thoughts lies in the comments above.
I'm only concerned on your #wait_for_change implementation, maybe you can explained me what pushed you to this direction.

@zsyed91
Copy link
Member Author

zsyed91 commented Apr 4, 2016

@elmatou see my note in the code regarding FileWatcher. We can definitely discuss it further, it is a big change, after all.

@elmatou
Copy link
Contributor

elmatou commented Apr 11, 2016

Hi @zsyed91,
tell me when your are good to go with your PR.
I just succeed to use I2C with sysfs & bcm2835. This will be a nice addition. see you

@zsyed91
Copy link
Member Author

zsyed91 commented Apr 11, 2016

@elmatou Yeah I have been insanely busy this past week with some life stuff. I will push the suggestions soon. Glad you tested I2C with the code and that it works 😄

@elmatou
Copy link
Contributor

elmatou commented Apr 21, 2016

My bad, select was and should listen to value_file of course, edge_file is only for setup.

As far I understand, FileWatcher use modification time, I get through the code and only found this line referring to the file :
https://github.com/thomasfl/filewatcher/blob/master/lib/filewatcher.rb#L125

as for select(2) not blocking on read. We need to investigate more, the SO thread you mentioned was listening on the reading part of the file descriptor and not the error part hence the difference in behaviour.
looking forward to read you.

@zsyed91
Copy link
Member Author

zsyed91 commented Apr 22, 2016

Sure I can take a look again. I will have to look at the difference between checking errors vs just reading via select. If it helps, I can pull that logic out of this PR and open a separate one containing those changes.

@elmatou
Copy link
Contributor

elmatou commented Apr 22, 2016

I think it would be best to keep atomic/feature oriented PR. I will
continue to investigate on the matter.
On Apr 22, 2016 4:54 AM, "Zshawn Syed" [email protected] wrote:

Sure I can take a look again. I will have to look at the difference
between checking errors vs just reading via select. If it helps, I can pull
that logic out of this PR and open a separate one containing those changes.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#4 (comment)

@elmatou
Copy link
Contributor

elmatou commented May 3, 2016

Hi @zsyed91,
where are we on this since we last spoke ?
do you need a hand to spin out the drivers ?

@zsyed91
Copy link
Member Author

zsyed91 commented May 3, 2016

@elmatou Hey, sorry I just switched jobs and am currently moving cross-country so this slipped through the cracks. I just pushed the changes. I fixed the driver class and removed the pin_wait_for changes so that I can open it in a separate PR.

…ch. Removed commented out driver line and added a placeholder in the spec_helper until 3.0 PiPiper is released
@zsyed91 zsyed91 force-pushed the create_driver_class branch from 14b79a9 to c7b7a01 Compare May 3, 2016 15:58
@elmatou
Copy link
Contributor

elmatou commented May 4, 2016

Ok, thx you, I'm gonna do a full review of the PR, and it will be good to merge

@zsyed91
Copy link
Member Author

zsyed91 commented May 4, 2016

Awesome, let me know and then I will merge if everything is good to go 😄

module PiPiper
def self.driver=(driver)
# Placeholder for testing, PiPiper 3.0 contains this so we can remove
end
Copy link
Contributor

Choose a reason for hiding this comment

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

you are right, we should remove this.

Copy link
Member Author

Choose a reason for hiding this comment

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

right, once we release 3.0 officially I can open a new pr to remove this.

@elmatou
Copy link
Contributor

elmatou commented May 6, 2016

I just pointed to 2 methods not useful for now.
and maybe we could set the dependency to pi_piper 3.0 (if 3.0 is good for you.).

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

Successfully merging this pull request may close these issues.

2 participants