-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FAST Neuron should ignore switches on other platforms #1837
Conversation
@@ -294,6 +294,9 @@ def update_switches_from_hw_data(self): | |||
it will process it like any switch change. | |||
""" | |||
for switch in self.machine.switches.values(): | |||
if switch.platform != self.platform: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect there's a better way in python to filter, and then not even need the continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to do it like this:
for switch in self.machine.switches.values() if switch.platform == self.platform:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a few whacks at it and found the final syntax. It's a little awkward imo, but it's in :)
d5d01c8
to
740d66f
Compare
740d66f
to
059786a
Compare
Quality Gate passedIssues Measures |
PR is all ready for final review! I've also tested the current version (with the list comprehension) on my neuron, no problems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great fix, thanks!
If using multiple platforms for switches, the Neuron communicator will try to look up every switch as though they are connected to FAST hardware, causing a crash. This is a bad assumption and it keeps a machine creator from declaring virtual switches when using a Neuron.
Virtual switches can be useful in letting a machine developer add switches to configs before they're wired into the machine, or even by creating virtual-only switches that will never be physically implemented, but can be used in mpf-monitor for debugging and arbitrary event creation.
First commit changes Neuron platform tests to be explicit about which platform they're using (instead of defaulting) but should be green. (Action run: https://github.com/bosh/mpf/actions/runs/10966582957 )
Second commit changes the test to include a cross-platform switch that causes crashes (9x crash in that test file due to Neuron not filtering switch platform) (Action run: https://github.com/bosh/mpf/actions/runs/10966584585 )
Third commit fixes the Neuron communicator code. I'm not sure of the best syntax for this in Python (could we filter the .values() call?) but it works :)