Library for the Dangerous Prototypes Bus Pirate.
- Linux
- Python 3.5 and up
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Library for the Dangerous Prototypes Bus Pirate
Home Page: http://dangerousprototypes.com/docs/Bus_Pirate
License: GNU General Public License v2.0
Library for the Dangerous Prototypes Bus Pirate.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Sorry for filling an issue to ask a question, but I'm not sure if there is another way on Github. What is the difference between this pyBusPirate and the pyBusPirateLite that is hosted on google code? Just asking before I dig too deep in either. I'm trying to port a pyEEPROM tool from using Total Phase Aardvark to BusPirate and am hoping to save time with trial/error.
Something looks funny at the end of the following method (which is not working for me with Bus Pirate v3.5b FW v5.10):
def BBmode(self):
self.resetBP()
for i in range(20):
self.port.write("\x00")
self.timeout(0.1)
self.port.flushInput();
self.reset()
if self.response(5) == "BBIO1": return 1
else: return 0
Because of how the last two lines are indented, the for loop code will run only one time. But even if the indentation is wrong and the response is only meant to be checked at the end, the loop code still looks funny because it's not checking for a response.
Looking at an old copy of the "Lite" version as reference, I made this change to my local copy and it seems to work:
def BBmode(self):
self.resetBP()
self.port.flushInput()
for i in range(20):
self.port.write("\x00")
r,w,e = select.select([self.port], [], [], 0.1);
if( r): break
if self.response(5) == "BBIO1": return 1
else: return 0
But this is just a hack on my part. It would be nice if someone who knows could take a look at the original code.
(Hmm. The display of this issue does not preserve the indentation...)
I'm not terribly familiar with Python, I imagine maybe some of this is due to me running an older version. Might be nice so others using systems like mine can use it since its such a trivial patch. System: CentOS 5.4, Python 2.4.3. Its getting somewhat mangled by formatting here, let me know if you'd like to e-mail or something.
From d6d7ad8952bca26de31e588cbf7596501d39b288 Mon Sep 17 00:00:00 2001
From: John McMaster <[email protected]>
Date: Sat, 13 Mar 2010 18:44:38 -0500
Subject: [PATCH] Python compatibility
---
pyBusPirate/BinaryMode/I2C.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/pyBusPirate/BinaryMode/I2C.py b/pyBusPirate/BinaryMode/I2C.py
index cc75a66..49d0764 100644
--- a/pyBusPirate/BinaryMode/I2C.py
+++ b/pyBusPirate/BinaryMode/I2C.py
@@ -20,11 +20,11 @@ You should have received a copy of the GNU General Public License
along with pyBusPirate. If not, see <http://www.gnu.org/licenses/>.
"""
-from .BitBang import BBIO
+from BitBang import BBIO
class I2CSpeed:
- _50KHZ = 0b000
- _5KHZ = 0b001
+ _50KHZ = 0x00
+ _5KHZ = 0x01
class I2CPins:
POWER = 0x8
--
1.5.2.1
In class I2CSpeed, the first two lines are using four space characters and the last two lines are using tab characters. While fixing the file is the most important issue, my preference would be to use the four space characters throughout pyBusPirate.
test.py and spi_test_binmode.py both have dependencies for pyBusPirateLite
The problem comes from the select() used in timeout function. From python doc it is said that select with 3 empty fd list does not work on windows.
This leads me to another stuff, why bothering with this timeout management since pyserial does already manages timeout ? Is there a limitation that I am not aware off ?
If no I can branch and propose a modification implementing pyserial timeout usage.
I'm trying to use pyBusPirate on macOS with Python installed from Homebrew. Tested Python versions 3.6 and 3.7 on macOS 10.13 and 10.14 so far, always with the same result. When I try to initialise any mode, it fails with the error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/pete/Documents/Develop/93c46/pybuspirate/lib/python3.7/site-packages/pyBusPirate-2.0.0.0-py3.7.egg/buspirate/base.py", line 84, in __init__
TypeError: __init__() got multiple values for argument 'self'
The following steps can be used to reproduce the issue
macallan:93c46 pete$ virtualenv pybuspirate
Using base prefix '/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/pete/Documents/Develop/93c46/pybuspirate/bin/python3.7
Also creating executable in /Users/pete/Documents/Develop/93c46/pybuspirate/bin/python
Installing setuptools, pip, wheel...
done.
macallan:93c46 pete$ . pybuspirate/bin/activate
(pybuspirate) macallan:93c46 pete$ pip install sphinx
Collecting sphinx
Using cached https://files.pythonhosted.org/packages/0e/5c/e7d076cf2900b38cba5c7d48545953540d86634d391b702067c00d99cb01/Sphinx-1.8.3-py2.py3-none-any.whl
[...]
Installing collected packages: MarkupSafe, Jinja2, Pygments, pyparsing, six, packaging, idna, urllib3, certifi, chardet, requests, alabaster, sphinxcontrib-websupport, docutils, imagesize, pytz, babel, snowballstemmer, sphinx
Successfully installed Jinja2-2.10 MarkupSafe-1.1.0 Pygments-2.3.1 alabaster-0.7.12 babel-2.6.0 certifi-2018.11.29 chardet-3.0.4 docutils-0.14 idna-2.8 imagesize-1.1.0 packaging-18.0 pyparsing-2.3.0 pytz-2018.9 requests-2.21.0 six-1.12.0 snowballstemmer-1.2.1 sphinx-1.8.3 sphinxcontrib-websupport-1.1.0 urllib3-1.24.1
(pybuspirate) macallan:pyBusPirate-master pete$ python setup.py build
running build
running build_py
running egg_info
writing src/pyBusPirate.egg-info/PKG-INFO
writing dependency_links to src/pyBusPirate.egg-info/dependency_links.txt
writing requirements to src/pyBusPirate.egg-info/requires.txt
writing top-level names to src/pyBusPirate.egg-info/top_level.txt
reading manifest file 'src/pyBusPirate.egg-info/SOURCES.txt'
writing manifest file 'src/pyBusPirate.egg-info/SOURCES.txt'
(pybuspirate) macallan:pyBusPirate-master pete$ python setup.py test
running test
Searching for pyserial
Best match: pyserial 3.4
Processing pyserial-3.4-py3.7.egg
(pybuspirate) macallan:pyBusPirate-master pete$ python setup.py test
running test
Searching for pyserial
Best match: pyserial 3.4
Processing pyserial-3.4-py3.7.egg
Using /Users/pete/Downloads/pyBusPirate-master/.eggs/pyserial-3.4-py3.7.egg
running egg_info
writing src/pyBusPirate.egg-info/PKG-INFO
writing dependency_links to src/pyBusPirate.egg-info/dependency_links.txt
writing requirements to src/pyBusPirate.egg-info/requires.txt
writing top-level names to src/pyBusPirate.egg-info/top_level.txt
reading manifest file 'src/pyBusPirate.egg-info/SOURCES.txt'
writing manifest file 'src/pyBusPirate.egg-info/SOURCES.txt'
running build_ext
test__write_then_read (tests.test_buspirate_base.BusPirateTest) ... ok
test__write_then_read_fail (tests.test_buspirate_base.BusPirateTest) ... ok
test_bulk_write (tests.test_buspirate_base.BusPirateTest) ... ok
test_bulk_write_count_is_too_big (tests.test_buspirate_base.BusPirateTest) ... ok
test_bulk_write_count_is_too_small (tests.test_buspirate_base.BusPirateTest) ... ok
test_bulk_write_data_is_none (tests.test_buspirate_base.BusPirateTest) ... ok
test_bulk_write_fail (tests.test_buspirate_base.BusPirateTest) ... ok
test_configure_peripherials (tests.test_buspirate_base.BusPirateTest) ... ok
test_configure_pins (tests.test_buspirate_base.BusPirateTest) ... ok
test_enter (tests.test_buspirate_base.BusPirateTest) ... ok
test_mode (tests.test_buspirate_base.BusPirateTest) ... ok
test_reset (tests.test_buspirate_base.BusPirateTest) ... ok
test_set_pins (tests.test_buspirate_base.BusPirateTest) ... ok
test_bridge_mode (tests.test_buspirate_uart.BusPirateUartTest) ... ok
test_echo_rx (tests.test_buspirate_uart.BusPirateUartTest) ... ok
test_enter (tests.test_buspirate_uart.BusPirateUartTest) ... ok
test_manual_baudrate (tests.test_buspirate_uart.BusPirateUartTest) ... ok
test_mode (tests.test_buspirate_uart.BusPirateUartTest) ... ok
test_uart_bulk_write (tests.test_buspirate_uart.BusPirateUartTest) ... ok
test_uart_configuration (tests.test_buspirate_uart.BusPirateUartTest) ... ok
test_uart_speed (tests.test_buspirate_uart.BusPirateUartTest) ... ok
test_ack_bit (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_enter (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_exit (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_extend_aux (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_i2c_bulk_write (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_i2c_speed (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_mode (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_nack_bit (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_pullup_voltage_select (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_read_byte (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_sniff (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_start_bit (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_stop_bit (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_write_then_read (tests.test_buspirate_i2c.BusPirateI2CTest) ... ok
test_measure (tests.test_buspirate_utilities.BusPirateFrequencyTest) ... ok
test_clear (tests.test_buspirate_utilities.BusPiratePWMTest) ... ok
test_disable (tests.test_buspirate_utilities.BusPiratePWMTest) ... ok
test_setup (tests.test_buspirate_utilities.BusPiratePWMTest) ... ok
test_exit (tests.test_buspirate_utilities.BusPirateSelfTestsTest) ... ok
test_long_test (tests.test_buspirate_utilities.BusPirateSelfTestsTest) ... ok
test_short_test (tests.test_buspirate_utilities.BusPirateSelfTestsTest) ... ok
test_continuous (tests.test_buspirate_utilities.BusPirateVoltageTest) ... ok
test_take_once (tests.test_buspirate_utilities.BusPirateVoltageTest) ... ok
test_bulk_bits (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_bulk_bits_nine_bits (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_bulk_bits_zero_bits (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_bulk_bits_zero_bytes (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_bulk_clock_ticks (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_bulk_clock_ticks_zero (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_clock_high (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_clock_low (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_clock_tick (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_cs_high (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_cs_low (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_data_high (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_data_low (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_enter (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_exit (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_mode (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_peek (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_pic_read (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_pic_write (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_pullup_voltage_select (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_rawwire_bulk_write (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_rawwire_config (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_rawwire_speed (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_read_bit (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_read_byte (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_start_bit (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_stop_bit (tests.test_buspirate_rawwire.BusPirateRawWireTest) ... ok
test_chip_select_high (tests.test_buspirate_spi.BusPirateSpiTest) ... ok
test_chip_select_low (tests.test_buspirate_spi.BusPirateSpiTest) ... ok
test_enter (tests.test_buspirate_spi.BusPirateSpiTest) ... ok
test_sniff (tests.test_buspirate_spi.BusPirateSpiTest) ... ok
test_spi_configuration (tests.test_buspirate_spi.BusPirateSpiTest) ... ok
test_spi_speed (tests.test_buspirate_spi.BusPirateSpiTest) ... ok
test_write_then_read (tests.test_buspirate_spi.BusPirateSpiTest) ... ok
test_write_then_read_with_no_cs (tests.test_buspirate_spi.BusPirateSpiTest) ... ok
test_1wire_bulk_write (tests.test_buspirate_onewire.BusPirateOneWireTest) ... ok
test_alarm_search (tests.test_buspirate_onewire.BusPirateOneWireTest) ... ok
test_enter (tests.test_buspirate_onewire.BusPirateOneWireTest) ... ok
test_exit (tests.test_buspirate_onewire.BusPirateOneWireTest) ... ok
test_mode (tests.test_buspirate_onewire.BusPirateOneWireTest) ... ok
test_pullup_voltage_select (tests.test_buspirate_onewire.BusPirateOneWireTest) ... ok
test_read_byte (tests.test_buspirate_onewire.BusPirateOneWireTest) ... ok
test_rom_search (tests.test_buspirate_onewire.BusPirateOneWireTest) ... ok
----------------------------------------------------------------------
Ran 87 tests in 3.775s
OK
Apparently the test is successful.
(pybuspirate) macallan:pyBusPirate-master pete$ python setup.py install
running install
running bdist_egg
running egg_info
writing src/pyBusPirate.egg-info/PKG-INFO
writing dependency_links to src/pyBusPirate.egg-info/dependency_links.txt
writing requirements to src/pyBusPirate.egg-info/requires.txt
writing top-level names to src/pyBusPirate.egg-info/top_level.txt
reading manifest file 'src/pyBusPirate.egg-info/SOURCES.txt'
writing manifest file 'src/pyBusPirate.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.14-x86_64/egg
running install_lib
running build_py
creating build/bdist.macosx-10.14-x86_64/egg
creating build/bdist.macosx-10.14-x86_64/egg/buspirate
copying build/lib/buspirate/openocd.py -> build/bdist.macosx-10.14-x86_64/egg/buspirate
copying build/lib/buspirate/onewire.py -> build/bdist.macosx-10.14-x86_64/egg/buspirate
copying build/lib/buspirate/i2c.py -> build/bdist.macosx-10.14-x86_64/egg/buspirate
copying build/lib/buspirate/rawwire.py -> build/bdist.macosx-10.14-x86_64/egg/buspirate
copying build/lib/buspirate/__init__.py -> build/bdist.macosx-10.14-x86_64/egg/buspirate
copying build/lib/buspirate/__version__.py -> build/bdist.macosx-10.14-x86_64/egg/buspirate
copying build/lib/buspirate/uart.py -> build/bdist.macosx-10.14-x86_64/egg/buspirate
copying build/lib/buspirate/utilities.py -> build/bdist.macosx-10.14-x86_64/egg/buspirate
copying build/lib/buspirate/spi.py -> build/bdist.macosx-10.14-x86_64/egg/buspirate
copying build/lib/buspirate/base.py -> build/bdist.macosx-10.14-x86_64/egg/buspirate
byte-compiling build/bdist.macosx-10.14-x86_64/egg/buspirate/openocd.py to openocd.cpython-37.pyc
byte-compiling build/bdist.macosx-10.14-x86_64/egg/buspirate/onewire.py to onewire.cpython-37.pyc
byte-compiling build/bdist.macosx-10.14-x86_64/egg/buspirate/i2c.py to i2c.cpython-37.pyc
byte-compiling build/bdist.macosx-10.14-x86_64/egg/buspirate/rawwire.py to rawwire.cpython-37.pyc
byte-compiling build/bdist.macosx-10.14-x86_64/egg/buspirate/__init__.py to __init__.cpython-37.pyc
byte-compiling build/bdist.macosx-10.14-x86_64/egg/buspirate/__version__.py to __version__.cpython-37.pyc
byte-compiling build/bdist.macosx-10.14-x86_64/egg/buspirate/uart.py to uart.cpython-37.pyc
byte-compiling build/bdist.macosx-10.14-x86_64/egg/buspirate/utilities.py to utilities.cpython-37.pyc
byte-compiling build/bdist.macosx-10.14-x86_64/egg/buspirate/spi.py to spi.cpython-37.pyc
byte-compiling build/bdist.macosx-10.14-x86_64/egg/buspirate/base.py to base.cpython-37.pyc
creating build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
copying src/pyBusPirate.egg-info/PKG-INFO -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
copying src/pyBusPirate.egg-info/SOURCES.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
copying src/pyBusPirate.egg-info/dependency_links.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
copying src/pyBusPirate.egg-info/requires.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
copying src/pyBusPirate.egg-info/top_level.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/pyBusPirate-2.0.0.0-py3.7.egg' and adding 'build/bdist.macosx-10.14-x86_64/egg' to it
removing 'build/bdist.macosx-10.14-x86_64/egg' (and everything under it)
Processing pyBusPirate-2.0.0.0-py3.7.egg
Copying pyBusPirate-2.0.0.0-py3.7.egg to /Users/pete/Documents/Develop/93c46/pybuspirate/lib/python3.7/site-packages
Adding pyBusPirate 2.0.0.0 to easy-install.pth file
Installed /Users/pete/Documents/Develop/93c46/pybuspirate/lib/python3.7/site-packages/pyBusPirate-2.0.0.0-py3.7.egg
Processing dependencies for pyBusPirate==2.0.0.0
Searching for pyserial
Reading https://pypi.org/simple/pyserial/
Downloading https://files.pythonhosted.org/packages/0d/e4/2a744dd9e3be04a0c0907414e2a01a7c88bb3915cbe3c8cc06e209f59c30/pyserial-3.4-py2.py3-none-any.whl#sha256=e0770fadba80c31013896c7e6ef703f72e7834965954a78e71a3049488d4d7d8
Best match: pyserial 3.4
Processing pyserial-3.4-py2.py3-none-any.whl
Installing pyserial-3.4-py2.py3-none-any.whl to /Users/pete/Documents/Develop/93c46/pybuspirate/lib/python3.7/site-packages
Adding pyserial 3.4 to easy-install.pth file
Installing miniterm.py script to /Users/pete/Documents/Develop/93c46/pybuspirate/bin
Installed /Users/pete/Documents/Develop/93c46/pybuspirate/lib/python3.7/site-packages/pyserial-3.4-py3.7.egg
Finished processing dependencies for pyBusPirate==2.0.0.0
(pybuspirate) macallan:93c46 pete$ python
Python 3.7.2 (default, Dec 27 2018, 07:35:06)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from buspirate.rawwire import RawWire
>>> rw=RawWire('/dev/tty.usbserial-A906HA2R', 115200)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/pete/Documents/Develop/93c46/pybuspirate/lib/python3.7/site-packages/pyBusPirate-2.0.0.0-py3.7.egg/buspirate/base.py", line 84, in __init__
TypeError: __init__() got multiple values for argument 'self'
>>>
Either I am doing something wrong, or there is a bug in the pyBusPirate module - unfortunately I can't tell since I couldn't find any definitely correct sample code.
Is it possible for this package to be uploaded to PyPI? It would make it slightly easier to be found and allow the package to be installed via pip
.
Similar to #13
i2c-test.py uses DOS EoL characters unlike all the other files.
It would be great to have a setup.py file for installation.
Hi,
I really would like to see python3 support. Any plans for that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.