Whole file

alengwenus/pypck

The author described this change as Fix commands for rt600 and rt1200 (#117). It counts as a record because the checks below fail on the code as it stood at 30ee8b389 and pass on 5adc67058, with nothing else changed between the two runs.

Fix saved2024-08-15
Sharing licenceMIT · LICENSE
Change size+6 6

What the code was meant to do, written into the code itself as a save note

Fix commands for rt600 and rt1200 (#117)

The change

586586 if state == lcn_defs.MotorStateModifier.UP:
587587 if reverse_time in [None, lcn_defs.MotorReverseTime.RT70]:
588588 params = (0x01, 0xE4, 0x00)
589+ ret = f"X2{params[0]:03d}{params[1]:03d}{params[2]:03d}"
589590 elif reverse_time == lcn_defs.MotorReverseTime.RT600:
590- params = (0x04, 0xC8, 0x08)
591+ ret = PckGenerator.dim_output(0, 100, 8)
591592 elif reverse_time == lcn_defs.MotorReverseTime.RT1200:
592- params = (0x04, 0xC8, 0x0B)
593+ ret = PckGenerator.dim_output(0, 100, 11)
593594 else:
594595 raise ValueError("Wrong MotorReverseTime.")
595- ret = f"X2{params[0]:03d}{params[1]:03d}{params[2]:03d}"
596596
597597 elif state == lcn_defs.MotorStateModifier.DOWN:
598598 if reverse_time in [None, lcn_defs.MotorReverseTime.RT70]:
599599 params = (0x01, 0x00, 0xE4)
600+ ret = f"X2{params[0]:03d}{params[1]:03d}{params[2]:03d}"
600601 elif reverse_time == lcn_defs.MotorReverseTime.RT600:
601- params = (0x05, 0xC8, 0x08)
602+ ret = PckGenerator.dim_output(1, 100, 8)
602603 elif reverse_time == lcn_defs.MotorReverseTime.RT1200:
603- params = (0x05, 0xC8, 0x0B)
604+ ret = PckGenerator.dim_output(1, 100, 11)
604605 else:
605606 raise ValueError("Wrong MotorReverseTime.")
606- ret = f"X2{params[0]:03d}{params[1]:03d}{params[2]:03d}"
607607
608608 elif state == lcn_defs.MotorStateModifier.STOP:
609609 ret = "AY000000"

The check that tells the two apart

failpass·tests/test_commands.py::test_command_generation_single_mod_noack[A1DI100008-command179]
failpass·tests/test_commands.py::test_command_generation_single_mod_noack[A1DI100011-command180]
failpass·tests/test_commands.py::test_command_generation_single_mod_noack[A2DI100008-command182]
failpass·tests/test_commands.py::test_command_generation_single_mod_noack[A2DI100011-command183]

Check file tests/test_commands.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it30ee8b389d38379e27fb705b2f738f76f06186ee
Broken version dated2024-08-14
Modulepypck.pck_commands
Units changedPckGenerator
Fingerprinta1deddb1ec945c8f
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in alengwenus/pypck