Author Topic: Problems getting started with P-ROC on Mac w/ OS X Mavericks  (Read 3196 times)

george.profenza

  • Newbie
  • *
  • Posts: 5
    • View Profile
Problems getting started with P-ROC on Mac w/ OS X Mavericks
« on: September 02, 2014, 09:12:54 AM »
Hi,

I've got a P-ROC REV 3.0 board hooked up to mac mini running OSX Mavericks.
So far I've used Brian Madden's guide (http://www.pinballcontrollers.com/forum/index.php?topic=1204.0) to install libpinproc/pypinproc/pyprocgame and that seemed to work fine.

I also tried to run one of the samples from the wiki (http://pinballcontrollers.com/wiki/Sample_Game_Files) but ran into the following errors:

Code: [Select]
No handlers could be found for logger "game.config"
WARNING no font_path set in None!
Unable to open ftdi device: -3: device not found
Error opening P-ROC device.
Traceback (most recent call last):
  File "helloPROC.py", line 4, in <module>
    game = procgame.game.GameController(machine_type=pinproc.MachineTypePDB)
  File "build/bdist.macosx-10.9-intel/egg/procgame/game/game.py", line 77, in __init__
  File "build/bdist.macosx-10.9-intel/egg/procgame/game/game.py", line 95, in create_pinproc
IOError: Unable to open ftdi device: -3: device not found

Running procgame config returns this:
Code: [Select]
procgame config
No handlers could be found for logger "game.config"
Your configuration file is located at:

  None

Traceback (most recent call last):
  File "/usr/local/bin/procgame", line 8, in <module>
    load_entry_point('pyprocgame==1.0.1', 'console_scripts', 'procgame')()
  File "build/bdist.macosx-10.9-intel/egg/procgame/tools/cmd.py", line 53, in main
    IDENTCHARS = string.ascii_letters + string.digits + '_'
  File "build/bdist.macosx-10.9-intel/egg/procgame/tools/config.py", line 77, in tool_run
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.py", line 18, in exists
    os.stat(path)
TypeError: coercing to Unicode: need string or buffer, NoneType found

So I may be missing a main config yaml file, but the specs don't seem to point to the serial port. I had a look at the documentation for the configration yaml format but it seems to mostly describe game related features such as font paths/display/etc.

I can see the P-ROC's serial port:
Code: [Select]
ls /dev/tty.*
/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbserial-A703RRND
/dev/tty.Bluetooth-Modem

but I can't seem instantiate PinPROC or GameController since both throw an error openening the ftdi port. At his point I don't know if the issues is simply setting the serial port (in which case how would I do that? ) or something is wrong with libftdi (in which case how can I check and fix this ?).

Any hints/tips are useful. Thank you for your patience, this is the 1st time I use this hardware and I have have no prior experience with pinball machines, so any 'hello world'/starters guide would help. I don't mind RTFM as long as I can pointed in the right direction :)
« Last Edit: September 02, 2014, 12:38:09 PM by Gerry Stellenberg »

spootdev

  • Full Member
  • ***
  • Posts: 36
    • View Profile
Re: Getting started with P-ROC
« Reply #1 on: September 02, 2014, 11:23:12 AM »
As for the device not found.....do you have the four leds "rotating" showing the board is powered correctly and happy?

george.profenza

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Getting started with P-ROC
« Reply #2 on: September 02, 2014, 11:38:14 AM »
Hi spootdev,

Thanks for the reply.
I can confirm the leds are rotating happily.
At the moment I can see these LEDs cycling/rotating:
D48,D45,D47,D46
Also here is the list of all other LEDs currently on:
D44,D42,D41 and 3 above: D49,D52,D50

Rosh

  • P3 Developers
  • *
  • Posts: 667
  • Josh Kugler
    • View Profile
Re: Getting started with P-ROC
« Reply #3 on: September 02, 2014, 12:04:18 PM »
Quote
IOError: Unable to open ftdi device: -3: device not found

Typically I only see this when it is not power up or hooked up.  But, there are some things you need to do to be sure it is seen.  First off, when you plug it in to the mac, do you see it show up if you run dmesg?

Also, on mavericks you need to tell the mac to not use its drivers for the the FTDI


There are some udev commands needed on linux, trying to remember if those are also needed on the mac.  Regardless, you need to run this command after it fails the first time (and then you will have to do this again after a reboot).

sudo kextunload -bundle-id com.apple.driver.AppleUSBFTDI

There is a more permanent fix for that, just don't recall what it is.  I don't think this will fix your problem, since it is typically a different error message.

Have you run things using fakepinproc?  Let see if that is working before tying to hook to the hardware.  Sounds like you may not have done that since it seems you are getting an error of no config.yaml file, which is where that would be set.  That file often sits in the main directory for your game.  so, if you don't have that, that is the first place to start.


Brian Madden

  • Wizard
  • *****
  • Posts: 498
  • Mission Pinball
    • View Profile
    • Mission Pinball
Re: Getting started with P-ROC
« Reply #4 on: September 02, 2014, 12:15:09 PM »
I can +1 to what Rosh wrote. I had the exact same error, and for me fakepinproc worked fine.

In my case I had a Windows VM which also had pyprocgame and all the drivers installed. I had to unmount the P-ROC from the VM, then I had to run that command to remove the Apple FTDI driver, and then the physical P-ROC would work from the Mac.
Brian
The Mission Pinball Framework (MPF) Project*
Twitter
* Disclaimer: MPF is a work-in-progress!

Rosh

  • P3 Developers
  • *
  • Posts: 667
  • Josh Kugler
    • View Profile
Re: Getting started with P-ROC
« Reply #5 on: September 02, 2014, 12:23:01 PM »
FYI, I just did a new post with a more permanent fix for the FTDI issue (that will stick after reboots), although seems have at least one other issue on this regarding the config file.

george.profenza

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problems getting started with P-ROC on Mac w/ OS X Mavericks
« Reply #6 on: September 02, 2014, 12:47:41 PM »
Thanks guys!

This is really helpful.

Rosh, brilliant tip on unloading the Mavericks AppleFTDI kext.
That bit me last year on a different project using the FTDID2XX library and I still haven't learned my lesson :)

This was the issue indeed. Now the output I get looks like this:
Code: [Select]
No handlers could be found for logger "game.config"
WARNING no font_path set in None!
Flushing Read Buffer: 0 bytes trashed
Verify Chip ID took too long to receive data
Verification of chip ID failed.  Flushing read buffer and re-verifying chip ID.
Flushing Read Buffer: 0 bytes trashed
FPGA Chip ID: 0xfeedbeef
FPGA Chip Version/Rev: 1.22
Creating PDLED board: 8
LEDS
rgb0
A8-R0-G1-B2
rgb1
A8-R3-G4-B5
Traceback (most recent call last):
  File "helloPROC.py", line 7, in <module>
    game.lamps.testLamp.schedule(schedule=0x00ff00ff, cycle_seconds=0, now=False)
  File "build/bdist.macosx-10.9-intel/egg/procgame/game/gameitems.py", line 16, in __getattr__
KeyError: "Error looking up key testLamp: 'testLamp'"

I haven't got very far yet reading the documentation, so my guess is I'll need define testLamp somewhere if I want to test it.

I haven't used fakepinproc so far, I don't remember setting that up.

I'm guessing now's a got time to plug a PD16 or PD-LED board and see if I can control it, right ? Is there any LED or simple element I can control on the P-ROC board to test before hand ? What would you recommend ?

Thank you again for the useful advice.


Brian Madden

  • Wizard
  • *****
  • Posts: 498
  • Mission Pinball
    • View Profile
    • Mission Pinball
Re: Problems getting started with P-ROC on Mac w/ OS X Mavericks
« Reply #7 on: September 02, 2014, 12:52:25 PM »
Yeah this error means that you don't have a lamp called `testlamp` defined. You can add it to the PRLamps section of your machine yaml file and all should be good. FYI in pyprocgame, the game.lamps collection only includes lamps or LEDs that are connected to a lamp matrix via a PD 8x8. LEDs connected to a PD-LED board are accessed and controlled via a LED Controller module.
Brian
The Mission Pinball Framework (MPF) Project*
Twitter
* Disclaimer: MPF is a work-in-progress!

george.profenza

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problems getting started with P-ROC on Mac w/ OS X Mavericks
« Reply #8 on: September 02, 2014, 02:40:22 PM »
Awesome,

I'm slowly starting to get my head around this.

At the moment I'm trying to print out the state of switch SD7 which fipperLwR is set to.
I noticed Mode has a add_switch_handler so I've changed the script to test like so:

Code: [Select]
import procgame.game
import pinproc

game = procgame.game.GameController(machine_type=pinproc.MachineTypePDB)
game.load_config('sample_pdb.yaml')
game.enable_flippers(enable=True)
game.lamps.VUK_right_r.schedule(schedule=0x00ff00ff, cycle_seconds=0, now=False)

def flipperLwR_handler(self,switch):
print switch.name + ' : ' + str(switch.state)

testMode = procgame.game.Mode(game,5)
testSwitch = game.switches.flipperLwR.name
testMode.add_switch_handler(testSwitch,'open',0,flipperLwR_handler)
testMode.add_switch_handler(testSwitch,'closed',0,flipperLwR_handler)
testMode.add_switch_handler(testSwitch,'active',0,flipperLwR_handler)
testMode.add_switch_handler(testSwitch,'inactive',0,flipperLwR_handler)

game.run_loop()

Unfortunately I'm not seeing any change. Is this the correct way to test a switch ?
I've also tried printing game.switches.flipperLwR.state and I can see the value changes, but only once. I'm guessing I need to add some of the event handler/callback for the main game loop ? If so, how would I do that ?

Thanks again!

Rosh

  • P3 Developers
  • *
  • Posts: 667
  • Josh Kugler
    • View Profile
Re: Problems getting started with P-ROC on Mac w/ OS X Mavericks
« Reply #9 on: September 02, 2014, 03:11:56 PM »
you can really test a switch just by having it defined in your yaml and watching the console window, which with 'info' logging, should show you all switch events.

george.profenza

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problems getting started with P-ROC on Mac w/ OS X Mavericks
« Reply #10 on: September 02, 2014, 03:23:46 PM »
Hi Rosh,

I've read more of the manual and realised that in my snippet I was creating a new mode, but I didn't add this mode to game.modes. This resolved the issue and I see I prints I expect.

I'm not sure what you mean by 'info' logging. Is this the typical logging type where I can set values such as verbose/info/debug/error etc. ? Is this something I can setup in the yaml file ? So far far I haven't found this in the manual. If you can let me know how to setup the logging type, that would be great!

Thank you!

Rosh

  • P3 Developers
  • *
  • Posts: 667
  • Josh Kugler
    • View Profile
Re: Problems getting started with P-ROC on Mac w/ OS X Mavericks
« Reply #11 on: September 02, 2014, 06:05:39 PM »
yes, you can set up the logging level, among those types.  Using debug is really for extreme cases, as it will send a massive mount of data to the logging (especially if you are doing a lot with lamps).  It is probably already being set up for you by the framework.

Try doing self.game.logger.info('foo bar') and see what happens.

You may need to also set this up at the top of your main game file to get the desired results, can't remember.   This is the code I have there that will do both logging to a file and to the console.  You can use different loggers in different parts of your code.

import logging

#create a logfile with the timestamp and hostname in the /logs/ folder

logging.basicConfig(level=logging.INFO, \
                    filename="log/" + datetime.now().strftime("%Y%m%d_%H%M%S" + ".log"),\
                    format="%(asctime)s - %(name)s - %(message)s",\
                    filemode='w')
console = logging.StreamHandler()
console.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)