2013
12.19

IMG_1875Remember that ugly box from a few months back I made for playing classic Arcade games?

Well I got a sudden urge to replace it today and now I have a new shinier box with moar buttons, smaller form factor and proper non Japanese buttons.

A few months back after I made my initial blog posts I had ordered a new set of buttons and a joystick for my next project which was going to be a cabinet however things didn’t work out to the point where I could buy the necessary tools and materials to make that a reality and the parts just ended up sitting in my drawer for the last 3 months. My original controller while still functional was beginning to fold at the corners as I made fairly frequent use of it so I was beginning to really worry about how much longer it would last.

IMG_1880That brings me to today, I was looking at a box on my desk from my 4 year service award and just like before the wheel began to turn and all of a sudden I was cutting out holes on the box for the stick and buttons. That was the easy part. I also decided months ago to get parts that would require traditional wiring so I had already made my ground line 3 months ago but I still needed to make my cables for the actual switches themselves. It wasn’t too hard, I had the tools and parts for that already from my initial purchase 3 months ago.

Creating the cables

I had a ribbon jumper cable kit from adafruit and I had a bag of crimp terminals from a local electronics store (.205 size fits perfectly). What I was doing was cutting the jumper off one end, stripping about 2 cm, turning the exposed wire downwards, placing the terminal over the wire/exposed wire and crimping it together. Blammo! one Joystick switch -> pi GPIO cable created. repeat 13 times.IMG_1877

Once all the button cables were created I attached them to the Normal Open connector (NO) I already had the switches attached to a daisy chained ground cable I made months before and the jumper end to an open GPIO slot.

Setting up the OS

In my original box I was following an Adafruit tutorial that in the end gives you a retrogame.c file that gives you an easy way to map you controls to the GPIO, I continued with this program in this case as well. I had to add several more lines to the table since I was now supporting 6 play buttons and 1 more additional function button but the program is very straightforward to edit. I had to add KEY_SPACE,KEY_LEFTSHIFT,KEY_Z, KEY_X,KEY_ESC to the default table. I also had to make a small change to mame4all to remove the 1+coin escape workaround I had previously implemented.

What’s changed

  • Well the obvious is 6 play buttons now instead of 2 but I also added an Escape button instead of having to do coin + 1p.
  • No longer using Sanwa buttons, using the American style with the indented button.
  • The size has also been reduced considerably.
  • The pi is more secured into place instead of just dangling about as before.
  • The cut outs on the exterior are more matching to the ports being used (HDMI, power, SD card)
  • Not as much ugly tape is visible, a small bit of 2 sided can be seen holding the stick in place

The long term plan is still to eventually make a cabinet but for now this will be more than enough to do the job.

2013
12.05

A month ago I went to the open house for the Greater Niagara model railroad engineer’s to checkout what their club was about. I enjoyed the visit, they had a wonderful layout and I took lots of pictures and a couple videos. I decided to continue visiting the club and hopefully eventually become a member. So 1 month later I have been to 3 members nights and have run a few of their trains and it has been a lot of fun.

The layout itself is era’d between 1955 and 1965 so unfortunately it is not by default a layout Chessie would make sense, around a decade too early BUT I was still able to get permission after an operating session to run my trains for a bit. This sounded like the perfect first outing for my Atlas U30B. This is a DC model from the silver series and it is exceptionally detailed and it runs very smooth. I also decided to give my Bachmann GP7 a run with the U30B as it hasn’t ever seen anything but EZ track beneath its wheels.

The Fenwick Central is a DC layout broken into several blocks for 4 throttles, it is a very well designed block system and multiple trains are able to run simultaneously through proper communication and passing siding usage. Now you may recall from my original post about my GP7 that is a DCC and it is however Bachmann puts dual mode decoders into its engines so that it can run both! FYI the GP7 ran excellent as DC and it also paired very nicely with the Atlas there wasn’t any tugging or dragging once the engines were moving.

So I had the cats running on the layout and I did 2 full trips around which took around 10-15minutes. Below is a video featuring Fenwick Central trains at first then it ends with my Chessie System run.

Enjoy

direct link to video

2013
12.03

vCloud API in PHP

I manage several vCloud environments at the moment ranging from versions 1.5 to 5.1 right now (no 5.5’s yet) with permissions ranging from System Admin to Organization Admin. If you have ever managed a growing vCloud environment then you already know it is paramount to use some form of automation, scripts or even powershell to handle some of the very repetitive tasks you will be doing on a regular basis otherwise you will become overwhelmed by them.

What I have unfortunately noticed is that almost no one really talks about or documents anything beyond absolute basics so going forward I am going to share some of my tools on this blog starting with the basic and going all the way up to my OVF transfer and network1.5->network5.1 scripts.

Today we’ll start with an easy one.

lsorg

 #!/usr/bin/php
<?php
   /*
    * lsorg 0.2 by Phil Spencer 2013
    */
   $home = getenv('HOME');
   require_once $home . '/etc/config.php';

   // login
   $service = VMware_VCloud_SDK_Service::getService();
   $service->login($server, array('username'=>$user, 'password'=>$pswd), $httpConfig);

   // create an SDK Query object
   $sdkQuery = VMware_VCloud_SDK_Query::getInstance($service);

   $recsObj = $sdkQuery->queryReferences("organization",null);
   foreach($recsObj->getReference() as $orgRef) {
      echo $orgRef->get_name() . "\n";
   }
   echo "\n";

   $service->logout();
?>

This is a simple CLI utility I wrote that dumps out the Organizations in whatever cloud I am using at the time. The config.php file is the same config.php that comes with the PHP SDK samples. I have just put all my cloud config.php files into one directory and switch between them depending on what cloud I am accessing at the time.

As you can see in this case I create a VMware_VCloud_SDK_Query object then request all the organization records my permissions allow me access to with queryReferences(“organization”,null). If I were to replace null with search terms or a specific name I would get the record for just the Organizations that matched. Then with a foreach I loop through them and output the names. You might not see a reason for this script yet but when I am working with other scripts that require an Organization name sometimes it is easier to have the list in front of me to copy/paste quickly.

I also have this script in my /usr/bin folder for easy access, a quick lsorg on the command line and away I go.

So as I said, an easy one but there will be more to follow.