Something went wrong. Try again.
PTAGIS Tooling & Pi Imaging
Something went wrong. Try again.
Files
- Python 69%
- Rust 31%
README.md
PTAGIS M5 Builder #
Build, test, and deploy Raspberry Pi environments for PTAGIS M5 fish monitoring.
The M5 Monitor Service runs on Raspberry Pis at field sites along the Columbia River Basin, reading PIT tag detections from Biomark IS1001 interrogation systems and reporting them to PTAGIS.
This tool produces a fully configured Pi — networking, SSH, firewall, serial permissions, time sync, and M5 — from a single .env file.
Quick Start #
# Install
brew install uv podman # macOS (Linux: apt install podman, then install uv)
podman machine init && podman machine start
git clone <repo-url> && cd ptagis
uv sync
# Configure
uv run ptagis init # Interactive — asks hostname, IP, gateway
# Build + run dev container (includes PIT tag emulator)
uv run ptagis build
uv run ptagis run
# Validate
uv run ptagis test
# Build production SD card image (no emulator)
uv run ptagis image
What Gets Configured #
Every Pi image (and dev container) includes:
| Component | Details |
|---|---|
| M5 Monitor Service | Installed, enabled, port 5440 (SignalR for M5 Control Panel) |
| Static IP | NetworkManager connection with your configured address |
| SSH | Key-only auth, password disabled, ptagis user |
| Firewall | iptables — only ports 22 (SSH) and 5440 (M5) open |
| Serial access | udev rules for FTDI/Prolific/CP210x USB-serial adapters |
| Time sync | systemd-timesyncd enabled (accurate tag timestamps) |
| Watchdog | Hardware watchdog for automatic recovery from hangs |
| Log rotation | 14-day retention with compression |
| Auto-updates | unattended-upgrades for security patches |
| Headless | GPU memory minimized (16MB), no desktop |
Commands #
| Command | Purpose |
|---|---|
ptagis init |
Interactive setup wizard — creates .env |
ptagis build |
Build arm64 dev container |
ptagis run |
Start the container (M5 + emulator) |
ptagis test |
Validate the running container |
ptagis shell |
Open bash inside the container |
ptagis logs |
Stream M5 service logs from the container |
ptagis scan |
Activate emulator and show PIT tag detections |
ptagis status |
Show container and service status |
ptagis image |
Build flashable SD card image (~3 min) |
ptagis doctor |
Check system prerequisites |
ptagis config show |
Display current configuration |
ptagis config edit |
Interactive config editor (TUI) |
Dev Container vs Production Image #
Dev Container (build/run) |
Production Image (image) |
|
|---|---|---|
| PIT tag emulator | Included | Not included |
| Serial hardware | Virtual PTY (/dev/ttyEMU0) |
Real USB-serial |
| Build time | 2-5 min | 2-5 min |
| Output | Running container | .img.xz file |
Configuration #
All settings live in .env (created by ptagis init or copied from .env.example):
PI_HOSTNAME=rpi-m5-site1
PI_STATIC_IP=192.168.1.24/24
PI_GATEWAY=192.168.1.1
PI_DNS=8.8.8.8
PI_INTERFACE=eth0
M5_VERSION=2.2.9
M5_SOURCE=https://example.com/m5_2.2.9_arm64.deb
SSH_PUBKEY_PATH=~/.ssh/id_ed25519.pub
PI_TIMEZONE=America/Los_Angeles
INSTALL_EMULATOR=true
See docs/README.md for the full configuration reference.
Multiple Sites #
cp .env .env.site2 # Different hostname/IP per site
ptagis build --env .env.site2
Deployment #
# Flash the image
xz -dc output/ptagis-m5.img.xz | sudo dd of=/dev/sdX bs=4M status=progress
# Or use Raspberry Pi Imager → "Use custom"
Insert SD card, connect Biomark IS1001 via USB-serial, plug in Ethernet, power on. M5 starts automatically.
Project Structure #
ptagis/
├── src/ptagis_builder/ # CLI + build logic (Python)
├── emulator/ # PIT tag transceiver emulator (Rust)
├── templates/ # Jinja2 templates (Dockerfile, NetworkManager, compose)
├── config/ # Static configs (SSH, udev, firewall, systemd)
├── packages/ # M5 .deb files (local installs)
├── tests/ # Python test suite
├── docs/ # Full documentation
├── output/ # Built SD card images (generated, gitignored)
└── .cache/ # Downloaded base images (gitignored)
Documentation #
- Getting Started — Full walkthrough from zero to production
- Architecture — How PTAGIS, M5, transceivers, and the emulator relate
- Glossary — What is a PIT tag? What is M5? All terms explained
- Protocol — IS1001 serial protocol specification
- Tag Codes — PIT tag format (ISO 11784/11785)
- Emulator — PIT tag emulator configuration and usage
- CLI Reference — All commands, config options, troubleshooting