Skip to main content

Python interface to the Voigts lab hex maze.

Project description

About

- Python Package Name: hex_maze_interface
- Description: Python interface to the Voigts lab hex maze.
- Version: 2.0.0
- Python Version: 3.11
- Release Date: 2025-05-12
- Creation Date: 2024-01-14
- License: BSD-3-Clause
- URL: https://github.com/janelia-python/hex_maze_interface_python
- Author: Peter Polidoro
- Email: peter@polidoro.io
- Copyright: 2025 Howard Hughes Medical Institute
- References:
  - https://github.com/janelia-kicad/prism-pcb
  - https://github.com/janelia-kicad/cluster-pcb
  - https://github.com/janelia-arduino/ClusterController
- Dependencies:
  - click
  - python3-nmap

Example Usage

Python

from hex_maze_interface import HexMazeInterface, MazeException
hmi = HexMazeInterface()
cluster_address = 10
hmi.check_communication(cluster_address)
hmi.beep(cluster_address, duration_ms=100)
hmi.power_on_all(cluster_address)
hmi.home_all(cluster_address)
actual_positions = hmi.read_all_actual_positions()
hmi.pause_all(cluster_address)
hmi.write_all_target_positions(cluster_address, (10, 20, 30, 40, 50, 60, 70))
hmi.resume_all(cluster_address)
actual_positions = hmi.read_all_actual_positions()
hmi.power_off_all(cluster_address)

Command Line

Help

maze --help
# Usage: maze [OPTIONS] COMMAND [ARGS]...

#   Command line interface to the Voigts lab hex maze.

Options:
  --help  Show this message and exit.

Commands:
  bad-cmd
  beep
  check
  discover
  home
  home-all
  led-off
  led-on
  led-on-then-off
  measure
  no-cmd
  pause
  pause-all
  power-off-all
  power-on-all
  reset
  resume
  resume-all
  write-all-target-positions
  write-target-position

Example

CLUSTER_ADDRESS=10
maze check $CLUSTER_ADDRESS
maze beep $CLUSTER_ADDRESS 100
maze power-on-all $CLUSTER_ADDRESS
maze home-all $CLUSTER_ADDRESS
maze read-all-actual-positions $CLUSTER_ADDRESS
maze pause-all $CLUSTER_ADDRESS
maze write-all-target-positions $CLUSTER_ADDRESS 10 20 30 40 50 60 70
maze resume-all $CLUSTER_ADDRESS
maze read-all-actual-positions $CLUSTER_ADDRESS
maze power-off-all $CLUSTER_ADDRESS

Installation

https://github.com/janelia-python/python_setup

GNU/Linux

Ethernet

C-x C-f /sudo::/etc/network/interfaces

auto eth1

iface eth1 inet static

    address 192.168.10.2

    netmask 255.255.255.0

    gateway 192.168.10.1

    dns-nameserver 8.8.8.8 8.8.4.4
nmap -sn 192.168.10.0/24
nmap -p 7777 192.168.10.3
nmap -sV -p 80,7777 192.168.10.0/24
sudo -E guix shell nmap
sudo -E guix shell wireshark -- wireshark
make guix-container

Serial

  1. Drivers

    GNU/Linux computers usually have all of the necessary drivers already installed, but users need the appropriate permissions to open the device and communicate with it.

    Udev is the GNU/Linux subsystem that detects when things are plugged into your computer.

    Udev may be used to detect when a device is plugged into the computer and automatically give permission to open that device.

    If you plug a sensor into your computer and attempt to open it and get an error such as: "FATAL: cannot open /dev/ttyACM0: Permission denied", then you need to install udev rules to give permission to open that device.

    Udev rules may be downloaded as a file and placed in the appropriate directory using these instructions:

    99-platformio-udev.rules

  2. Download rules into the correct directory

    curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/master/scripts/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules
    
  3. Restart udev management tool

    sudo service udev restart
    
  4. Ubuntu/Debian users may need to add own “username” to the “dialout” group

    sudo usermod -a -G dialout $USER
    sudo usermod -a -G plugdev $USER
    
  5. After setting up rules and groups

    You will need to log out and log back in again (or reboot) for the user group changes to take effect.

    After this file is installed, physically unplug and reconnect your board.

Python Code

The Python code in this library may be installed in any number of ways, chose one.

  1. pip

    python3 -m venv ~/venvs/hex_maze_interface
    source ~/venvs/hex_maze_interface/bin/activate
    pip install hex_maze_interface
    
  2. guix

    Setup guix-janelia channel:

    https://github.com/guix-janelia/guix-janelia

    guix install python-hex-maze-interface
    

Windows

Python Code

The Python code in this library may be installed in any number of ways, chose one.

  1. pip

    python3 -m venv C:\venvs\hex_maze_interface
    C:\venvs\hex_maze_interface\Scripts\activate
    pip install hex_maze_interface
    

Development

Clone Repository

git clone git@github.com:janelia-python/hex_maze_interface_python.git
cd hex_maze_interface_python

Guix

Install Guix

Install Guix

Edit metadata.org

make -f .metadata/Makefile metadata-edits

Tangle metadata.org

make -f .metadata/Makefile metadata

Develop Python package

make -f .metadata/Makefile guix-dev-container
exit

Test Python package using ipython shell

make -f .metadata/Makefile guix-dev-container-ipython
import hex_maze_interface
exit

Test Python package installation

make -f .metadata/Makefile guix-container
exit

Upload Python package to pypi

make -f .metadata/Makefile upload

Test direct device interaction using serial terminal

make -f .metadata/Makefile guix-dev-container-port-serial # PORT=/dev/ttyACM0
# make -f .metadata/Makefile PORT=/dev/ttyACM1 guix-dev-container-port-serial
? # help
[C-a][C-x] # to exit

Docker

Install Docker Engine

https://docs.docker.com/engine/

Develop Python package

make -f .metadata/Makefile docker-dev-container
exit

Test Python package using ipython shell

make -f .metadata/Makefile docker-dev-container-ipython
import hex_maze_interface
exit

Test Python package installation

make -f .metadata/Makefile docker-container
exit

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

hex_maze_interface-2.0.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hex_maze_interface-2.0.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file hex_maze_interface-2.0.0.tar.gz.

File metadata

  • Download URL: hex_maze_interface-2.0.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.11

File hashes

Hashes for hex_maze_interface-2.0.0.tar.gz
Algorithm Hash digest
SHA256 c90eee76fc16748bb4cd4d794c00023f99598319090218722300fa95e67fc54c
MD5 45ef3e9779ce130a4bc27119a7cea864
BLAKE2b-256 c0c3a3b7be7a92a4a292bdc946bb0bbddfbfb22abe72311b0282ccd1e0c3e42c

See more details on using hashes here.

File details

Details for the file hex_maze_interface-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hex_maze_interface-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f88fe4c047544543f8c880103e8fcdef9fba4a27d5c866762d7831fa50f122f
MD5 6a0b49491e442b28bbd004ef5e302fd7
BLAKE2b-256 8fe8e484f195a74bd62ca3292bcfd56e52c6a65bfe943302445d853c7782f8aa

See more details on using hashes here.

Supported by

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