From c1259aea47fe1fbd55e8c03f29a5d4eddc049923 Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Sat, 12 Mar 2022 18:23:00 -0800 Subject: [PATCH 01/11] Don't wait for responses on SEG processor The SEG processor does not send responses for PA, PD, PS, and PC messages. Refactor serial communicator to not wait and timeout --- mpf/_version.py | 2 +- mpf/config_spec.yaml | 1 - mpf/platforms/fast/fast_serial_communicator.py | 7 ++++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mpf/_version.py b/mpf/_version.py index 5a9b56d91..d50a479e8 100644 --- a/mpf/_version.py +++ b/mpf/_version.py @@ -10,7 +10,7 @@ """ -__version__ = '0.56.0-dev.18' +__version__ = '0.56.0-dev.20bsm' '''The full version of MPF.''' __short_version__ = '0.56' diff --git a/mpf/config_spec.yaml b/mpf/config_spec.yaml index a268818b8..b7a822900 100644 --- a/mpf/config_spec.yaml +++ b/mpf/config_spec.yaml @@ -620,7 +620,6 @@ fast: net_buffer: single|int|10 rgb_buffer: single|int|3 dmd_buffer: single|int|3 - segment_buffer: single|int|4 console_log: single|enum(none,basic,full)|none file_log: single|enum(none,basic,full)|basic firmware_updates: list|subconfig(fast_firmware_update)|None diff --git a/mpf/platforms/fast/fast_serial_communicator.py b/mpf/platforms/fast/fast_serial_communicator.py index 203f183cd..a40414a8a 100644 --- a/mpf/platforms/fast/fast_serial_communicator.py +++ b/mpf/platforms/fast/fast_serial_communicator.py @@ -191,9 +191,7 @@ async def _identify_connection(self): elif self.remote_processor == 'SEG': min_version = SEG_MIN_FW # latest_version = SEG_LATEST_FW - self.max_messages_in_flight = self.platform.config['segment_buffer'] - self.platform.debug_log("Setting SEG buffer size: %s", - self.max_messages_in_flight) + self.max_messages_in_flight = 0 # SEG doesn't have ACK messages else: raise AttributeError(f"Unrecognized FAST processor type: {self.remote_processor}") @@ -343,6 +341,9 @@ def _send(self, msg): if debug and msg[0] != "W": self.platform.log.debug("Send: %s", "".join(" 0x%02x" % b for b in msg)) + elif not self.max_messages_in_flight: # For processors that don't use this + self.writer.write(msg.encode() + b'\r') + self.platform.log.debug("Sending without message flight tracking: %s", msg) else: self.messages_in_flight += 1 if self.messages_in_flight > self.max_messages_in_flight: From b464ba314dd5c7b853e35d3009af3fd7b65dc06c Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Sat, 12 Mar 2022 20:39:33 -0800 Subject: [PATCH 02/11] typos & version bump --- mpf/_version.py | 2 +- mpf/core/machine.py | 2 +- mpf/platforms/fast/fast.py | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/mpf/_version.py b/mpf/_version.py index d50a479e8..cd06994fc 100644 --- a/mpf/_version.py +++ b/mpf/_version.py @@ -10,7 +10,7 @@ """ -__version__ = '0.56.0-dev.20bsm' +__version__ = '0.56.0-dev.21bsm' '''The full version of MPF.''' __short_version__ = '0.56' diff --git a/mpf/core/machine.py b/mpf/core/machine.py index f8bc06d17..0fda830cb 100644 --- a/mpf/core/machine.py +++ b/mpf/core/machine.py @@ -560,7 +560,7 @@ async def reset(self) -> None: These events are posted when MPF boots (after the init_phase events are posted), and they're also posted subsequently when the machine is reset - (after existing the service mode, for example). + (after exiting the service mode, for example). This is a queue event. The machine reset phase 3 will not be complete until the queue is cleared. diff --git a/mpf/platforms/fast/fast.py b/mpf/platforms/fast/fast.py index 586cb2249..a828dd128 100644 --- a/mpf/platforms/fast/fast.py +++ b/mpf/platforms/fast/fast.py @@ -348,9 +348,6 @@ def update_leds(self): This is done once per game loop for efficiency (i.e. all LEDs are sent as a single update rather than lots of individual ones). - Also, every LED is updated every loop, even if it doesn't change. This - is in case some interference causes a LED to change color. Since we - update every loop, it will only be the wrong color for one tick. """ dirty_leds = [led for led in self.fast_leds.values() if led.dirty] From b2bba1fa55f25628111ec51bba7e246fd366d824 Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Mon, 14 Mar 2022 21:16:19 -0700 Subject: [PATCH 03/11] dirty path for fast segment throttling default is updates every 0.03 secs (about 30 fps) adjust this in mpf/platforms/fast/fast.py line 350 --- mpf/_version.py | 2 +- mpf/platforms/fast/fast.py | 22 ++++++++++++++++++++++ mpf/platforms/fast/fast_segment_display.py | 13 +++++++++---- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/mpf/_version.py b/mpf/_version.py index cd06994fc..346592055 100644 --- a/mpf/_version.py +++ b/mpf/_version.py @@ -10,7 +10,7 @@ """ -__version__ = '0.56.0-dev.21bsm' +__version__ = '0.56.0-dev.23bsm-fast-segment-throttling' '''The full version of MPF.''' __short_version__ = '0.56' diff --git a/mpf/platforms/fast/fast.py b/mpf/platforms/fast/fast.py index a828dd128..b2dee868f 100644 --- a/mpf/platforms/fast/fast.py +++ b/mpf/platforms/fast/fast.py @@ -335,6 +335,10 @@ def register_processor_connection(self, name: str, communicator): self.net_connection = communicator elif name == 'SEG': self.seg_connection = communicator + + # Dirty patch to batch segment updates + self.machine.events.add_handler('machine_reset_phase_3', self._start_seg_updates) + elif name == 'RGB': self.rgb_connection = communicator self.rgb_connection.send('RF:0') @@ -342,6 +346,24 @@ def register_processor_connection(self, name: str, communicator): self.rgb_connection.send('RF:{}'.format( Util.int_to_hex_string(self.config['hardware_led_fade_time']))) + def _start_seg_updates(self, **kwargs): + self.machine.clock.schedule_interval(self._update_segs, 0.03) # Adjust this last value for udpate interval, in seconds. + + def _update_segs(self, **kwargs): + combined_text = '' + combined_colors = '' + + for s in self.machine.segment_displays: + combined_text += s.hw_display.next_text + combined_colors += s.hw_display.next_color + s.hw_display.next_text = '' + s.hw_display.next_color = '' + + self.seg_connection.send(f'PA:00,{combined_text}') + + if combined_colors: + self.seg_connection.send(f'PC:00,{combined_colors}') + def update_leds(self): """Update all the LEDs connected to a FAST controller. diff --git a/mpf/platforms/fast/fast_segment_display.py b/mpf/platforms/fast/fast_segment_display.py index ff53a0b32..57e502b6d 100644 --- a/mpf/platforms/fast/fast_segment_display.py +++ b/mpf/platforms/fast/fast_segment_display.py @@ -14,20 +14,23 @@ class FASTSegmentDisplay(SegmentDisplayPlatformInterface): """FAST segment display.""" - __slots__ = ["serial", "hex_id"] + __slots__ = ["serial", "hex_id", "next_color", "next_text"] def __init__(self, index, communicator): """Initialise alpha numeric display.""" super().__init__(index) self.serial = communicator self.hex_id = Util.int_to_hex_string(index * 7) + self.next_color = None + self.next_text = None def set_text(self, text: ColoredSegmentDisplayText, flashing: FlashingType, flash_mask: str) -> None: """Set digits to display.""" del flashing del flash_mask colors = text.get_colors() - self.serial.send(f'PA:{self.hex_id},{text.convert_to_str()[0:7]}') + # self.serial.send(f'PA:{self.hex_id},{text.convert_to_str()[0:7]}') + self.next_text = text.convert_to_str()[0:7] if colors: self._set_color(colors) @@ -38,5 +41,7 @@ def _set_color(self, colors: List[RGBColor]) -> None: colors = (RGBColor(colors[0]).hex + ',') * 7 else: colors = ','.join([RGBColor(color).hex for color in colors]) - self.serial.send(('PC:{},{}').format( - self.hex_id, colors)) + #self.serial.send(('PC:{},{}').format( + # self.hex_id, colors)) + + self.next_color = colors From 8609cc46ee70a718964dbdf7d8d7ee003fd33759 Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Tue, 15 Mar 2022 13:10:51 -0700 Subject: [PATCH 04/11] bug fix for segment color COMMA!!!!!!!!!!!! --- mpf/platforms/fast/fast_segment_display.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpf/platforms/fast/fast_segment_display.py b/mpf/platforms/fast/fast_segment_display.py index 57e502b6d..4141de1ba 100644 --- a/mpf/platforms/fast/fast_segment_display.py +++ b/mpf/platforms/fast/fast_segment_display.py @@ -40,7 +40,7 @@ def _set_color(self, colors: List[RGBColor]) -> None: if len(colors) == 1: colors = (RGBColor(colors[0]).hex + ',') * 7 else: - colors = ','.join([RGBColor(color).hex for color in colors]) + colors = ','.join([RGBColor(color).hex for color in colors]) + ',' #self.serial.send(('PC:{},{}').format( # self.hex_id, colors)) From db48d6a8796a9500c4476025c49ce2fb1ea97543 Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Tue, 15 Mar 2022 21:14:14 -0700 Subject: [PATCH 05/11] FAST Segment fixes Added / fixed: * HZ update throttling * fixed color settings * FIxed display ordering --- mpf/_version.py | 2 +- mpf/config_spec.yaml | 1 + mpf/platforms/fast/fast.py | 44 +++++++++++++--------- mpf/platforms/fast/fast_segment_display.py | 11 ++---- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/mpf/_version.py b/mpf/_version.py index 346592055..27f222882 100644 --- a/mpf/_version.py +++ b/mpf/_version.py @@ -10,7 +10,7 @@ """ -__version__ = '0.56.0-dev.23bsm-fast-segment-throttling' +__version__ = '0.56.0-dev.24bsm-fast-segment-throttling' '''The full version of MPF.''' __short_version__ = '0.56' diff --git a/mpf/config_spec.yaml b/mpf/config_spec.yaml index b7a822900..797b294bc 100644 --- a/mpf/config_spec.yaml +++ b/mpf/config_spec.yaml @@ -624,6 +624,7 @@ fast: file_log: single|enum(none,basic,full)|basic firmware_updates: list|subconfig(fast_firmware_update)|None ignore_rgb_crash: single|bool|false + segment_display_update_hz: single|int|20 fast_firmware_update: type: single|enum(net,rgb)| file: single|str| diff --git a/mpf/platforms/fast/fast.py b/mpf/platforms/fast/fast.py index b2dee868f..04176abf7 100644 --- a/mpf/platforms/fast/fast.py +++ b/mpf/platforms/fast/fast.py @@ -43,7 +43,8 @@ class FastHardwarePlatform(ServoPlatform, LightsPlatform, DmdPlatform, __slots__ = ["dmd_connection", "net_connection", "rgb_connection", "seg_connection", "is_retro", "serial_connections", "fast_leds", "fast_commands", "config", "machine_type", "hw_switch_data", - "io_boards", "flag_led_tick_registered", "_watchdog_task", "_led_task"] + "io_boards", "flag_led_tick_registered", "_watchdog_task", "_led_task", "flag_seg_tick_registered", + "fast_segs"] def __init__(self, machine): """Initialise fast hardware platform. @@ -84,7 +85,9 @@ def __init__(self, machine): self._led_task = None self.serial_connections = set() # type: Set[FastSerialCommunicator] self.fast_leds = {} + self.fast_segs = list() self.flag_led_tick_registered = False + self.flag_seg_tick_registered = False self.hw_switch_data = None self.io_boards = {} # type: Dict[int, FastIoBoard] @@ -336,9 +339,10 @@ def register_processor_connection(self, name: str, communicator): elif name == 'SEG': self.seg_connection = communicator - # Dirty patch to batch segment updates - self.machine.events.add_handler('machine_reset_phase_3', self._start_seg_updates) - + if not self.flag_seg_tick_registered: + # Need to wait until the segs are all set up + self.machine.events.add_handler('machine_reset_phase_3', self._start_seg_updates) + elif name == 'RGB': self.rgb_connection = communicator self.rgb_connection.send('RF:0') @@ -347,22 +351,29 @@ def register_processor_connection(self, name: str, communicator): Util.int_to_hex_string(self.config['hardware_led_fade_time']))) def _start_seg_updates(self, **kwargs): - self.machine.clock.schedule_interval(self._update_segs, 0.03) # Adjust this last value for udpate interval, in seconds. + + for s in self.machine.device_manager.collections["segment_displays"]: + self.fast_segs.append(s.hw_display) + + self.fast_segs.sort(key=lambda x: x.number) + + if self.fast_segs: + self.machine.clock.schedule_interval(self._update_segs, + 1 / self.machine.config['fast'][ + 'segment_display_update_hz']) + self.flag_seg_tick_registered = True def _update_segs(self, **kwargs): - combined_text = '' - combined_colors = '' - - for s in self.machine.segment_displays: - combined_text += s.hw_display.next_text - combined_colors += s.hw_display.next_color - s.hw_display.next_text = '' - s.hw_display.next_color = '' - self.seg_connection.send(f'PA:00,{combined_text}') + for s in self.fast_segs: - if combined_colors: - self.seg_connection.send(f'PC:00,{combined_colors}') + if s.next_text: + self.seg_connection.send(f'PA:{s.hex_id},{s.next_text.convert_to_str()[0:7]}') + s.next_text = None + + if s.next_color: + self.seg_connection.send(('PC:{},{}').format(s.hex_id, s.next_color)) + s.next_color = None def update_leds(self): """Update all the LEDs connected to a FAST controller. @@ -793,7 +804,6 @@ async def configure_segment_display(self, number: str, display_size: int, platfo """Configure a segment display.""" self.debug_log("Configuring FAST segment display.") del platform_settings - del display_size if not self.seg_connection: raise AssertionError("A request was made to configure a FAST " "Segment Display but no connection is " diff --git a/mpf/platforms/fast/fast_segment_display.py b/mpf/platforms/fast/fast_segment_display.py index 4141de1ba..20c3adde9 100644 --- a/mpf/platforms/fast/fast_segment_display.py +++ b/mpf/platforms/fast/fast_segment_display.py @@ -29,8 +29,7 @@ def set_text(self, text: ColoredSegmentDisplayText, flashing: FlashingType, flas del flashing del flash_mask colors = text.get_colors() - # self.serial.send(f'PA:{self.hex_id},{text.convert_to_str()[0:7]}') - self.next_text = text.convert_to_str()[0:7] + self.next_text = text if colors: self._set_color(colors) @@ -38,10 +37,6 @@ def _set_color(self, colors: List[RGBColor]) -> None: """Set display color.""" self.serial.platform.info_log("Color: {}".format(colors)) if len(colors) == 1: - colors = (RGBColor(colors[0]).hex + ',') * 7 + self.next_color = (RGBColor(colors[0]).hex + ',') * 7 else: - colors = ','.join([RGBColor(color).hex for color in colors]) + ',' - #self.serial.send(('PC:{},{}').format( - # self.hex_id, colors)) - - self.next_color = colors + self.next_color = ','.join([RGBColor(color).hex for color in colors]) + ',' From 09d84fc1766f4e6ca953ab53d32ee8f3bd6d4a79 Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Wed, 16 Mar 2022 21:08:25 -0700 Subject: [PATCH 06/11] seg task little cleanup --- mpf/_version.py | 2 +- mpf/platforms/fast/fast.py | 12 +++++++----- mpf/platforms/fast/fast_segment_display.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mpf/_version.py b/mpf/_version.py index 27f222882..fe1ce4a90 100644 --- a/mpf/_version.py +++ b/mpf/_version.py @@ -10,7 +10,7 @@ """ -__version__ = '0.56.0-dev.24bsm-fast-segment-throttling' +__version__ = '0.56.0-dev.25bsm-fast-segment-throttling' '''The full version of MPF.''' __short_version__ = '0.56' diff --git a/mpf/platforms/fast/fast.py b/mpf/platforms/fast/fast.py index 04176abf7..7cb356e5a 100644 --- a/mpf/platforms/fast/fast.py +++ b/mpf/platforms/fast/fast.py @@ -43,7 +43,7 @@ class FastHardwarePlatform(ServoPlatform, LightsPlatform, DmdPlatform, __slots__ = ["dmd_connection", "net_connection", "rgb_connection", "seg_connection", "is_retro", "serial_connections", "fast_leds", "fast_commands", "config", "machine_type", "hw_switch_data", - "io_boards", "flag_led_tick_registered", "_watchdog_task", "_led_task", "flag_seg_tick_registered", + "io_boards", "flag_led_tick_registered", "_watchdog_task", "_led_task", "_seg_task", "fast_segs"] def __init__(self, machine): @@ -87,7 +87,7 @@ def __init__(self, machine): self.fast_leds = {} self.fast_segs = list() self.flag_led_tick_registered = False - self.flag_seg_tick_registered = False + self._seg_task = None self.hw_switch_data = None self.io_boards = {} # type: Dict[int, FastIoBoard] @@ -190,6 +190,9 @@ def stop(self): if self._led_task: self._led_task.cancel() self._led_task = None + if self._seg_task: + self._seg_task.cancel() + self._seg_task = None if self._watchdog_task: self._watchdog_task.cancel() self._watchdog_task = None @@ -339,7 +342,7 @@ def register_processor_connection(self, name: str, communicator): elif name == 'SEG': self.seg_connection = communicator - if not self.flag_seg_tick_registered: + if not self._seg_task: # Need to wait until the segs are all set up self.machine.events.add_handler('machine_reset_phase_3', self._start_seg_updates) @@ -358,10 +361,9 @@ def _start_seg_updates(self, **kwargs): self.fast_segs.sort(key=lambda x: x.number) if self.fast_segs: - self.machine.clock.schedule_interval(self._update_segs, + self._seg_task = self.machine.clock.schedule_interval(self._update_segs, 1 / self.machine.config['fast'][ 'segment_display_update_hz']) - self.flag_seg_tick_registered = True def _update_segs(self, **kwargs): diff --git a/mpf/platforms/fast/fast_segment_display.py b/mpf/platforms/fast/fast_segment_display.py index 20c3adde9..e122391fc 100644 --- a/mpf/platforms/fast/fast_segment_display.py +++ b/mpf/platforms/fast/fast_segment_display.py @@ -35,7 +35,7 @@ def set_text(self, text: ColoredSegmentDisplayText, flashing: FlashingType, flas def _set_color(self, colors: List[RGBColor]) -> None: """Set display color.""" - self.serial.platform.info_log("Color: {}".format(colors)) + #self.serial.platform.info_log("Color: {}".format(colors)) if len(colors) == 1: self.next_color = (RGBColor(colors[0]).hex + ',') * 7 else: From 47cfd15190f0ab5951f5f3133a204ec214954639 Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Sun, 8 May 2022 19:36:52 -0700 Subject: [PATCH 07/11] initial commit for FAST Platform v2 branch --- mpf/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpf/_version.py b/mpf/_version.py index fe1ce4a90..2a918048c 100644 --- a/mpf/_version.py +++ b/mpf/_version.py @@ -10,7 +10,7 @@ """ -__version__ = '0.56.0-dev.25bsm-fast-segment-throttling' +__version__ = '0.56.0-dev.19.fast-platform-v2' '''The full version of MPF.''' __short_version__ = '0.56' From ad267129fe6799499e4d755124dc8f547bb0f343 Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Mon, 9 May 2022 19:08:01 -0700 Subject: [PATCH 08/11] updated version number to be PEP 400 compliant --- mpf/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpf/_version.py b/mpf/_version.py index 2a918048c..40b7c8aa0 100644 --- a/mpf/_version.py +++ b/mpf/_version.py @@ -10,7 +10,7 @@ """ -__version__ = '0.56.0-dev.19.fast-platform-v2' +__version__ = '0.56.post19.dev1' '''The full version of MPF.''' __short_version__ = '0.56' From ff868ed37306fcef2f97b12adcb7ecc9c635255a Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Mon, 9 May 2022 19:08:24 -0700 Subject: [PATCH 09/11] replaced deprecated distutils --- mpf/platforms/fast/fast.py | 22 +++++++++-------- .../fast/fast_serial_communicator.py | 24 +++++++++---------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/mpf/platforms/fast/fast.py b/mpf/platforms/fast/fast.py index 7cb356e5a..c433f431a 100644 --- a/mpf/platforms/fast/fast.py +++ b/mpf/platforms/fast/fast.py @@ -7,7 +7,7 @@ import asyncio import os from copy import deepcopy -from distutils.version import StrictVersion +from packaging import version from typing import Dict, Set, Optional from serial import SerialException @@ -158,7 +158,7 @@ def _update_net(self) -> str: max_firmware = self.net_connection.remote_firmware update_config = None for update in self.config['firmware_updates']: - if StrictVersion(update['version']) > StrictVersion(max_firmware) and update['type'] == "net": + if version.parse(update['version']) > version.parse(max_firmware) and update['type'] == "net": update_config = update if not update_config: @@ -250,8 +250,10 @@ def register_io_board(self, board): def _update_watchdog(self): """Send Watchdog command.""" - if self.net_connection: + try: self.net_connection.send('WD:' + str(hex(self.config['watchdog']))[2:]) + except: + pass def process_received_message(self, msg: str, remote_processor: str): """Send an incoming message from the FAST controller to the proper method for servicing. @@ -274,7 +276,7 @@ def process_received_message(self, msg: str, remote_processor: str): self.log.warning("Received malformed message: %s from %s", msg, remote_processor) return - # Can't use try since it swallows too many errors for now + # Can't use try since it swallows too many errors for now #TODO if cmd in self.fast_commands: self.fast_commands[cmd](payload, remote_processor) else: # pragma: no cover @@ -824,7 +826,7 @@ def get_switch_config_section(cls): """Return switch config section.""" return "fast_switches" - def _check_switch_coil_combincation(self, switch, coil): + def _check_switch_coil_combination(self, switch, coil): # V2 hardware can write rules across node boards if not self.net_connection.is_legacy: return @@ -855,7 +857,7 @@ def set_pulse_on_hit_and_release_rule(self, enable_switch, coil): "Driver: %s", enable_switch.hw_switch.number, coil.hw_driver.number) - self._check_switch_coil_combincation(enable_switch, coil) + self._check_switch_coil_combination(enable_switch, coil) driver = coil.hw_driver @@ -888,8 +890,8 @@ def set_pulse_on_hit_and_release_and_disable_rule(self, enable_switch: SwitchSet "%s, Driver: %s", enable_switch.hw_switch.number, coil.hw_driver.number) - self._check_switch_coil_combincation(enable_switch, coil) - self._check_switch_coil_combincation(eos_switch, coil) + self._check_switch_coil_combination(enable_switch, coil) + self._check_switch_coil_combination(eos_switch, coil) driver = coil.hw_driver @@ -921,7 +923,7 @@ def set_pulse_on_hit_rule(self, enable_switch: SwitchSettings, coil: DriverSetti "Driver: %s", enable_switch.hw_switch.number, coil.hw_driver.number) - self._check_switch_coil_combincation(enable_switch, coil) + self._check_switch_coil_combination(enable_switch, coil) driver = coil.hw_driver @@ -943,7 +945,7 @@ def set_pulse_on_hit_and_enable_and_release_rule(self, enable_switch: SwitchSett "Switch: %s, Driver: %s", enable_switch.hw_switch.number, coil.hw_driver.number) - self._check_switch_coil_combincation(enable_switch, coil) + self._check_switch_coil_combination(enable_switch, coil) driver = coil.hw_driver diff --git a/mpf/platforms/fast/fast_serial_communicator.py b/mpf/platforms/fast/fast_serial_communicator.py index a40414a8a..38a0d3d55 100644 --- a/mpf/platforms/fast/fast_serial_communicator.py +++ b/mpf/platforms/fast/fast_serial_communicator.py @@ -1,6 +1,6 @@ """Fast serial communicator.""" import asyncio -from distutils.version import StrictVersion +from packaging import version from mpf.platforms.fast import fast_defines from mpf.core.utility_functions import Util @@ -12,14 +12,14 @@ # The following minimum firmware versions are to prevent breaking changes # in MPF from running on boards that have not been updated. -DMD_MIN_FW = '0.88' # Minimum FW for a DMD -NET_MIN_FW = '2.0' # Minimum FW for a V2 controller -NET_LEGACY_MIN_FW = '0.88' # Minimum FW for a V1 controller -RGB_MIN_FW = '2.0' # Minimum FW for an RGB LED controller -RGB_LEGACY_MIN_FW = '0.87' -IO_MIN_FW = '1.09' # Minimum FW for an IO board linked to a V2 controller -IO_LEGACY_MIN_FW = '0.87' # Minimum FW for an IO board linked to a V1 controller -SEG_MIN_FW = '0.10' # Minimum FW for a Segment Display +DMD_MIN_FW = version.parse('0.88') # Minimum FW for a DMD +NET_MIN_FW = version.parse('2.0') # Minimum FW for a V2 controller +NET_LEGACY_MIN_FW = version.parse('0.88') # Minimum FW for a V1 controller +RGB_MIN_FW = version.parse('2.0') # Minimum FW for an RGB LED controller +RGB_LEGACY_MIN_FW = version.parse('0.87') +IO_MIN_FW = version.parse('1.09') # Minimum FW for an IO board linked to a V2 controller +IO_LEGACY_MIN_FW = version.parse('0.87') # Minimum FW for an IO board linked to a V1 controller +SEG_MIN_FW = version.parse('0.10') # Minimum FW for a Segment Display LEGACY_ID = 'FP-CPU-0' # Start of an id for V1 controller RETRO_ID = 'FP-SBI' # Start of an id for a Retro controller @@ -143,7 +143,7 @@ async def _identify_connection(self): if self.remote_model.startswith(RETRO_ID): self.is_retro = True - elif StrictVersion(self.remote_firmware) < StrictVersion(V2_FW): + elif self.remote_firmware < V2_FW: self.is_legacy = True self.platform.log.info("Connected! Processor: %s, " @@ -195,7 +195,7 @@ async def _identify_connection(self): else: raise AttributeError(f"Unrecognized FAST processor type: {self.remote_processor}") - if StrictVersion(min_version) > StrictVersion(self.remote_firmware): + if version.parse(self.remote_firmware) < min_version: raise AssertionError(f'Firmware version mismatch. MPF requires the {self.remote_processor} processor ' f'to be firmware {min_version}, but yours is {self.remote_firmware}') @@ -313,7 +313,7 @@ async def query_fast_io_boards(self): node_id, model, fw, int(sw, 16), int(dr, 16)) min_fw = IO_LEGACY_MIN_FW if self.is_legacy else IO_MIN_FW - if StrictVersion(min_fw) > str(fw): + if min_fw > version.parse(fw): self.platform.log.critical("Firmware version mismatch. MPF requires the IO boards " "to be firmware %s, but your Board %s (%s) is firmware %s", min_fw, node_id, model, fw) From 8de2559341d4afaa2b31ed4fc9cd89285e97de0a Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Mon, 23 May 2022 13:49:24 -0700 Subject: [PATCH 10/11] version bump to dev.20 --- mpf/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpf/_version.py b/mpf/_version.py index 40b7c8aa0..7053a18b5 100644 --- a/mpf/_version.py +++ b/mpf/_version.py @@ -10,7 +10,7 @@ """ -__version__ = '0.56.post19.dev1' +__version__ = '0.56.0-dev.20' '''The full version of MPF.''' __short_version__ = '0.56' From 127549025ae5b07ef1040d279469663e93108dd0 Mon Sep 17 00:00:00 2001 From: Brian Madden Date: Mon, 23 May 2022 14:44:44 -0700 Subject: [PATCH 11/11] add packaging module to setup requirements --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 18b015c53..90c53e47e 100644 --- a/setup.py +++ b/setup.py @@ -114,6 +114,7 @@ 'pyserial-asyncio==0.5;platform_system!="Windows"', 'sortedcontainers==2.3.0', 'psutil==5.7.3', + 'packaging', ], extras_require={