Can I use only MPF-MC ?

102 views
Skip to first unread message

Lorenzo

unread,
Jun 5, 2017, 2:13:57 PM6/5/17
to MPF Users
Hello,
I'm working on a machine that has a pinball display, that means scoring, animation etc.
This machine has a pressure sensor and a camera. Anytime the pressure sensor change his value, the machine will take a picture and the display will show a score and some anymation.

Then, I would like to control the pressure sensor and the camera with arduino or teensy, and the media stuff with mpf-mc.

To do that, I thought I should send commands to mpf-mc using the BCP protocol and then let it starts the animation. An other ways is to use arduino as a pinball switch and let it control the sensor pressure and the camera, closing the circuit anytime the pressure sensor change his value.

I'm not so confident with coding and electronics, but I'm studing, so, any advide will be helpful.
Sorry for my english, I hope it was clear enough

Thanks for your help
Lorenzo  

jabdoa

unread,
Jun 5, 2017, 2:20:12 PM6/5/17
to MPF Users
Hi Lorenzo,

you can use MPF-MC without MPF. You are not even the first one to try. See this thread: https://groups.google.com/d/msg/mpf-users/mbvfl8c5Zmg/SCoK8FQmCQAJ.

However, you could also implement your teensy or arduino as platform in MPF. Depends if you want to write your complete game/scoring in the arduino or in MPF. Both ways are possible. Writing your own platform is probably more convenient and has been done by more people.


Jan

Lorenzo

unread,
Jun 5, 2017, 6:01:21 PM6/5/17
to MPF Users
Thank you very much Jan,
I'll have a look to the post you linked me!

Lorenzo

unread,
Jun 7, 2017, 12:53:13 PM6/7/17
to MPF Users
Hello and thanks for help.

I'm trying to do do some tests on mpf mc to undersdand the protocolol but I'm having troubles.

These are my steps:

- Downloaded and installed mpf 0.33x
- Created a machince folder with a basic config file
- Run mpf mc
- Sent some string on tcp


This is my config file:

#config_version=4

switches:
    s_1:
        number:
        label:
        tags: first

displays:
  window:
    width: 800
    height: 600

slides:
  welcome_slide:
    widgets:
      - type: text
        text: PINBALL Lore!
        font_size: 50
        color: red
      - type: rectangle
        width: 240
        height: 60

  welcome_slide_2:
    widgets:
      - type: text
        text: 2 PINBALL Lore 2!
        font_size: 50
        color: red
      - type: rectangle
        width: 240
        height: 60

slide_player:
   init_done: welcome_slide
   sw_first: welcome_slide_2

keyboard:
    l:
        switch: s_1

And I send tcp message with a small software I found online called packet sender. I send strings to 127.0.0.1 port 5050


Whn I run: mpf both -X everything works well. It just change a slide when a push the "L" key.

Otherwise, if I run:

mpf mc -X

and then a try to send the string  "hello?version=1.0" the software just closes.

Down below the terminal output:

mpf mc -X
kivy: Factory: 194 symbols loaded
kivy: Image: Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
kivy: VideoGstplayer: Using Gstreamer 1.8.3.0
kivy: Video: Provider: gstplayer
kivy: Loading MPF-MC controller
mpfmc: Mission Pinball Framework Media Controller v0.33.6
mpfmc: Mission Pinball Framework Game Engine v0.33.28
mpfmc: Machine path: /home/lorenzo/Scrivania/mpf/tutorial_step_18_mod
mpfmc: Starting clock at 30.0Hz
kivy: Text: Provider: sdl2
kivy: OSC: using <multiprocessing> for socket
kivy: Window: Provider: sdl2(['window_egl_rpi'] ignored)
kivy: GL: Using the "OpenGL" graphics system
kivy: GL: Backend used <gl>
kivy: GL: OpenGL version <b'3.0 Mesa 12.0.6'>
kivy: GL: OpenGL vendor <b'Intel Open Source Technology Center'>
kivy: GL: OpenGL renderer <b'Mesa DRI Intel(R) Sandybridge Mobile '>
kivy: GL: OpenGL parsed version: 3, 0
kivy: GL: Shading version <b'1.30'>
kivy: GL: Texture max size <8192>
kivy: GL: Texture max units <16>
kivy: Window: auto add sdl2 input provider
kivy: Window: virtual keyboard not allowed, single mode, not docked
SoundSystem: SoundSystem: Using default 'sound_system' settings
AudioInterface: Initialized
SoundSystem: No audio tracks are specified in your machine config file. a track named 'default' has been created.
kivy: ProbeSysfs: device match: /dev/input/event5
kivy: MTD: Read event from </dev/input/event5>
kivy: Base: Start application main loop
kivy: MTD: Unable to open device "/dev/input/event5". Please ensure you have the appropriate permissions.
MPF-MC BCP Server: Starting up on localhost port 5050
MPF-MC BCP Server: Waiting for a connection...
kivy: GL: NPOT texture support is available


Then I try to send the "hello?version=1.0" string to 127.0.0.1 port 5050


MPF-MC BCP Server: Received connection from: 127.0.0.1:59989
mpfmc: Stopping...
mpfmc: Loop rate 40.2 Hz
kivy: Base: Leaving application in progress...
mpfmc: Stopping...
mpfmc: Loop rate 40.22 Hz
kivy: MC run loop ended.
kivy: Stopping child threads... (2 remaining)
MPF-MC BCP Server: Stopping BCP sending thread
kivy: All child threads stopped.


