Skip to content

Commit

Permalink
Polling of analogue or digital pins now causes an exception
Browse files Browse the repository at this point in the history
Some users just don't read the README, do some polling instead
of using callbacks and then fire off an issue
(#16).

To prevent wasting my time the library now does a hard
exception if somebody tries polling. This then recommends
pyfirmata1.
  • Loading branch information
berndporr committed Apr 18, 2024
1 parent 952fdd3 commit a43ee10
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions examples/scan.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import serial
import serial.tools.list_ports

print("Serial devices available:")
l = serial.tools.list_ports.comports()
for ll in l:
print(ll.device, ll.description)
#!/usr/bin/python

import serial
import serial.tools.list_ports

print("Serial devices available:")
l = serial.tools.list_ports.comports()
for ll in l:
print(ll.device, ll.description)
2 changes: 1 addition & 1 deletion pyfirmata2/pyfirmata2.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def read(self):
if self.mode == UNAVAILABLE:
raise IOError("Cannot read pin {0}".format(self.__str__()))
if (self.mode is INPUT) or (self.mode is INPUT_PULLUP) or (self.type == ANALOG):
warnings.warn("Use a callback handler for pin {0}".format(self.__str__()))
raise IOError("Reading via polling is not supported by this library. Please use the original pyfirmata.")
return self.value

def register_callback(self, _callback):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='pyFirmata2',
version='2.4.6',
version='2.5.0',
description="Use your Arduino as a data acquisition card under Python",
long_description=long_description,
author='Bernd Porr',
Expand Down

0 comments on commit a43ee10

Please sign in to comment.