diff options
author | Xo Wang <xow@google.com> | 2016-12-02 10:26:15 -0800 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2016-12-05 20:29:13 +0000 |
commit | 5d4a54e8949995f3e49366f575fcb47f119beb52 (patch) | |
tree | efa141f813b79ba91f100c884f12e101d50236a1 /pytools | |
parent | 12a26d27e75d4cb96291f9fa4bea44cf7900bf58 (diff) | |
download | talos-skeleton-5d4a54e8949995f3e49366f575fcb47f119beb52.tar.gz talos-skeleton-5d4a54e8949995f3e49366f575fcb47f119beb52.zip |
pytools/gpioutil: Don't set direction if already set
Writing "out" to GPIO direction will actually clear the output value.
This makes it impossible to read the value of outputs with gpioutil
since it always sets value to 0 before reading it.
Fix: don't write direction if the direction already matches that
requested.
Change-Id: I2116e6c7f5800239dd89c4f47fe7fd087b3a87cd
Signed-off-by: Xo Wang <xow@google.com>
Diffstat (limited to 'pytools')
-rw-r--r-- | pytools/gpioutil | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pytools/gpioutil b/pytools/gpioutil index 0654cd9..5ed13e2 100644 --- a/pytools/gpioutil +++ b/pytools/gpioutil @@ -59,10 +59,11 @@ class Gpio: self.write(self.getPath('edge'),self.interrupt) else: raise Exception("ERROR - Invalid Direction: "+dir) - - - self.write(self.getPath('direction'),self.direction) - + + current_direction = self.read(self.getPath('direction')) + if current_direction != self.direction: + self.write(self.getPath('direction'),self.direction) + def setValue(self,value): if (value == '0'): self.write(self.getPath('value'),'0') |