hackPyrateBus
is a Python library that provides high-level functions to interact with specific integrated circuits using the Bus Pirate.
This library takes into account the particularities of the integrated circuits it interacts with.
This project is built on top of pyBusPirateLite, and we would like to give credit to the original authors and contributors of pyBusPirateLite and pyBusPirate.
NOTE: the pyBusPirateLite dependency is vendored from https://github.com/julianvilas/pyBusPirateLite/tree/new for convenience, as the original project does not seem to be maintained and it is not available in PyPI neither.
The new
branch in that fork contains commits not available in the original upstream, while master
matches exactly the upstream (as of today).
How to use the module directly.
From PyPI:
virtualenv venv
source venv/bin/activate
pip install hackPyrateBus
From the root of the cloned repo you can install hackPyrateBus
running:
# from the root of the cloned repo
virtualenv venv
source venv/bin/activate
pip install .
Directly From GitHub Releases:
# from anywhere
virtualenv venv
source venv/bin/activate
# latest release
url=$(curl --silent "https://api.github.com/repos/julianvilas/hackPyrateBus/releases/latest" | jq -r .assets[0].browser_download_url)
pip install --upgrade $url
Device particularities:
- 16,384/32,768 bytes capacity (
AT24C128
/AT24C256
respectively) organized as 256/512 64-bytes pages - Device address range [
0x50
:0x54
] (default0x50
), plus a LSB R/W bit (0 write, 1 read) - Page write mode rolls over when more than 64 bytes are written
- Sequential read with data address auto-increment
- Reading from a concrete data address requires a previous dummy-write
from hackPyrateBus.AT24CXXX import AT24CXXX
at24c = AT24CXXX()
at24c.speed = '50kHz'
at24c.configure(power=True, pullup=True) # do not enable pullup when using external pullup resistors
Default values:
- Auto-detect and auto-connect to Bus Pirate port
- 115200 bps serial communication speed with Bus Pirate
- 1s timeout to ensure full EEPROM can be read/written in a single call
256
model0x50
device address
at24c.load(0x0000, 15)
- Performs dummy-write + sequential read using Bus Pirate Write then read I2C method
- Auto-handles reads of more than 4096 bytes (Bus Pirate buffer size)
at24c.store(100, b'\x00Hello, world!\xff')
- Performs page write using Bus Pirate Write then read I2C method
- Auto-handles writes of more than 64 bytes (page size) to avoid roll-over
at24c.hw_reset()
As previously mentioned pyBusPirateLite
is vendored in this repo. To directly use that module, just import vendor.pyBusPirateLite
.
Usage example:
from vendor.pyBusPirateLite.I2C import I2C
This project uses the following open source packages:
- pyBusPirateLite (GPLv3)
hackPyrateBus
is licensed under the GNU General Public License v3 (GPLv3). The full text of the license can be found in the LICENSE file.
The pyBusPirateLite project, from which this project is derived, is also licensed under the GPLv3. We would like to thank the authors and contributors of pyBusPirateLite for their work.