Adding SATA 3 Support to a Mac Pro

Caveat: be careful with your expensive, delicate computer. This has all the characteristics of a hack, but it was wildly successful for me. There may also be a much more sensible way of doing this out there. YMMV.

I have a mid 2010 spec Mac Pro, with the 6 core Westmere chip. I’ve been running out of disk space for about half of the elapsed time since I upgraded to a SATA 2 SSD about 3 years ago. Amazon are doing a pretty good deal on a Samsung SATA 3 SSD at the moment so I thought I’d take a punt on upgrading.

The long and short of it is that I’ve hacked together a pretty cheap option, which has given me a 13x speed up on sustained write speeds.

I went for this card [which appears to have risen in price by a couple of quid since last week], on the basis of seeing a reference to a particular chipset [ASM1061] on a forum somewhere along the line.

I have to admit straight off the bat that I’d never worked with PCIE before, and it took me a while to work out that the card was missing a power supply. This led me on a merry dance to figure out how to get power into my SSD. There are a couple of raised interfaces on the card which may be power outlets, but I’ve never seen anything like them before. Having looked at a tutorial on how to install a USB 3 device, I thought I was going to end up having to take the fan out, and get some sort of MOLEX to Mac 4 pin style power adapter cable. Having then hit on the fact that your stock Mac Pro [of my era at least] comes fitted with a single occupied bay of 4 designed for hard drives with SATA [2] interfaces, I bought one of these. Here’s the really hacky bit: the extender cable comes with a couple of clips either side to stabilise the connection. You have to clip one of them off, and plug it into the SATA interface of your choice.

And it works. And it’s bootable [a gotcha for some PCIE cards], and it handles resurrection from sleep. I verified that it was registered as a SATA 3 [look for the negotiated link speed of 6 Gb/sec] and used BlackMagic Disk Speed Test to verify a sustained write speed of 354 Mb/sec.

While there are integrated cards that you slot your SSD straight into, this turned out to be cheaper. That said, the new SSD is currently sitting loose inside the machine. There are integrated ‘sleds’ that you can screw the SSD into, and then slide into one of the four disk bays. I haven’t seen one that’s less than about £20. I also haven’t experimented with any of the 3 spare interfaces [2 of which are external] on the card: I’ve no idea if you can RAID up two SSDs on the same card, for instance. I’d be interested to find out!

Setting GPS Data in UIImagePickerControllerMediaMetadata With iOS 8

I’ve been doing some housekeeping on one of the apps I have in the App Store, and I noticed that the image picker was broken when I tested it on the GM version of iOS 8. It took me a while to track it down and, because I couldn’t see the solution on StackOverflow, I thought I’d do a quick posting here.

So the background to this is if you want to add something into the UIImagePickerControllerMediaMetadata dictionary after you have taken a picture, and the classic example is saving back GPS data.

The long and short of it is that you can no longer assign  UIImagePickerControllerMediaMetadata straight to a NSMutableDictionary. My code originally looked like this:

NSMutableDictionary *tmpMetadataDic = [info objectForKey:UIImagePickerControllerMediaMetadata];

which, if I called it, threw an error like this:

[__NSDictionaryI setObject:forKey:] unrecognized selector sent to instance....

The clue is that reference to NSDictionaryI, which means that you’re trying to set something in a non mutable dictionary.

So doing something like this works:

NSDictionary *nonMutytmpMetadataDic = [info objectForKey:UIImagePickerControllerMediaMetadata];    
NSMutableDictionary *tmpMetadataDic = [[NSMutableDictionary alloc] initWithDictionary:nonMutytmpMetadataDic];

 

Arduino Based PIR Motion Sensor with iOS Push Notification

We’ve been having some problems with our cat staying out late over the last few weeks, and expecting to be able to summon us at the back door. As I’m not keen on standing guard waiting for him, I’ve decided to revert to type and build a solution around one of my Arduino boards.

I’ve used various bits of example code, and it’s all working. First the hardware, which is a real thing of beauty(!)

PIR Sensor

PIR Sensor

So we have a PIR sensor in a yoghurt pot. I’ve enclosed the sensor in a tube to try to make it more directional. The sketch I’ve used is from the Arduino Playground. The only change I’ve made is to comment out every Serial.Print[ln] command, except for the one that identifies the end of the motion detection period.

Next, on the Raspberry Pi, I installed this variant of the standard serial port library for Perl.  I’ve used the example script to make a call to curl, using the system(“curl….”); command.

Next comes the slightly trickier part. I did a bit of a trawl around yesterday to see if there were any nice push notification services. This is a pretty complicated sport, but long and short of it is that I went for a free option from an organisation call PushApps, who have detailed instructions on how to set yourself up with the various certificate options on the Apple Developer Portal, and then how to integrate the actual code into your app. I just went for a very rough and ready single view app for now. It’s not doing anything other than displaying the remote notification.

The actual process of integrating the notification functionality into an app is very straightforward.

That said, there are two moderately tricky parts to this. The first is to make sure that you configure Xcode to pick up the right ‘provisioning profile’ that you have to go through in the instructions.

The second is – well, actually pretty straightforward with the benefit of hindsight, but it took me a while to translate the example provided in the documentation in PHP into something I could use – via curl. It’s a call to PushApps’ JSON interface, which brings us back to the perl script. When I read a string from the serial port equating to a motion detection event I call:

curl -H “Content-Type: application/json” -d ‘{“SecretToken”:”your-secret-token-here”, “Message”:”short message to be displayed”}’ https://ws.pushapps.mobi/RemoteAPI/CreateNotification

which, lo and behold, will send a push notification event. The example code takes care of the registering of the phone [well, the app installed on the phone] to pick up the notification.

I’ve left the curl command unescaped for readability purposes. When you put it inside the system() command, you have to escape all of the double quotes with a backslash.

if this doesn’t work, there’s nothing for it, the cat will have to go 🙂

I initially tried making the call using the web client on the Arduino WiFi shield. You can’t: there’s no support for TLS.