OPP & MPF serial problem on Mac

136 views
Skip to first unread message

Adrien A-G

unread,
Feb 7, 2018, 10:07:07 AM2/7/18
to MPF Users

Hello everyone!

I'm new here. I'm trying to make a half scale pinball with (almost) all the fancy stuffs you find on full size pinball.
I'm using OPP and MPF (Both tremendous projects! I only discovered them recently) to drive it from Mac OS X at the moment (I would like to move to Raspberry Pi 3 further down the road). But I'm encountering a problem (I did search the forums but didn't find my answer…) making OPP and MPF communicate together. Maybe I did miss a simple step, has I am not really tech savvy concerning Terminal and Serial ports…

Here is my problem. When I build my MPF Machine (mpf -b) the program end with: 

AttributeError: module 'serial' has no attribute 'serial_for_url'


My OPP processor is flashed with the "Gen2.rev0.2.0.5" firmware and configured with "2sol2switch". The Mac is able to connect to it (and was used to flash it). My MPF config (derived from Step 3 of the Tutorial) is configured for the OPP hardware and the port is the right one at the time of my test. 
I don't get what I'm missing here, some configuration I did wrong or some Python I missed?

Here is my MPF config:

#config_version=4

hardware:
    platform: opp
    driverboards: gen2

opp:
    ports: /dev/cu.usbmodem146121
    baud: 115200

switches:
    s_left_flipper:
        number: 2-16
        tags: left_flipper
    s_right_flipper:
        number: 2-17
        tags: right_flipper

coils:
    c_flipper_left:
        number: 0-0
        allow_enable: yes
        hold_power: 2
    c_flipper_right:
        number: 0-1
        allow_enable: yes
        hold_power: 2

flippers:
    left_flipper:
        main_coil: c_flipper_left
        activation_switch: s_left_flipper
        enable_events: machine_reset_phase_3
    right_flipper:
        main_coil: c_flipper_right
        activation_switch: s_right_flipper
        enable_events: machine_reset_phase_3

Here is the Terminal extract:

MacBook:mini_pinball_v0 madi$ mpf -b
Machine : Mission Pinball Framework Core Engine v0.33.49
Machine : Command line arguments: {'mc_file_name': None, 'no_load_cache': False, 'create_config_cache': True, 'consoleloglevel': 20, 'syslog_address': None, 'logfile': 'logs/2018-02-07-16-00-47-mpf-MacBook.local.log', 'force_platform': None, 'pause': False, 'force_assets_load': False, 'configfile': ['config'], 'loglevel': 11, 'bcp': False, 'mpfconfigfile': '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/mpfconfig.yaml'}
Machine : MPF path: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf
Machine : Machine path: /Users/madi/Documents/Pinball/mini_pinball_v0
Machine : Platform: darwin
Machine : Python executable location: /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
Machine : Python version: 3.5.2 (64-bit)
Machine : Loading config from original files
Machine : Machine config file #1: /Users/madi/Documents/Pinball/mini_pinball_v0/config/config
Machine : Config file cache created: /var/folders/gt/g919nfqj04l8xmnhwkzh3nvw0000gn/T/53bd5a222337892b6d7849a81898bdc9config
OPP : Configuring OPP hardware.
SwitchController : Loading the SwitchController
OPP : Connecting to /dev/cu.usbmodem146121 at 115200bps
root : module 'serial' has no attribute 'serial_for_url'
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/commands/game.py", line 181, in __init__
    MachineController(mpf_path, machine_path, vars(args)).run()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/core/machine.py", line 127, in __init__
    self._initialize_platforms()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/core/machine.py", line 198, in _initialize_platforms
    platform.initialize()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/platforms/opp/opp.py", line 91, in initialize
    self._connect_to_hardware()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/platforms/opp/opp.py", line 154, in _connect_to_hardware
    platform=self, port=port, baud=self.config['baud']))
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/platforms/opp/opp.py", line 938, in __init__
    super().__init__(platform, port, baud)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/platforms/base_serial_communicator.py", line 27, in __init__
    self.machine.clock.loop.run_until_complete(self._connect_to_hardware(port, baud))
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/base_events.py", line 387, in run_until_complete
    return future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/platforms/base_serial_communicator.py", line 35, in _connect_to_hardware
    self.reader, self.writer = yield from connector
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/core/clock.py", line 132, in open_serial_connection
    **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/coroutines.py", line 206, in coro
    res = func(*args, **kw)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/serial_asyncio/__init__.py", line 410, in create_serial_connection
    ser = serial.serial_for_url(*args, **kwargs)
AttributeError: module 'serial' has no attribute 'serial_for_url'

If someone has an idea of what I may have done wrong, I'll be happy to ear it. :¬)

Thanks and take care!

jabdoa

unread,
Feb 7, 2018, 12:16:43 PM2/7/18
to MPF Users
That's a weird error. Can you post the output of "pip3 list"? It looks like pyserial is not installed properly or something. Looks not like a typical error with that lib.


Jan

Adrien A-G

unread,
Feb 7, 2018, 12:21:42 PM2/7/18
to MPF Users
Thank you Jan!

Here is the "pip3 list":

DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.


certifi (2017.11.5)


chardet (3.0.4)


cyflash (1.6)


Cython (0.24.1)


docutils (0.14)


future (0.16.0)


idna (2.6)


iso8601 (0.1.12)


Kivy (1.10.0)


Kivy-Garden (0.1.4)


mpf (0.33.49)


mpf-mc (0.33.16)


mpf-monitor (0.2.1)


pip (9.0.1)


psutil (5.4.3)


Pygments (2.2.0)


PyQt5 (5.10)


pyserial (3.4)


