2014
01.08

popey had asked me for some more details a couple weeks ago regarding my Arcade console so here we are. I am going to post the GPIO layout similar to what I did with the old Arcade box and I will also post the changes I made to retrogame.c which takes the GPIO inputs and converts them to MAME keyboard input.

GPIO layout

Similar to last time here is a standard Pi GPIO layout, the old controller layout and my current controllers layout. I matched most of the buttons wiring to their actual colour with a purple ground cable, green for the joystick wiring and the black buttons have brown wires.

Notice that I only used one ground this time, I daisy chained the ground cable between all the buttons. This wasn’t possible last time because each button cable had a single wide jumper that straddled 2 pins so it needed to be laid out in a manner that was always next to a GND and that was limiting in my original design. In this new layout I still have 2 free GPIO pins I could use if needed.

retrogame.c

This file was provided by a tutorial on Adafruit and that is where the original box started with me doing their tutorial (with some slight improvements). For the new box it had to be expanded to cover all the buttons I was using and I am quite happy to report the Pi has no issue with rapid simultaneous input that can come from playing something like Street Fighter 2. Also, on my original post I said I had added an escape button but instead I went back to Coin + P1 for escape and made the additional side button into a pause. It has worked out significantly better this way.

The input table:

#define GND -1
struct {
        int pin;
        int key;
} io[] = {
//        Input    Output (from /usr/include/linux/input.h)
        { 8 ,      KEY_LEFT     },
        { 27,      KEY_RIGHT    },
        { 7 ,      KEY_UP       },
        { 25,      KEY_DOWN     },
        { 11,      KEY_LEFTCTRL },
        {  9,      KEY_LEFTALT  },
        { 24,      KEY_5        },
        { 18,      KEY_1        },
        { 10,      KEY_SPACE    },
        { 22,      KEY_LEFTSHIFT},
        { 2 ,      KEY_Z        },
        { 3 ,      KEY_X        },
        { 23,      KEY_P        }
};
#define IOLEN (sizeof(io) / sizeof(io[0])) // io[] table size

