From 44ecfe173c3ce61f300c3fbdca901056fa76533f Mon Sep 17 00:00:00 2001 From: cobra18t Date: Mon, 23 May 2022 22:18:34 -0700 Subject: [PATCH 1/6] add solenoid kick pwm command --- mpf/platforms/opp/opp_rs232_intf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mpf/platforms/opp/opp_rs232_intf.py b/mpf/platforms/opp/opp_rs232_intf.py index 23ad6b9b5..fdfeadb6b 100644 --- a/mpf/platforms/opp/opp_rs232_intf.py +++ b/mpf/platforms/opp/opp_rs232_intf.py @@ -33,6 +33,7 @@ class OppRs232Intf: SET_SOL_INP_CMD = b'\x17' UPGRADE_OTHER_BRD = b'\x18' READ_MATRIX_INP = b'\x19' + CFG_SOL_KICK_PWM = b'\x1b' INV_CMD = b'\xf0' ILLEGAL_CMD = b'\xfe' From 68553685ff54d88c305a3f649e352f9631ff1b29 Mon Sep 17 00:00:00 2001 From: cobra18t Date: Mon, 23 May 2022 22:22:32 -0700 Subject: [PATCH 2/6] add pulse_power support to opp --- mpf/platforms/opp/opp_coil.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mpf/platforms/opp/opp_coil.py b/mpf/platforms/opp/opp_coil.py index ebd3d7136..ea36ef452 100644 --- a/mpf/platforms/opp/opp_coil.py +++ b/mpf/platforms/opp/opp_coil.py @@ -143,6 +143,13 @@ def reconfigure_driver(self, pulse_settings: PulseSettings, hold_settings: Optio # if config would not change do nothing if new_config_state == self._config_state: return + + if self.sol_card.platform.min_version[self.sol_card.chain_serial] >= 0x00020305: + if self._config_state is None: + self.reconfigure_pulse_pwm(pulse_settings) + else: + if self._config_state[0].power != pulse_settings.power: + self.reconfigure_pulse_pwm(pulse_settings) self._config_state = new_config_state @@ -204,6 +211,27 @@ def reconfigure_driver(self, pulse_settings: PulseSettings, hold_settings: Optio self.log.debug("Writing individual config: %s on %s", "".join(" 0x%02x" % b for b in final_cmd), self.sol_card.chain_serial) self.sol_card.platform.send_to_processor(self.sol_card.chain_serial, final_cmd) + + def reconfigure_pulse_pwm(self, pulse_settings: PulseSettings): + pwm_val = int((pulse_settings.power * 32) - 1) + if pwm_val < 0: + pwm_val = 0 + + _, _, solenoid = self.number.split('-') + + msg = bytearray() + msg.append(self.sol_card.addr) + msg.extend(OppRs232Intf.CFG_SOL_KICK_PWM) + msg.append(pwm_val) + msg.append(int(solenoid)) + msg.extend(OppRs232Intf.calc_crc8_whole_msg(msg)) + msg.extend(OppRs232Intf.EOM_CMD) + final_cmd = bytes(msg) + + if self.sol_card.platform.debug: + self.log.debug("Writing pulse power config: %s on %s", "".join(" 0x%02x" % b for b in final_cmd), + self.sol_card.chain_serial) + self.sol_card.platform.send_to_processor(self.sol_card.chain_serial, final_cmd) class OPPSolenoidCard: From 8073d371e66215ea8bac1ce42f0e0fa619c47887 Mon Sep 17 00:00:00 2001 From: cobra18t Date: Mon, 23 May 2022 22:49:35 -0700 Subject: [PATCH 3/6] update test for expected pulse power commands --- mpf/tests/test_OPP.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mpf/tests/test_OPP.py b/mpf/tests/test_OPP.py index 8809e58d4..f35cc30c8 100644 --- a/mpf/tests/test_OPP.py +++ b/mpf/tests/test_OPP.py @@ -21,6 +21,7 @@ 0x14: 7, 0x17: 5, 0x19: 11, + 0x1b: 5, } class MockOppSocket(MockSerial): @@ -335,11 +336,17 @@ def setUp(self): self._crc_message(b'\x21\x02\x00\x00\x00\x00'): self._crc_message(board2_version), self._crc_message(b'\x22\x02\x00\x00\x00\x00'): self._crc_message(board3_version), self._crc_message(b'\x23\x02\x00\x00\x00\x00'): self._crc_message(board4_version), # get version + self._crc_message(b'\x20\x1b\x1f\x00'): False, # configure pulse power coil 0 self._crc_message(b'\x20\x14\x00\x02\x17\x00'): False, # configure coil 0 + self._crc_message(b'\x20\x1b\x1f\x01'): False, # configure pulse power coil 1 self._crc_message(b'\x20\x14\x01\x04\x17\x00'): False, # configure coil 1 + self._crc_message(b'\x20\x1b\x1f\x02'): False, # configure pulse power coil 2 self._crc_message(b'\x20\x14\x02\x04\x0a\x00'): False, # configure coil 2 + self._crc_message(b'\x20\x1b\x1f\x03'): False, # configure pulse power coil 3 self._crc_message(b'\x20\x14\x03\x00\x0a\x06'): False, # configure coil 3 + self._crc_message(b'\x21\x1b\x1f\x0c'): False, # configure pulse power coil 1-12 self._crc_message(b'\x21\x14\x0c\x00\x0a\x01'): False, # configure coil 1-12 + self._crc_message(b'\x23\x1b\x1f\x00'): False, # configure pulse power coil 3-0 self._crc_message(b'\x23\x14\x00\x02\x2a\x00'): False, # configure coil 3-0 self._crc_message(b'\x20\x13\x07\x00\x00\x00\x00', False): False, # turn off all incands self._crc_message(b'\x22\x13\x07\x00\x00\x00\x00', False): False, # turn off all incands From c9ad32b278431ed155e1f563c34bd311ad411546 Mon Sep 17 00:00:00 2001 From: cobra18t Date: Tue, 24 May 2022 21:59:20 -0700 Subject: [PATCH 4/6] Correct pulse power version check to 2.3.0.5 --- mpf/platforms/opp/opp_coil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpf/platforms/opp/opp_coil.py b/mpf/platforms/opp/opp_coil.py index ea36ef452..d0feac918 100644 --- a/mpf/platforms/opp/opp_coil.py +++ b/mpf/platforms/opp/opp_coil.py @@ -144,7 +144,7 @@ def reconfigure_driver(self, pulse_settings: PulseSettings, hold_settings: Optio if new_config_state == self._config_state: return - if self.sol_card.platform.min_version[self.sol_card.chain_serial] >= 0x00020305: + if self.sol_card.platform.min_version[self.sol_card.chain_serial] >= 0x02030005: if self._config_state is None: self.reconfigure_pulse_pwm(pulse_settings) else: From 7f0a0053c0d7a8af07f62253e314093190abc952 Mon Sep 17 00:00:00 2001 From: cobra18t Date: Tue, 24 May 2022 22:14:36 -0700 Subject: [PATCH 5/6] update firmware version in test case --- mpf/tests/test_OPP.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mpf/tests/test_OPP.py b/mpf/tests/test_OPP.py index f35cc30c8..a548a4f76 100644 --- a/mpf/tests/test_OPP.py +++ b/mpf/tests/test_OPP.py @@ -317,10 +317,10 @@ def setUp(self): board2_config = b'\x21\x0d\x06\x02\x02\x01' # wing1: neo, wing2: inputs, wing3: inputs, wing4: solenoids board3_config = b'\x22\x0d\x03\x03\x03\x07' # wing1: lamps, wing2: lamps, wing3: lamps, wing4: hi-side lamps board4_config = b'\x23\x0d\x01\x01\x04\x05' # wing1: sol, wing2: sol, wing3: matrix_out, wing4: matrix_in - board1_version = b'\x20\x02\x02\x00\x00\x00' # 2.0.0.0 - board2_version = b'\x21\x02\x02\x00\x00\x00' # 2.0.0.0 - board3_version = b'\x22\x02\x02\x00\x00\x00' # 2.0.0.0 - board4_version = b'\x23\x02\x02\x00\x00\x00' # 2.0.0.0 + board1_version = b'\x20\x02\x02\x03\x00\x05' # 2.3.0.5 + board2_version = b'\x21\x02\x02\x03\x00\x05' # 2.3.0.5 + board3_version = b'\x22\x02\x02\x03\x00\x05' # 2.3.0.5 + board4_version = b'\x23\x02\x02\x03\x00\x05' # 2.3.0.5 inputs1_message = b"\x20\x08\x00\xff\x00\x0c" # inputs 0+1 off, 2+3 on, 8 on inputs2_message = b"\x21\x08\x00\x00\x00\x00" inputs3a_message = b"\x23\x08\x00\x00\x00\x00" @@ -364,7 +364,7 @@ def setUp(self): assert isinstance(self.machine.default_platform, OppHardwarePlatform) self._wait_for_processing() - self.assertEqual(0x02000000, self.machine.default_platform.min_version["com1"]) + self.assertEqual(0x02030005, self.machine.default_platform.min_version["com1"]) self.assertFalse(self.serialMock.expected_commands) self.maxDiff = 100000 @@ -372,10 +372,10 @@ def setUp(self): # test hardware scan info_str = """Connected CPUs: - Port: com1 at 115200 baud. Chain Serial: com1 - -> Board: 0x20 Firmware: 0x2000000 - -> Board: 0x21 Firmware: 0x2000000 - -> Board: 0x22 Firmware: 0x2000000 - -> Board: 0x23 Firmware: 0x2000000 + -> Board: 0x20 Firmware: 0x2030005 + -> Board: 0x21 Firmware: 0x2030005 + -> Board: 0x22 Firmware: 0x2030005 + -> Board: 0x23 Firmware: 0x2030005 Incand cards: - Chain: com1 Board: 0x20 Card: 0 Numbers: [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31] From 4f4da93f9be9d6e5a7b9106a240d9f663120afcf Mon Sep 17 00:00:00 2001 From: cobra18t Date: Tue, 24 May 2022 22:21:48 -0700 Subject: [PATCH 6/6] revert test case to original --- mpf/tests/test_OPP.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/mpf/tests/test_OPP.py b/mpf/tests/test_OPP.py index a548a4f76..8809e58d4 100644 --- a/mpf/tests/test_OPP.py +++ b/mpf/tests/test_OPP.py @@ -21,7 +21,6 @@ 0x14: 7, 0x17: 5, 0x19: 11, - 0x1b: 5, } class MockOppSocket(MockSerial): @@ -317,10 +316,10 @@ def setUp(self): board2_config = b'\x21\x0d\x06\x02\x02\x01' # wing1: neo, wing2: inputs, wing3: inputs, wing4: solenoids board3_config = b'\x22\x0d\x03\x03\x03\x07' # wing1: lamps, wing2: lamps, wing3: lamps, wing4: hi-side lamps board4_config = b'\x23\x0d\x01\x01\x04\x05' # wing1: sol, wing2: sol, wing3: matrix_out, wing4: matrix_in - board1_version = b'\x20\x02\x02\x03\x00\x05' # 2.3.0.5 - board2_version = b'\x21\x02\x02\x03\x00\x05' # 2.3.0.5 - board3_version = b'\x22\x02\x02\x03\x00\x05' # 2.3.0.5 - board4_version = b'\x23\x02\x02\x03\x00\x05' # 2.3.0.5 + board1_version = b'\x20\x02\x02\x00\x00\x00' # 2.0.0.0 + board2_version = b'\x21\x02\x02\x00\x00\x00' # 2.0.0.0 + board3_version = b'\x22\x02\x02\x00\x00\x00' # 2.0.0.0 + board4_version = b'\x23\x02\x02\x00\x00\x00' # 2.0.0.0 inputs1_message = b"\x20\x08\x00\xff\x00\x0c" # inputs 0+1 off, 2+3 on, 8 on inputs2_message = b"\x21\x08\x00\x00\x00\x00" inputs3a_message = b"\x23\x08\x00\x00\x00\x00" @@ -336,17 +335,11 @@ def setUp(self): self._crc_message(b'\x21\x02\x00\x00\x00\x00'): self._crc_message(board2_version), self._crc_message(b'\x22\x02\x00\x00\x00\x00'): self._crc_message(board3_version), self._crc_message(b'\x23\x02\x00\x00\x00\x00'): self._crc_message(board4_version), # get version - self._crc_message(b'\x20\x1b\x1f\x00'): False, # configure pulse power coil 0 self._crc_message(b'\x20\x14\x00\x02\x17\x00'): False, # configure coil 0 - self._crc_message(b'\x20\x1b\x1f\x01'): False, # configure pulse power coil 1 self._crc_message(b'\x20\x14\x01\x04\x17\x00'): False, # configure coil 1 - self._crc_message(b'\x20\x1b\x1f\x02'): False, # configure pulse power coil 2 self._crc_message(b'\x20\x14\x02\x04\x0a\x00'): False, # configure coil 2 - self._crc_message(b'\x20\x1b\x1f\x03'): False, # configure pulse power coil 3 self._crc_message(b'\x20\x14\x03\x00\x0a\x06'): False, # configure coil 3 - self._crc_message(b'\x21\x1b\x1f\x0c'): False, # configure pulse power coil 1-12 self._crc_message(b'\x21\x14\x0c\x00\x0a\x01'): False, # configure coil 1-12 - self._crc_message(b'\x23\x1b\x1f\x00'): False, # configure pulse power coil 3-0 self._crc_message(b'\x23\x14\x00\x02\x2a\x00'): False, # configure coil 3-0 self._crc_message(b'\x20\x13\x07\x00\x00\x00\x00', False): False, # turn off all incands self._crc_message(b'\x22\x13\x07\x00\x00\x00\x00', False): False, # turn off all incands @@ -364,7 +357,7 @@ def setUp(self): assert isinstance(self.machine.default_platform, OppHardwarePlatform) self._wait_for_processing() - self.assertEqual(0x02030005, self.machine.default_platform.min_version["com1"]) + self.assertEqual(0x02000000, self.machine.default_platform.min_version["com1"]) self.assertFalse(self.serialMock.expected_commands) self.maxDiff = 100000 @@ -372,10 +365,10 @@ def setUp(self): # test hardware scan info_str = """Connected CPUs: - Port: com1 at 115200 baud. Chain Serial: com1 - -> Board: 0x20 Firmware: 0x2030005 - -> Board: 0x21 Firmware: 0x2030005 - -> Board: 0x22 Firmware: 0x2030005 - -> Board: 0x23 Firmware: 0x2030005 + -> Board: 0x20 Firmware: 0x2000000 + -> Board: 0x21 Firmware: 0x2000000 + -> Board: 0x22 Firmware: 0x2000000 + -> Board: 0x23 Firmware: 0x2000000 Incand cards: - Chain: com1 Board: 0x20 Card: 0 Numbers: [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]