Skip to content

Instantly share code, notes, and snippets.

View cardil's full-sized avatar

Chris Suszynski cardil

View GitHub Profile
@cardil
cardil / Debugger_parity_analysis__zIBmPww2.md
Created August 10, 2026 14:41
OpenBallistics: Per-Session Debugging Summaries (8 sessions, + spent)

MERGED SESSION SUMMARY: OpenBallistics ↔ py-ballisticcalc Parity Debugging

APPROACHES TRIED

Debugger-Based RK4 Investigation (Multi-phase, Systematic)

  • Phase 1: Set MCP breakpoints at RK4 step boundaries (Python rk4.py:235, Kotlin TrajectorySolver.kt:321)
  • Extracted k1-k4 y-component values at steps 1-2 of zero-finding and main trajectory
  • Phase 2: Compared internal state variables: km, density_ratio, mach, speed of sound, cd, vRelMag, gravity, coriolis
  • Finding: All RK4 internal calculations match to 1e-13 floating-point precision; divergence is purely initial conditions
  • Phase 3: Tested altitude-dependent density path (step 88 where |y| > 30ft threshold kicks in)
@cardil
cardil / k1k4-comparison.md
Created August 10, 2026 14:41
OpenBallistics: Analysis Artifacts from Parity Debugging Sessions (WARNING: conclusions may be incorrect, see main report)

k1-k4 y-Component Comparison: Python vs Kotlin (RK4 Step 2)

Setup

  • Python: debug_py_step.py suspended at line 235 of rk4.py (velocity_vector += line), step 2 of calc.fire().
  • Kotlin: DebugOneStep.kt suspended at line 321 of TrajectorySolver.kt (return State( line), step 2 of computeTrajectory().

Both breakpoints capture all k1-k4 values AFTER they are computed but BEFORE the state update.

Conversion factor: 1/3.2808399 (= Kotlin's FPS_PER_MPS inverse)

@cardil
cardil / debug_py_step.py
Created August 10, 2026 14:41
OpenBallistics: MCP Debugger Infrastructure for Parity Debugging
#!/usr/bin/env python3
from py_ballisticcalc import (
Ammo, Angular, Atmo, Calculator, Distance, DragModel,
Pressure, Shot, TableG7, Temperature, Velocity, Weapon, Weight, Wind,
)
bc = 0.209
dm = DragModel(bc=bc, drag_table=TableG7,
weight=Weight.Grain(77.0),
diameter=Distance.Millimeter(5.56),
@cardil
cardil / bug4-outlet-toggle-test.py
Created April 4, 2026 12:21
APC Modbus OutletCommand_BF single-command test tool
#!/usr/bin/env python3
"""PR #3381 — Single-command outlet test.
Usage: python3 .ai/bug4-outlet-toggle-test.py <test> [port]
Tests:
og1.off.le SOG_0 (OG1) OFF, LE word order
og1.on.le SOG_0 (OG1) ON, LE word order
og1.off.be SOG_0 (OG1) OFF, BE word order
og1.on.be SOG_0 (OG1) ON, BE word order
@cardil
cardil / bug4-probe-test.py
Created March 27, 2026 14:40
APC Modbus word-order probe test - tests EchterAgo's CANCEL|ON|OFF detection method
#!/usr/bin/env python3
"""Test EchterAgo's probe idea: write CANCEL|OUTPUT_ON|OUTPUT_OFF to OutletCommand_BF.
On spec-compliant firmware: EMBXILVAL (invalid command combo detected)
On LE-buggy firmware: different error or no error (combo lands in reserved bits)
Must run with NUT driver stopped: systemctl stop nut-driver@apc
"""
import sys
@cardil
cardil / bug4-test-modbus-tcp.py
Created March 27, 2026 11:16
Bug 4 — Modbus/TCP word order test via APC NMC (NUT #2338)
#!/usr/bin/env python3
"""Test: Modbus/TCP word order via APC NMC.
Reads raw register values to verify read word order, then tests write
word order for OutletCommand (load.on) in both big-endian and little-endian.
Safe: load.on while already on is a NOOP.
Usage:
python3 bug4-test-modbus-tcp.py <NMC_HOST> [NMC_PORT]
@cardil
cardil / bug4-test-word-order.py
Created March 26, 2026 23:11
NUT apc_modbus word-order bug proof — confirms big-endian vs little-endian register write issue
#!/usr/bin/env python3
"""Bug 4 — Test: Confirm word-order bug in apc_modbus OutletCommand writes.
The NUT driver's _apc_modbus_from_uint64() stores 32-bit values in big-endian
word order: [MSW, LSW]. But APC UPS expects little-endian: [LSW, MSW].
For command value 0x0102 (load.on + MOG):
- NUT sends: [0x0000, 0x0102] → FAILS (value in wrong register)
- Correct: [0x0102, 0x0000] → WORKS (value in register 1538)
@cardil
cardil / bug4-test-source-bit.py
Last active March 27, 2026 01:19
NUT apc_modbus word-order bug proof — source bit hypothesis test (disproved)
#!/usr/bin/env python3
"""Bug 4 — Test: Does setting SOURCE_RJ45_PORT bit fix OutletCommand writes?
This script bypasses the NUT driver and sends a raw Modbus write to register
1538 (OutletCommand_BF) with the SOURCE_RJ45_PORT bit (bit 14) set.
Command: load.on targeting MOG (Main Outlet Group)
- Without source bit: 0x0102 = CMD_OUTPUT_ON | TARGET_MOG
- With source bit: 0x4102 = CMD_OUTPUT_ON | TARGET_MOG | SOURCE_RJ45_PORT
@cardil
cardil / mcp_settings.json
Created February 23, 2026 23:28
RooCode MCP settings by @cardil
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
@cardil
cardil / gh-review.py
Created January 23, 2026 12:14
Helper scripts to get GH review comments in LLM-friendly way
#!/usr/bin/env python
"""Fetch unresolved review comments from a GitHub PR.
Based on: https://stackoverflow.com/a/66072198/844449
Usage:
python scripts/gh-comments.py [PR_NUMBER]
python scripts/gh-comments.py 17
"""