Skip to content

Add the TopDist lamp and strobe HIL cases - #349

Merged
abhinavp5 merged 1 commit into
porting_HILfrom
05-topdist-lamp-and-strobe
Oct 25, 2026
Merged

abhinavp5 merged 1 commit into
porting_HILfrom
05-topdist-lamp-and-strobe

Conversation

@abhinavp5

Copy link
Copy Markdown
Contributor

Summary

TopDist/tests/test.py
  setUp: load the TopDist pin map, reset the Nucleo
  DashboardCommands 0x12C left_turn_signal -> LEFT_TURN_EN (PA1) flashes
  BpsError 0x3AA cell-communication fault -> BMS_STROBE_EN (PC2) flashes
  a pin name that is not on the sheet raises

The server discovers this file because TopDist is in hil_config.json.

Evidence

  • Before: TopDist had no suite. The server would flash it and find no tests.
    After: The module is the two lamp cases plus the unknown-pin case. Not run on the rack.

Merge Danger

Door: two-way

Revert deletes the suite.

Blast radius: tests

Only TopDist/tests/test.py. The compile job does not execute it.

Made with Cursor

A dashboard left-turn command must flash PA1, and a BPS fault must flash PC2.
Comment thread TopDist/tests/test.py
Comment on lines +21 to +35
def setUp(self):
import config
from gpioPins import reset_nucleo
config.read_in_nucleo_pinmaps("TopDist")
reset_nucleo()

def _bus(self):
from CANBus import CANBus, clear_receive_queue
bus = CANBus()
self.addCleanup(bus.close)
clear_receive_queue()
return bus

def test_dashboard_left_turn_flashes_pa1(self):
from CANMessage import CanMessage

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports are repeated inside setUp, _bus, and each test. MotorBoard/tests/test.py:7-10 imports gpioPins, CANMessage, etc. once at the top of the file. Do the same here, so a new member sees the module's dependencies in one place. If they must be lazy (for example, config has to run before gpioPins loads), add a one-line why comment.

Comment thread TopDist/tests/test.py
Comment on lines +5 to +18
def _edges(read, timeout: float) -> int:
previous = read()
count = 0
start = time.time()
while time.time() - start < timeout:
current = read()
if current != previous:
count += 1
previous = current
if count >= 2:
return count
time.sleep(0.05)
return count

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_edges is hard to read cold. Name the 2 (for example MIN_EDGES = 2) and say why two edges means "flashing". Name the 5 s timeout (hardcoded in both tests) and the 0.05 poll interval. timeout should be timeout_s, since the repo names units. Add a short why comment on the lamp period, since it is the reason 5 s is enough. MotorBoard/tests/test.py comments its sleeps, for example "Allow time for PowerBoard to read voltage...".

Comment thread TopDist/tests/test.py
Comment on lines +38 to +45
bus.sendMessage(CanMessage(
"DashboardCommands", 0x12C, {"left_turn_signal": 1}, time.time()))
lamp = DigitalInput("LEFT_TURN_EN")
self.assertGreaterEqual(_edges(lamp.read, 5), 2, "PA1 left turn did not flash")

def test_bps_fault_flashes_pc2(self):
from CANMessage import CanMessage
from gpioPins import DigitalInput

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues.

  1. config.read_in_nucleo_pinmaps, reset_nucleo, CANBus, clear_receive_queue and PinValidate are not defined anywhere else in this repo. MotorBoard/tests/test.py uses CANPi.writeOut and AnalogOutput("6"). Please confirm these names exist on the HIL server side. If they do not, every test fails with ImportError. The PR also says "Not run on the rack".
  2. DigitalInput is created after sendMessage. The first read() in _edges happens after the send, so any early edge is missed. Create the input before sending.

The same applies to the BPS test below.

@abhinavp5
abhinavp5 merged commit 872c2cc into porting_HIL Oct 25, 2026
2 checks passed
@abhinavp5
abhinavp5 deleted the 05-topdist-lamp-and-strobe branch October 25, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant