missionpinball / mpf

Mission Pinball Framework: Open source software to run a real pinball machine.
http://missionpinball.org
MIT License
217 stars 143 forks source link

FAST Neuron should ignore switches on other platforms #1837

Closed bosh closed 1 month ago

bosh commented 2 months ago

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 :)

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

bosh commented 1 month ago

PR is all ready for final review! I've also tested the current version (with the list comprehension) on my neuron, no problems.