Any help will be welcome
Thank you very much

Lorenzo

Quinn Capen

unread,
Jun 7, 2017, 1:08:58 PM6/7/17
to MPF Users
Lorenzo,

Can you retry sending your hello command with "hello?version=1.1"?  The BCP version in 0.33 is now 1.1.
Also, what command are you using to run the MC by itself?

Quinn

Lorenzo Bisconti

unread,
Jun 7, 2017, 1:35:29 PM6/7/17
to mpf-...@googlegroups.com
Hello,
I've tried but nothing changed:


MPF-MC BCP Server: Waiting for a connection...
kivy: GL: NPOT texture support is available


Then I send the hello?version=1.1

MPF-MC BCP Server: Received connection from: 127.0.0.1:52683
mpfmc: Stopping...
mpfmc: Loop rate 40.13 Hz

kivy: Base: Leaving application in progress...
mpfmc: Stopping...
mpfmc: Loop rate 40.12 Hz

kivy: MC run loop ended.
kivy: Stopping child threads... (1 remaining)

MPF-MC BCP Server: Stopping BCP sending thread
kivy: All child threads stopped.


I don't run the mpf pin controller because I just want to use the mpf mc to play slydes and scores anytime something happens on my own hardware (that I didn't buid yet).


Jan told me it is possible to do that. I don't know if it is ok to run the normal release or I have to run the dev release.
I would like to run just the mpf mc and write with python some program that send a string by tcp anytime something happen and then mpf mc will change slide and show scores.

Thanks for help

--
You received this message because you are subscribed to a topic in the Google Groups "MPF Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mpf-users/Wrl8Ulxht-8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mpf-users+unsubscribe@googlegroups.com.
To post to this group, send email to mpf-...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpf-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpf-users/96ff92c1-bbc4-44df-94b5-a54f4decf8d0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Quinn Capen

unread,
Jun 7, 2017, 2:01:56 PM6/7/17
to MPF Users
I can now reproduce this on my system. It appears to be a unicode/utf-8 string decoding problem when I use a telnet terminal to send strings to the MC. I will do some more research and see if I can figure out a solution.

Quinn

Quinn Capen

unread,
Jun 7, 2017, 2:32:25 PM6/7/17
to MPF Users
Following up with some additional information.  The MC expects all strings to be UTF-8 encoded and commands should be separated only by a newline character.  I could not figure out how to set my telnet client to only send a newline character when I press Enter (it sends CR and LF).  The additional LF character causes the messages to not get decoded properly (for example, the version parameter in the hello command includes a LF which means the version comparison will fail).

I understand the problem fully now.  Time to figure out a solution...

Quinn

jabdoa

unread,
Jun 7, 2017, 3:21:18 PM6/7/17
to MPF Users
A python script should do it. Or you can use the BcpSocketClient from mpf which will do all the encoding and decoding for you. Telnet on Linux apparently also works for mpf. Did not try it on mc.


Jan

Lorenzo

unread,
Jun 8, 2017, 4:30:27 AM6/8/17
to MPF Users
Thank you Quinn, thank you Jan.

Jan, what do you mean with "did not try it on mc?"
I don't find infos on BcpSocketClient, I don't know how can I load it in a python script or whatever.

Can you tell me where I'm doing wrong on the procedure I explained below ? Did I make some mistake on config file? Did I make mistakes sending command by tcp on the same machine? I don't really know what's going on..

Thanks for help,
Lorenzo

jabdoa

unread,
Jun 8, 2017, 8:39:00 AM6/8/17
to MPF Users
Hi Lorenzo,

I looked into this today. I catched the decoding error which Quinn mentioned. MC will not exit anymore in this case. Furthermore, we strip the command now to get rid of any \r and \n at the end of commands. I released mpf-mc 0.33.7 just now. Should be up soon. You can upgrade using:

pip3 install --upgrade mpf-mc

Furthermore, I noticed that you have to run mc with -t to get proper error output:

mpf mc -t

This is caused by a bug introduced by our text UI which silences the log in MC. This should not happen when you start mc standalone. We will fix it but "-t" should do the trick for now.


Jan

Lorenzo Bisconti

unread,
Jun 12, 2017, 3:55:00 AM6/12/17
to mpf-...@googlegroups.com
Hello Jan.
thanks for reply.
unfortunatlely I'm not able to understand what you are trying to explain to me. The only thing I tried is to run the command to upgrade the version and, after that, I still have the 0.33.28 and not the 0.33.7. I don't know why.

mpf mc still crash when I try to send any kind of command by terminal. Actually I've tried with "demo_man" too. I've just run "mpf mc" and then I've tried to send a string on tcp and it doesn't crash. Nothing works, of course, but it doesn't crash and it is something unexpected.

I'll try to get help from someone here around and then I'll let you know.

Thanks for help
Lorenzo

--
You received this message because you are subscribed to a topic in the Google Groups "MPF Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mpf-users/Wrl8Ulxht-8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mpf-users+unsubscribe@googlegroups.com.
To post to this group, send email to mpf-...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpf-users.
Reply all
Reply to author
Forward
0 new messages