Simple stuff, { Pin # on the GPIO board, Key_Definition } (Thanks Adafruit!)

The full file can be viewed here: retrogame.c

The compiled file is run in the background on boot and takes the input on those pins and sends them as the specified key.

If there is any other aspect of the machine you want details on feel free to leave comment, most of the OS stuff was covered in the old consoles post. I used the same flash card for this one so it isn’t any different unless specified in the new consoles post or this one. 

 

2014
01.07

I sure hope no one out there actually buys ringtones on iOS as the process to create them is so simple and available to any Mac owner.

Here’s the basic rundown if you are unaware:

  • Open GarageBand
  • Select ringtones for the new project, then it will give you some more sub options
  • Pick voice
  • You will get a blank project with 2 empty instruments “Male Voice” “Female Voice”
  • From iTunes, find your favourite song or from your computer your favourite sound clip and drag it onto the project
  • drag the Yellow loop bar ontop of the project to the part of the song or clip that you want or cut/paste the part you want into the loop area (keep the loop area under 40 seconds)
  • Menu: Share -> iTunes as Ringtone

Blammo!

Yea, it’s always been that easy and GarageBand will take any supported sound file into it, midi, wav, mp3, AAC so the skies the limit

Here’s one I made a year and a half ago and 3 more I made today for kicks:

1.5 years ago:

Darkworld

Today:

7 days plus 1 week

Probe – 2 – Nacka

Hells March remix

 

2014
01.06

I have been working with vCloud over 3 years now and directly administering several 1.5 and 5.1 cloud instances for over 2.5 years. Anyone who has worked with a scaling vCloud knows that you may run into some form of an issue revolving around networking at some point or another. The most consistent issue I ran into in my 1.5 vClouds was when under load if several vApps were undeploying sometimes the portgroups in vCenter would not get cleaned up. The main culprit of that was most likely vShield which in the vCloud 1.5 era was limited to 32bit and could quite easily run into memory issues.

So to the point, as my clouds scaled I found myself starting to spend more and more time cleaning these portgroups up manually which wasn’t complicated once you figured it out but it was time consuming.

The basic process was:

  •   Go to stranded items in the system admin pane on vCloud
  •   Select all the portgroup items there (they would appear as something like dvs-networkname-unique-hash)
  •   Try to delete them
  •   Watch the vCenter activity pane simultaneously and watch for errors
  •   When it erred click the error to be brought to the portgroup (sometimes the stranded portgroups will remove them self cleanly)

Clean up what’s left in 1 of 2 ways:

  • If all the was there was a vShield EDGE VM (prefixed with VSE) power off and delete from disk (you can delete it because the standard deployment process of vCloud is to create a new one from template)
  • If there were several VM’s disconnect the nics and reconnect them from the vCloud interface (which was time consuming)

So, the latter is the one I dealt with as it was more tedious. What I did was with the vCloud API is create a script that finds the vApp name with the issue, goes through each VM and disconnects and reconnects the VMs. This has saved me hours and hours of work because while the portgroup issue may not happen often it happened enough to be noticeable.

Here is the script below:

#!/usr/bin/php
<?php 
   if ($argc < 2) {
      echo "Usage: resetnics <orgname> <vapp>\n";
      exit(1);
   }

   $orgName = $argv[1];
   $vAppName = $argv[2];

   $home = getenv('HOME');
   require_once $home . '/etc/config.php';

   // Initialize Global parameters
   $httpConfig = array('ssl_verify_peer'=>false, 'ssl_verify_host'=>false);

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

   $orgRefs = $service->getOrgRefs($orgName);

   if (!empty($orgRefs))
   {  
      foreach ($orgRefs as $ref)
      {
         echo $ref->get_name() . ":\n";
         $sdkOrg   = $service->createSDKObj($ref);
         $vdcRefs  = $sdkOrg->getVdcRefs();
         $sdkVdc   = $service->createSDKObj($vdcRefs[0]); //our cloud only has one vDC per ORG currently, can cheat here
         $vAppRefs = $sdkVdc->getVAppRefs($vAppName);
         if(!empty($vAppRefs))
         {
            foreach ( $vAppRefs as $vARefs ) {
               echo "vApp " . $vARefs->get_name() . "\n"; 
               $sdkvApp = $service->createSDKObj($vARefs);
               $status = $sdkvApp->getStatus();
               $vmRefs = $sdkvApp->getContainedVmRefs();
               if(!empty($vmRefs)) {
                  foreach ($vmRefs as $vRefs) {
                     $sdkvm = $service->createSDKObj($vRefs);
                     $status = $sdkvm->getStatus();
                     //Disconnect NICS
                     echo $vRefs->get_name() . " Disconnecting NICS...\n";
                     $nics = $sdkvm->getVirtualNetworkCards();
                     $nics_rasd = $nics->getItem();
                     $updatedNics = new VMware_VCloud_API_RasdItemsListType();
                     foreach($nics_rasd as $nic_rasd) {
                        $nic_value = $nic_rasd->getAutomaticAllocation();
                        if($nic_value->get_valueOf() == "true") {
                           $nic_value->set_valueOf("false");
                           $nic_rasd->setAutomaticAllocation($nic_value);
                        }
                        $updatedNics->addItem($nic_rasd);
                     }
                     $task = $sdkvm->modifyVirtualNetworkCards($updatedNics);
                     $service->waitForTask($task);
                     //Reconnect Nics
                     echo $vRefs->get_name() . " Reconnecting NICS...\n";
                     $nics = $sdkvm->getVirtualNetworkCards();
                     $nics_rasd = $nics->getItem();
                     $updatedNics = new VMware_VCloud_API_RasdItemsListType();
                     foreach($nics_rasd as $nic_rasd) {
                        $nic_value = $nic_rasd->getAutomaticAllocation();
                        if($nic_value->get_valueOf() == "false") {
                           $nic_value->set_valueOf("true");
                           $nic_rasd->setAutomaticAllocation($nic_value);
                        }
                        $updatedNics->addItem($nic_rasd);
                     }
                     $task = $sdkvm->modifyVirtualNetworkCards($updatedNics); //restore original.
                     $service->waitForTask($task);
                  }
               }
            }
         }
      }
   }
   echo "\n";
   $service->logout();
?>

What this script does is with the supplied Organization and vApp name it will scan through the vApp inventory of that Organization until it is found. Once the vApp is found it will cycle through the VMs of that vApp and look through the OVF RASD Items List for a specific value unique to being a NIC. Once a NIC was identified, update it to disconnected but continue checking that VM for NICs and update them as well. Once all the NICs have been modified to disconnect on that VM apply the change back to vCloud and wait until completed. After completion reverse the change and apply and wait again. This leaves the vApp networking intact, no need to worry about the IP settings of the VMs, just disconnect-> reconnect-> complete. After this script has completed and finished with the vApp the next time the user tries to start the vApp or the next time you try to delete the stranded item it should clear without fault.

Now you may notice I don’t use the query service here, this is one of my older scripts before I had learned the query service however I do frequently still use this manner because it’s easy to quickly grab one of my existing scripts and add new functionality to it in a short manner of time. Usually I’ll only switch to query service if time is a significant issue with what the script is doing.

2014
01.02

IMG_1965

So I have been visiting a model railroading club the last several weeks and it has been a lot of fun, you need to do 8 meetings, 2 of them business related before you can become a member to the club officially. Once a member you then start paying membership and you are required to donate 1 type of rolling stock in the correct period to the layout. At the hobby store a few weeks back I saw a beautiful Canadian Pacific box car in the right period with a neat pine logo and in a very sharp green paint job, this caught my attention because the 1950-60’s wasn’t a very colourful time period for North American railroading but it was just before Christmas and I wasn’t going to buy something for myself so I passed on the opportunity. I went to the hobby store again after Christmas however and the box car was still there so of course I picked it up.

Now another requirement is that the donation be fitted with Kadee couplers so that the uncoupling magnets installed on the layout work and there are no general issues with trains and their cars. Most couplers are Kadee compatible which means they’ll link up just fine but a lot of these couplers that come with rolling stock by default are mostly plastic and can have issues with the magnets so I decided since I had some official Kadee’s left that I would just install them.

IMG_1969

So to get to the coupler box the trucks need to be removed and for sanity sake so you don’t damage any of the details you can also take off the shell. Once the trucks are off it is just a matter of unscrewing the small screw and the coupler box and coupler easily come out. Now once the coupler is removed you can install the the Kadee brass spring box and place the coupler on top. This can be tricky, it’s all tiny and loose in this manner so be careful. Then place the screw back in and tighten it to the base of the car, not all the way as that will stop movement, but enough to hold it in place straight and to allow you to flick the knuckle and have it spring back at you. Once installed I put the trucks and body back on and in under 10 minutes I’ve converted this car to Kadee.

Now you should make sure everything lines up with a coupler gauge, this makes sure your coupler is the right height and it has a lip that shows you if it hangs too low. In my case, it lined up just right but I had a diesel that needed some work in this regard.