diff --git a/README.md b/README.md index a895127..ec5c058 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,60 @@ -# DCMotor -A pySimpleGUI for position, speed, and torque control of a DC motor via Arduino +# dc-motor -Hardware required -- 1 x [Arduino 2A H-Bridge Dual Channel DC Motor Driver Shield Module L298NH Than L298P](https://www.diymore.cc/products/replace-l298p-for-arduino-uno-r3-dual-channel-dc-motor-driver-shield-expansion-board-l298nh-module-driving-module-mega2560-one) +Technical note on a project whose source was never published: position, speed and torque control of a DC motor from a PySimpleGUI desktop application, through an Arduino with an L298N dual H-bridge shield. + +## What it is + +Documentation only. The repository tracks `README.md`, `LICENSE` and `tests/run.sh`, and contains no application code on any branch or tag: no Python application, no Arduino sketch, no `.gitignore`. Its history is three commits — the initial README (2023-05-29), an edit to it the same day, and the licence commit of 2026-10-08. Nothing described here has been run against hardware, because there is nothing here to run. + +What the repository does record is the project's original one-line description and its hardware list, and that is the whole specification available: + +- **Interface**: a desktop GUI (PySimpleGUI), not a CLI. +- **Modes**: three — position, speed and torque. +- **Actuation**: an Arduino driving the motor through the L298N shield. +- **Link**: a serial connection between the host and the Arduino, implied by "via Arduino". + +### What is missing + +Everything that would make the project reproducible: + +- The Arduino firmware: the shield's pin mapping (PWM/enable and direction), the motor supply voltage, and whether the control loop ran on the Arduino or on the host. +- The host application: the window layout, the serial protocol and framing, the control period, and the units of each of the three modes. +- **The feedback source.** An L298N shield is an open-loop driver: position and speed control need an encoder or a potentiometer, and the original README mentions neither. Which one was used, and at what resolution, is not recorded anywhere in this repository. +- The controller — PID or otherwise — its gains, and where it ran. +- Dependency versions (`pysimplegui` and `pyserial` follow from the description but were never pinned). + +### If it is reconstructed + +Record those items before the code, not after: pin map, feedback device and counts per revolution, serial framing, control period, controller and gains. The three modes on a GUI are the easy part; the feedback path is the part that cannot be guessed from this repository. + +## Requirements + +The original README listed exactly one item: + +- 1× Arduino 2A H-Bridge Dual Channel DC Motor Driver Shield Module L298NH (two-channel, L298N-class), with a link to the vendor page. + +The Arduino board and the DC motor follow from the description but were never listed separately. Nothing is vendored here and there is no dependency manifest. + +## Install + +Nothing to install: there is no code, no build file and no dependency manifest. The repository is its own documentation. + +## Usage + +No code to run. The original README was the only usage record that ever existed, and its content is reproduced above; the application itself lived elsewhere and was never versioned here. + +## Tests + +Not applicable to code, because there is none. The one check that means anything here is `tests/run.sh` (`bash tests/run.sh`), which confirms that this README exists, that every internal reference in it resolves (markdown links and inline-code paths), that the tree carries no editor junk (`.DS_Store`, `Thumbs.db`, `*.swp`) and that no file has the shape of a secret. It is a hygiene check, not a behavioural test: there is no behaviour to test. Its negatives are proven by `bash tests/run.sh --self-test`, where a missing `LICENSE`, a missing cited image, an added `.DS_Store` and an added `.env` each make the run fail. + +## Structure + +``` +README.md this file +LICENSE MIT, Copyright (c) 2023 André Neto +tests/run.sh reference and hygiene checks for this repository +``` ## License -MIT — see [LICENSE](LICENSE). +MIT — Copyright (c) 2023 André Neto, the year of the first commit. See [LICENSE](LICENSE). No third-party code is redistributed here, so the whole repository is covered by that one licence. diff --git a/tests/run.sh b/tests/run.sh new file mode 100755 index 0000000..42e07e9 --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,190 @@ +#!/usr/bin/env bash +# tests/run.sh — checks for the dc-motor documentation repository. +# +# bash tests/run.sh check the checkout this script lives in +# bash tests/run.sh check another checkout +# bash tests/run.sh --self-test negative proofs: every check must fail when broken +# +# There is no code in this repository, so this is not a code test suite. It checks the +# documentation itself (the README is present and every internal reference in it resolves) +# and the hygiene of the tree (no editor junk, no file with the shape of a secret). +set -u + +checks() { + python3 - "$1" <<'PY' +import os, re, sys + +root = sys.argv[1] +failures = [] + + +def ok(msg): + print(" ok %s" % msg) + + +def bad(msg): + print(" FAIL %s" % msg) + failures.append(msg) + + +# ---- the tree, ignoring .git --------------------------------------------------------------- +tree = [] +for dirpath, dirnames, filenames in os.walk(root): + dirnames[:] = [d for d in dirnames if d != ".git"] + for name in filenames: + tree.append(os.path.relpath(os.path.join(dirpath, name), root)) +tree.sort() + +# ---- 1. the README exists and is not empty ------------------------------------------------- +readme = os.path.join(root, "README.md") +text = "" +if os.path.isfile(readme) and os.path.getsize(readme) > 0: + ok("README.md exists (%d bytes)" % os.path.getsize(readme)) + with open(readme, encoding="utf-8") as fh: + text = fh.read() +else: + bad("README.md is missing or empty") + +# ---- 2. every internal reference resolves -------------------------------------------------- +if text: + refs = set() + for target in re.findall(r"\]\(([^)\s]+)\)", text): + refs.add(target) # markdown links and images + body = re.sub(r"```.*?```", "", text, flags=re.S) # ignore fenced blocks + for span in re.findall(r"`([^`\n]+)`", body): + if re.match(r"^[A-Za-z0-9_][A-Za-z0-9_./-]*" + r"\.(md|sh|py|ino|png|jpg|jpeg|svg|pdf|txt|json|ya?ml|gitignore)$", span): + refs.add(span) # inline-code file paths + resolved, missing = 0, [] + for target in sorted(refs): + if target.startswith("#") or re.match(r"^[A-Za-z][A-Za-z0-9+.-]*:", target): + continue # anchor or absolute/external URL + path = target.split("#", 1)[0] + if not path: + continue + if os.path.isfile(os.path.join(root, path)): + resolved += 1 + else: + missing.append(target) + if missing: + bad("internal reference(s) without a file: %s" % ", ".join(missing)) + else: + ok("internal references resolve (%d file(s) cited)" % resolved) + +# ---- 3. no editor junk --------------------------------------------------------------------- +junk = [p for p in tree + if os.path.basename(p) in (".DS_Store", "Thumbs.db", ".AppleDouble") + or p.endswith((".swp", ".swo", "~"))] +if junk: + bad("editor junk present: %s" % ", ".join(junk)) +else: + ok("no editor junk (.DS_Store, Thumbs.db, *.swp, *~)") + +# ---- 4. nothing with the name or the content shape of a secret ------------------------------ +NAME = re.compile(r"(^|/)(\.env(\..*)?|id_rsa|id_ed25519" + r"|.*\.pem|.*\.key|secrets?\.[^/]*|.*credentials.*)$") +CONTENT = re.compile( + r"-----BEGIN [A-Z ]*PRIVATE KEY-----" + r"|AKIA[0-9A-Z]{16}" + r"|gh[pousr]_[A-Za-z0-9]{20,}" + r"|xox[baprs]-[A-Za-z0-9-]{10,}" + r"|(password|passwd|secret|token|api[_-]?key)\s*[:=]\s*" + r"[\"']?[A-Za-z0-9/+_-]{8,}", + re.IGNORECASE, +) +by_name = [p for p in tree if NAME.search(p)] +by_content = [] +for p in tree: + try: + with open(os.path.join(root, p), "rb") as fh: + blob = fh.read() + except OSError: + continue + if b"\0" in blob[:4096]: + continue + if CONTENT.search(blob.decode("utf-8", "replace")): + by_content.append(p) +if by_name or by_content: + if by_name: + bad("secret-shaped file name(s): %s" % ", ".join(by_name)) + if by_content: + bad("secret-shaped content in: %s" % ", ".join(by_content)) +else: + ok("no secret-shaped file name or content") + +# ---- summary ------------------------------------------------------------------------------- +if failures: + print(" %d check(s) failed" % len(failures)) + sys.exit(1) +print(" all checks passed") +sys.exit(0) +PY +} + +# ---- self-test: each check must fail when it is broken ------------------------------------- +self_test() { + tmp="$(mktemp -d)" + rc=0 + negatives=0 + + fixture() { # fixture -> a clean tree, echoing its path + d="$tmp/$1" + mkdir -p "$d" + printf '# fixture\n\nSee [LICENSE](LICENSE).\n' > "$d/README.md" + printf 'MIT\n' > "$d/LICENSE" + printf '%s\n' "$d" + } + + run() { # run