-
Notifications
You must be signed in to change notification settings - Fork 234
[RDY] Topic/onewire #6
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8c15402
onewireport: add OneWirePIO
Emantor 1e8f59c
onewiredriver: add OneWirePIODriver and DigitalOutputProtocol
Emantor aaae8b4
powerdriver: add DigitalOutputPowerDriver
Emantor 3f67b1e
powerdriver: add subprocess support and rename binding
Emantor 1d5f3d8
onewire: switch from OWHttpd to python-onewire
Emantor 13aa34c
dev-requirements: add onewire
Emantor 8a619be
setup: add onewire
Emantor 18957f5
travis: add libow-dev dependency
Emantor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ pytest-isort | |
| pytest-mock | ||
| pytest-pylint | ||
| pytest-runner | ||
| onewire | ||
| pyudev | ||
| yapf | ||
| requests | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import logging | ||
| import onewire | ||
|
|
||
| import attr | ||
|
|
||
| from ..factory import target_factory | ||
| from ..resource import OneWirePIO | ||
| from ..protocol import DigitalOutputProtocol | ||
| from .common import Driver | ||
|
|
||
| @target_factory.reg_driver | ||
| @attr.s | ||
| class OneWirePIODriver(Driver, DigitalOutputProtocol): | ||
|
|
||
| bindings = {"port": OneWirePIO, } | ||
|
|
||
| def __attrs_post_init__(self): | ||
| super().__attrs_post_init__() | ||
| self.onewire = onewire.Onewire(self.port.host) | ||
|
|
||
| def set(self, status): | ||
| if status == True: | ||
| self.onewire.set(self.port.path, '1') | ||
| else: | ||
| self.onewire.set(self.port.path, '0') | ||
|
|
||
| def get(self): | ||
| status = self.onewire.get(self.port.path) | ||
| return status == '1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import abc | ||
|
|
||
|
|
||
| class DigitalOutputProtocol(abc.ABC): | ||
| """Abstract class providing the OneWireProtocol interface""" | ||
|
|
||
| @abc.abstractmethod | ||
| def get(self): | ||
| """Implementations should return the status of the OneWirePort.""" | ||
| raise NotImplementedError | ||
|
|
||
| @abc.abstractmethod | ||
| def set(self, status): | ||
| """Implementations should set the status of the OneWirePort""" | ||
| raise NotImplementedError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| from .base import SerialPort | ||
| from .serialport import RawSerialPort | ||
| from .networkservice import NetworkService | ||
| from .onewireport import OneWirePIO | ||
| from .power import NetworkPowerPort | ||
| from .udev import USBSerialPort | ||
| from .common import Resource, ResourceManager, ManagedResource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import attr | ||
|
|
||
| from ..factory import target_factory | ||
| from .common import Resource | ||
|
|
||
|
|
||
| @target_factory.reg_resource | ||
| @attr.s | ||
| class OneWirePIO(Resource): | ||
| """This resource describes a Onewire PIO Port. | ||
|
|
||
| Arguments: | ||
| host - The hostname of the owserver e.g. localhost:4304 | ||
| path - Path to the port on the owserver e.g. 29.7D6913000000/PIO.0""" | ||
| host = attr.ib(validator=attr.validators.instance_of(str)) | ||
| path = attr.ib(validator=attr.validators.instance_of(str)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| 'pytest', | ||
| 'pyyaml', | ||
| 'pyudev', | ||
| 'onewire', | ||
| 'requests', | ||
| ], | ||
| packages=[ | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add a docstring with example host/port values.