Skip to main content

Write to the Basys3 ROM directly.

Project description

IIC2343

Write to the Basys3 ROM directly.

PyPI - Version Tests Coverage Linters

Installation

Install using pip!

$ pip install iic2343

Usage

To use the library, import the Basys3 object directly and use the begin, write and end methods!

from iic2343 import Basys3

instance = Basys3()

instance.begin(port_number=2)  # port_number is optional
instance.write(1, bytearray([0x00, 0x00, 0x10, 0x16, 0x01]))
instance.write(2, bytearray([0x00, 0x00, 0x00, 0x18, 0x03]))
instance.write(3, bytearray([0x00, 0x00, 0x20, 0x18, 0x03]))
instance.write(4, bytearray([0x00, 0x00, 0x00, 0x20, 0x00]))
instance.end()

Methods

Here, a Basys3 instance has 3 methods:

begin

The method receives an optional port_number parameter (in needs to be an int). If the parameter is not present and there is only one available serial port on your machine, the Basys3 instance will use that serial port. Otherwise, it will raise an exception. The method initializes a port to write to.

write

The method receives an address parameter (an int) and a word parameter (a bytearray). It then attempts to write the word on the specified address. If the Basys3 instance fails, it returns a 0. Otherwise, it returns an int.

end

The method receives no parameters, and simply closes the port initialized on the begin method.

Attributes

The Basys3 instance also has 1 attribute:

available_ports

This attribute has a list with all the available ports (the ports are ListPortInfo objects). You don't need to use this attribute, but it might come in handy if you want to generate a GUI for your users or something like that.

CLI

This module also includes a CLI! It is quite simple, but it might be useful to see ports on your machine. The CLI works as follows:

$ iic2343 --help
usage: iic2343 [-h] [-v] {ports} ...

Command line interface tool for iic2343.

positional arguments:
  {ports}        Action to be executed.

optional arguments:
  -h, --help     show this help message and exit
  -v, --version  show program's version number and exit

That was the --help flag. Use it when you're not sure how something works! To see a list of your available ports, run the following command on your terminal:

$ iic2343 ports
(0) ttyS0
      desc: ttyS0
(1) ttyUSB0
      desc: n/a
(2) ttyUSB1
      desc: CP2102 USB to UART Bridge Controller
3 ports found

You can also use the --verbose flag to get a bit more information about each port:

$ iic2343 ports --verbose
(0) /dev/ttyS0
      desc: ttyS0
      hwid: PNP0501
(1) /dev/ttyUSB0
      desc: n/a
      hwid: PNP0502
(2) /dev/ttyUSB1
      desc: CP2102 USB to UART Bridge Controller
      hwid: USB VID:PID=10C4:EA60 SER=0001 LOCATION=2-1.6
3 ports found

Developing

This library uses PyTest as the test suite runner, and PyLint, Flake8, Black, ISort and MyPy as linters. It also uses Poetry as the default package manager.

The library includes a Makefile that has every command you need to start developing. If you don't have it, install Poetry using:

make get-poetry

Then, create a virtualenv to use throughout the development process, using:

make build-env

Activate the virtualenv using:

. .venv/bin/activate

Deactivate it using:

deactivate

To add a new package, use Poetry:

poetry add <new-package>

To run the linters, you can use:

# The following commands auto-fix the code
make black!
make isort!

# The following commands just review the code
make black
make isort
make flake8
make mypy
make pylint

To run the tests, you can use:

make tests

Releasing

To make a new release of the library, git switch to the master branch and execute:

make bump! minor

The word minor can be replaced with patch or major, depending on the type of release. The bump! command will bump the versions of the library, create a new branch, add and commit the changes. Then, just merge that branch to master. Finally, execute a merge to the stable branch. Make sure to update the version before merging into stable, as PyPi will reject packages with duplicated versions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iic2343-0.2.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

iic2343-0.2.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file iic2343-0.2.0.tar.gz.

File metadata

  • Download URL: iic2343-0.2.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for iic2343-0.2.0.tar.gz
Algorithm Hash digest
SHA256 db8db77ed058e7a6ec59b1f0d482f95ba45e4f0a1a8893756a143e9e3e39adda
MD5 0befe98766b318205edfcfed914dcd0b
BLAKE2b-256 8e0b2b1ffcee496dd7353ac37a9468c21a1370bc386369455b2718e490d1d67b

See more details on using hashes here.

File details

Details for the file iic2343-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: iic2343-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for iic2343-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b6b5fb54a5ad1b76f703a56bbf3374312e273af968fcc878e555e685b793190
MD5 cc91421300a8ebfadc8dec9e49d1dfc9
BLAKE2b-256 855a06272b3676a1e23e14c48c148ee8c61400f9570cc51d43f03cde456e2411

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page