pyserial-asyncio (0.4)


PyYAML (3.12)


requests (2.18.4)


ruamel.base (1.0.0)


ruamel.yaml (0.10.23)


serial (0.0.38)


setuptools (38.4.0)


sip (4.19.7)


typing (3.6.4)


urllib3 (1.22)



Adrien A-G

unread,
Feb 7, 2018, 1:40:34 PM2/7/18
to MPF Users
Thanks for the advice, I did uninstall and re-install pyserial for Python 3 and it seems to have changed something!

Now I have this error. It seems to be a problem with the input I designated in my config file but I don't know where. My configuration on the OPP is 2 solenoid (wing 0 and 1) and 2 inputs (wing 2 and 3) but input number seems to match in my MPF config file…

MacBook:mini_pinball_v0 madi$ mpf -b
Machine : Mission Pinball Framework Core Engine v0.33.49
Machine : Command line arguments: {'mpfconfigfile': '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/mpfconfig.yaml', 'force_assets_load': False, 'pause': False, 'loglevel': 11, 'logfile': 'logs/2018-02-07-19-32-46-mpf-MacBook.local.log', 'configfile': ['config'], 'syslog_address': None, 'bcp': False, 'create_config_cache': True, 'no_load_cache': False, 'consoleloglevel': 20, 'mc_file_name': None, 'force_platform': None}
Machine : MPF path: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf
Machine : Machine path: /Users/madi/Documents/Pinball/mini_pinball_v0
Machine : Platform: darwin
Machine : Python executable location: /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
Machine : Python version: 3.5.2 (64-bit)
Machine : Loading config from original files
Machine : Machine config file #1: /Users/madi/Documents/Pinball/mini_pinball_v0/config/config
Machine : Config file cache created: /var/folders/gt/g919nfqj04l8xmnhwkzh3nvw0000gn/T/53bd5a222337892b6d7849a81898bdc9config
OPP : Configuring OPP hardware.
SwitchController : Loading the SwitchController
OPP : Connecting to /dev/cu.usbmodem146121 at 115200bps
EventManager : Event: ======'machine_var_mpf_version'====== Args={'change': False, 'value': 'MPF v0.33.49', 'prev_value': 'MPF v0.33.49'}
EventManager : Event: ======'machine_var_mpf_extended_version'====== Args={'change': False, 'value': 'MPF v0.33.49, Config version:4, Show version: 4, BCP version:1.1', 'prev_value': 'MPF v0.33.49, Config version:4, Show version: 4, BCP version:1.1'}
EventManager : Event: ======'machine_var_python_version'====== Args={'change': False, 'value': '3.5.2', 'prev_value': '3.5.2'}
EventManager : Event: ======'machine_var_platform'====== Args={'change': False, 'value': 'Darwin-16.7.0-x86_64-i386-64bit', 'prev_value': 'Darwin-16.7.0-x86_64-i386-64bit'}
EventManager : Event: ======'machine_var_platform_system'====== Args={'change': False, 'value': 'Darwin', 'prev_value': 'Darwin'}
EventManager : Event: ======'machine_var_platform_release'====== Args={'change': False, 'value': '16.7.0', 'prev_value': '16.7.0'}
EventManager : Event: ======'machine_var_platform_version'====== Args={'change': False, 'value': 'Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64', 'prev_value': 'Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64'}
EventManager : Event: ======'machine_var_platform_machine'====== Args={'change': False, 'value': 'x86_64', 'prev_value': 'x86_64'}
EventManager : Event: ======'init_phase_1'====== Args={}
Machine : Shutting down...
EventManager : Event: ======'shutdown'====== Args={}
OPP : Stop called on serial connection /dev/cu.usbmodem146121
asyncio : Exception in callback EventManager._done(<Task finishe...146121-2-16')>)
handle: <Handle EventManager._done(<Task finishe...146121-2-16')>)>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/core/events.py", line 572, in _done
    future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/core/events.py", line 507, in _run_handlers_sequential
    handler.callback(queue=queue, **merged_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/core/device_manager.py", line 81, in _load_device_modules
    self.initialize_devices()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/core/device_manager.py", line 162, in initialize_devices
    collection[device_name].device_added_system_wide()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/core/system_wide_device.py", line 13, in device_added_system_wide
    self._initialize()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/devices/switch.py", line 75, in _initialize
    self.hw_switch = self.platform.configure_switch(self.config)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/platforms/opp/opp.py", line 671, in configure_switch
    "with number %s which doesn't exist", number)
AssertionError: ("A request was made to configure an OPP switch with number %s which doesn't exist", '/dev/cu.usbmodem146121-2-16')
root : Event loop stopped before Future completed.
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/commands/game.py", line 181, in __init__
    MachineController(mpf_path, machine_path, vars(args)).run()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpf/core/machine.py", line 134, in __init__
    self.clock.loop.run_until_complete(self._run_init_phases())
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/base_events.py", line 385, in run_until_complete
    raise RuntimeError('Event loop stopped before Future completed.')
RuntimeError: Event loop stopped before Future completed.

Thank you again for your help.

Dan - aka BorgDog

unread,
Feb 7, 2018, 2:37:17 PM2/7/18
to MPF Users
It looks like you only have one OPP in your system?  if so the numbering on your switch definitions is incorrect, they should likely be 0-16 and 0-17.  the 0 being the OPP board number, not the wing number, so if you only have 1 OPP board they would all start with 0


Adrien A-G

unread,
Feb 7, 2018, 4:38:08 PM2/7/18
to MPF Users
You are right! I have only one OPP processor currently. I read the documentation wrong…

Thank you so much to both of you for your help!
Reply all
Reply to author
Forward
0 new messages