Rewrite README to match what the repository holds, and add a documentation check

The repository has no code on any branch or tag, so both README drafts were wrong about what is here: the technical note predates the MIT LICENSE commit and described a single 358-byte file, and the archive notice had no licence section at all. This README keeps the original project description and hardware list, says plainly that there is no code to run, and its Licence section points at the MIT LICENSE (Copyright (c) 2023 André Neto, the year of the first commit, 2023-05-29).

tests/run.sh checks the only claims that can be checked here: the README exists, every internal reference in it resolves, the tree has no editor junk and no file has the name or content shape of a secret. --self-test proves each check fails when broken.
This commit is contained in:
Andre Neto
2026-10-08 17:25:24 +01:00
parent 3589952d95
commit d45f5e5023
2 changed files with 246 additions and 5 deletions
+56 -5
View File
@@ -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.
Executable
+190
View File
@@ -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 <dir> 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 <name> -> 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 <expected-rc> <label> <dir>
out="$(checks "$3" 2>&1)"
got=$?
if [ "$got" -eq "$1" ]; then
printf ' ok %s (rc=%s)\n' "$2" "$got"
if [ "$1" -ne 0 ]; then
negatives=$((negatives + 1))
fi
else
printf ' FAIL %s (rc=%s, expected %s)\n' "$2" "$got" "$1"
rc=1
fi
printf '%s\n' "$out" | sed 's/^/ /'
}
echo "self-test — every check must fail when the thing it guards is broken:"
d="$(fixture clean)"; run 0 "clean tree passes" "$d"
d="$(fixture no-readme)"; rm "$d/README.md"
run 1 "README removed -> fails" "$d"
d="$(fixture no-license)"; rm "$d/LICENSE"
run 1 "cited LICENSE missing -> fails" "$d"
d="$(fixture no-image)"; printf '# fixture\n\n![screenshot](shot.png)\n' > "$d/README.md"
run 1 "cited image missing -> fails" "$d"
d="$(fixture junk)"; touch "$d/.DS_Store"
run 1 "editor junk added -> fails" "$d"
d="$(fixture secret)"
# built at run time so that this script does not itself contain a secret-shaped literal
printf '%s = "%s"\n' "pass""word" "hunter2""hunter2" > "$d/.env"
run 1 "secret-shaped file added -> fails" "$d"
if [ "$rc" -eq 0 ]; then
echo "self-test passed: $negatives negative case(s) failed as expected"
else
echo "self-test FAILED"
fi
rm -rf "$tmp"
return "$rc"
}
if [ "${1:-}" = "--self-test" ]; then
self_test
exit $?
fi
root="$(cd "${1:-"$(dirname "${BASH_SOURCE[0]}")/.."}" && pwd)"
echo "checks for $root:"
checks "$root"
exit $?