Skip to content

Commit

Permalink
Finalized FAST Nano integration & tests, v0.57.0.dev10
Browse files Browse the repository at this point in the history
  • Loading branch information
toomanybrians committed Sep 26, 2023
1 parent 5925b19 commit c08d41c
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 149 deletions.
2 changes: 1 addition & 1 deletion mpf/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""

__version__ = '0.57.0.dev9'
__version__ = '0.57.0.dev10'
'''The full version of MPF.'''

__short_version__ = '0.57'
Expand Down
8 changes: 2 additions & 6 deletions mpf/platforms/fast/communicators/net_nano.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ class FastNetNanoCommunicator(FastNetNeuronCommunicator):
DRIVER_CMD = 'DN'
SWITCH_CMD = 'SN'

def __init__(self, platform, processor, config):
super().__init__(platform, processor, config)

self.message_processors['\x11\x11!'] = self._process_reboot_done

async def configure_hardware(self):
pass # Not used on a Nano

Expand All @@ -39,4 +34,5 @@ def _process_boot_message(self, msg):

if msg == '02': # reboot done
self._process_reboot_done()
# TODO what else? Mark all configs as dirty? Log and warn if this was unexpected?
# TODO what else? Mark all configs as dirty? Log and warn if this was unexpected?
# TODO add ignore_reboot option to config
9 changes: 4 additions & 5 deletions mpf/platforms/fast/communicators/rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ async def init(self):

def _process_boot_msg(self, msg):
"""Process bootloader message."""
self.debug_log(f"Got Bootloader message: !B:{msg}")
ignore_rgb = self.config['ignore_reboot']
self.log.debug(f"Got Bootloader message: !B:{msg}")
if msg in ('00', '02'):
if ignore_rgb:
if self.config['ignore_reboot']:
self.machine.events.post("fast_rgb_rebooted", msg=msg)
self.error_log("FAST RGB processor rebooted. Ignoring.")
self.log.error("FAST RGB processor rebooted. Ignoring.")
else:
self.error_log("FAST RGB processor rebooted.")
self.log.error("FAST RGB processor rebooted.")
self.machine.stop("FAST RGB processor rebooted")

def update_leds(self):
Expand Down
38 changes: 7 additions & 31 deletions mpf/platforms/fast/fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def configure_light(self, number, subtype, config, platform_settings) -> LightPl
return FASTMatrixLight(number, self.serial_connections['net'], self.machine,
int(1 / self.config['net']['lamp_hz'] * 1000), self)
if not subtype or subtype == "led":

# TODO refactor and split into EXP and RGB communicators
parts, channel = number.lower().rsplit('-', 1) # make everything lowercase and strip trailing channel number
parts = parts.split('-') # split into board name, (breakout), port, led

Expand Down Expand Up @@ -581,16 +581,20 @@ def port_idx_to_hex(self, port, device_num, devices_per_port, name=None):
device_num: LED position in the change, First LED is 1. No zeros.
devices_per_port: number of LEDs per port. Typically 32.
"""

port = int(port)
device_num = int(device_num)

if port < 1:
raise AssertionError(f"Port {port} is not valid for device {device_num}")

if device_num > devices_per_port:
if name:
self.raise_config_error(f"Device number {device_num} exceeds the number of devices per port ({devices_per_port}) "
f"for LED {name}", 8) # TODO get a final error code
else:
raise AssertionError(f"Device number {device_num} exceeds the number of devices per port ({devices_per_port})")

port_offset = ((int(port) - 1) * devices_per_port)
port_offset = ((port - 1) * devices_per_port)
device_num = device_num - 1
return f'{(port_offset + device_num):02X}'

Expand Down Expand Up @@ -793,31 +797,3 @@ def clear_hw_rule(self, switch, coil):
driver = coil.hw_driver

driver.clear_autofire()

# TODO everything below needs to move

def receive_nw_open(self, msg, remote_processor):
"""Process network switch open.
Args:
----
msg: switch number
remote_processor: Processor which sent the message.
"""
assert remote_processor == "NET"
self.machine.switch_controller.process_switch_by_num(state=0,
num=(msg, 1),
platform=self)

def receive_nw_closed(self, msg, remote_processor):
"""Process network switch closed.
Args:
----
msg: switch number
remote_processor: Processor which sent the message.
"""
assert remote_processor == "NET"
self.machine.switch_controller.process_switch_by_num(state=1,
num=(msg, 1),
platform=self)
9 changes: 3 additions & 6 deletions mpf/tests/machine_files/fast/config/nano.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ hardware:
fast:
net:
port: com6
debug: true
controller: nano
io_loop:
3208:
Expand All @@ -28,7 +27,6 @@ fast:
order: 4
rgb:
port: com5
debug: true

switches:
s_test:
Expand Down Expand Up @@ -163,11 +161,10 @@ flippers:

lights:
test_led:
number: 2-23
type: grb
test_led2:
number: 2-23 #0x56
test_led2: #0x57
previous: test_led
type: grb
l_o_circle:
number: 0-10
number: 1-10 # 0x09
type: grb
4 changes: 3 additions & 1 deletion mpf/tests/platforms/fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ def __init__(self, test_fast_base):
}

self.leds = dict()
for i in range(128):
self.leds[f'{i:02X}'] = "000000"

def process_msg(self, cmd):
if cmd[:3] == 'RS:':
Expand Down Expand Up @@ -283,7 +285,7 @@ def __init__(self, test_fast_base):
self.autorespond_commands = {
'WD:1' : 'WD:P',
'WD:3E8': 'WD:P',
"SA:": "SA:01,00,09,050000000000000000",
"SA:": "SA:01,00,09,000000040000000000", # switch 0x1A is active
'ID:': 'ID:NET FP-CPU-002-2 01.05',
}

Expand Down
Loading

0 comments on commit c08d41c

Please sign in to comment.