By Collin Allen

Simulating Slow Internet for iOS Testing

May 12, 2011

Apple’s iOS Simulator is an acceptable environment for testing development code, but when users purchase your finished app from the App Store, they’ll be running it on real hardware, particularly on networks that are likely much less reliable than your home or office internet.

To ensure your app performs well under real-world conditions, you can load up the code on a device and go outside, but then you can’t debug as easily. And even if you bring your MacBook Air with you, what if your Verizon iPhone is everything you hoped, and it performs admirably on the worst of days? To get around all of this, you can approximate an unreliable network with SpeedLimit. SpeedLimit is a System Preferences pane for intentionally and selectively slowing down specific ports and domains.

speedlimit window

Download and install SpeedLimit, add one or more hosts (separated by commas, as seen above), select a target speed, and click Slow Down. Subsequent network requests matching the criteria you set will be throttled, giving you time to go all out testing your app’s performance and error handling. Does it crash when users hit the Back button while a UITableView is loading? Does it lock the UI while downloading avatars or thumbnails? SpeedLimit lets you find out, and be confident in your networking code.

How to Find the Right Windows Driver

September 14, 2009

When setting up a new Windows machine, whether it’s Windows 2000 all the way up through Windows 7, you’ll occasionally run into an issue where you need drivers for a system or PCI device that you just can’t seem to find. To make matters worse, you don’t know which company made the device, so you don’t even know where to start looking for drivers. Should you go to Dell’s site? The motherboard manufacturer? Persistent “Unknown device” entries in the Windows Device Manager are a plague upon even the most seasoned techs. Here’s a tip to get your driver hunt moving in the right direction.

Find Out Who Made the Device

Figuring out which company made the device(s) in question is the first step towards getting it working. Start by opening the Windows Device Manager. My preferred quick way of doing this is clicking Start, Run, type devmgmt.msc, and pressing Enter. Once there, choose the device in question and right click it, and select Properties. Select the Details tab to see something like the view below:

windows device manager

Note the PCI VEN and DEV 4-character identifiers. PCI, USB, and many other system devices have Vendor and Device IDs. The Vendor ID is specific to the manufacturer, like Broadcom or nVIDIA. The Device ID is specific to the particular make or model of device you have. These are expressed in hexadecimal (0 through 9 plus A through F), so don’t be surprised to see letters there, as well. Some common Vendor IDs are 8080 and 8086 for Intel, 0A5C for Broadcom, 10DE for nVIDIA, 1002 for ATI, and many more.

Look Up Vendor and Device IDs

A common way to express both the Vendor and Device IDs in a single string is 1022:2000, Vendor ID first. Combine your Vendor and Device IDs in this manner, and wrap it with quotes: “1022:2000”. Google that, and you should quickly figure out who made your “Unknown device” and what model it is. With this knowledge, you can either find the appropriate driver on your computer manufacturer’s website (Dell makes a good note of which manufacturer’s devices they use for a particular system), or you can visit the device manufacturer’s website directly.

I hope this information can help those looking to simply get their hardware working under Windows, whether it’s running on a Mac or PC.

MacAlly IceKey USB 2.0

July 5, 2009

MacAlly has been producing the same IceKey keyboard since 2003, and while it’s a solid performer featuring comfortable low profile scissor keys and extra USB ports, it still ships with a maddeningly slow internal USB 1.1 hub. While this early USB specification is plenty fast for a keyboard alone, it throttles back speeds of all attached devices like flash drives, iPods, and digital cameras. Copying an music album or two can take several minutes over USB 1.1, whereas today’s USB 2.0 takes only seconds. With USB 2.0 as today’s ubiquitous standard and USB 3.0 just around the corner, it’s disappointing that MacAlly has yet to update the IceKey to include a faster hub. Luckily, you can take matters into your own hands. Here’s how to install a high speed hub inside the keyboard while maintaining MacAlly’s elegant factory appearance.

macally icekey keyboard

What You’ll Need

  • a MacAlly IceKey
  • a small, narrow USB hub (a cheap Targus hub worked fine for me)
  • a screwdriver set
  • a soldering iron, solder, and spare wire
  • a pocket knife (I’m not sure any project I’ve done didn’t require this…)

Open the Hub

USB hubs generally aren’t too complicated to open, and this Targus on is no exception. A single screw on the underside holds together the hub’s two plastic halves, which snap apart with little effort. Write a note or take a picture to document the wire colors and order relevant to the orientation of the board inside – it will come in handy later.

usb hub board

Open the Keyboard

The MacAlly IceKey is slightly trickier to get apart, but not much. Remove all the obvious screws on the bottom of the keyboard, including the one under the “Do Not Remove”/Quality Control/Warranty sticker. Then, flip open the pivoting feet to expose two more screws covered by a protective piece of rubber. The final two screws are under the front rubber feet.

Starting with the keyboard upright and facing you, begin unsnapping the plastic hooks around the perimeter starting at the front middle. A plastic pry tool might come in handy, but isn’t required. Once the top is removed, you can clearly see all the important electronics, including a very common Cypress USB controller chip.

keyboard controller

left port

Test Fit Everything

Just to make sure the rest of this modification is physically possible, fit the USB hub board in the open space at the top of the keyboard and set the keyboard bezel on top. Luckily, the IceKey has plenty of room to spare. I was planning to have to remove the USB ports from the hub board to make everything fit, but there was so much extra space that I didn’t even have to go to that length.

Unhook the Keyboard

Carefully pull the keyboard ribbon cables straight away from their matching plugs on the controller board. Gently flip the keyboard pad over, and unscrew the two short ground wires to completely free the keyboard keys from the plastic housing. Set it aside for later; it does not need to be modified – all the action happens on the two remaining circuit boards. Unscrew both boards to get at the backs of each.

ribbon cables

Cut Wires

Cut the gray ribbon that leads from the controller board to the left port. Since that wire only provides USB 1.1 speed, we won’t be using it. You’ll note that it has two extra wires that run to an unpopulated LED on the left board, so we can skip those when doing the re-wiring. (I wonder what MacAlly had in store for that, or if this keyboard is a “port” from another language or something?)

Unplug the USB cord from the controller board and cut off the connector. This cord needs to run to the input on the new USB hub, and not to the input on the keyboard controller board where it currently connects.

Cut Traces

Since the right port also needs USB 2.0 speeds, it too will need to be disconnected from its USB 1.1 source. However, it is soldered directly onto the controller board and is effectively hard-wired into the slowness. This is perhaps the trickiest part of the whole project: desolder the USB connector and use a knife to scrape away the traces that run to the port. Some are on top of the board, and some are on the bottom. (You might be able to get away with cutting the traces without removing the port, as a little bit of the traces are exposed on the top before routing into electronic components, but you’ll want to test with a multimeter and make sure you’ve done this successfully.) Once all four traces to the port are cut, re-solder the USB port in place (if you removed it).

cut traces

Re-wire the Keyboard Controller and Ports

Here’s a simple before and after block diagram to help your wiring layout:

wiring diagram

Solder Keyboard Cord to Hub Input

Strip about an inch of plastic from the cut end of the keyboard cord to expose its individual wires, and strip just a millimeter or two from each of those. Using your note from earlier, solder the keyboard wires to the matching USB hub input connections. On this Targus hub, the wires were in the same order as the standard USB pinout.

Solder Keyboard Controller to a Hub Port

Solder four wires from the keyboard input port (where the cord originally connected to) to one of the USB hub ports, effectively making the keyboard controller into one of four devices on the hub. Previously, the keyboard supplied its own hub, but we’re bypassing it altogether. Luckily, most everything is either color coded or silkscreen labeled on the circuit boards (V/5V is red, D- is green, D+ is white, and G/GND is black).

Solder Keyboard USB Ports to Hub Ports

Solder wire from the left USB port board to another free USB hub port, making sure to get the order correct. With the traces cut on the right port, run wire from the connections under the board to yet another free hub port. You should end up with a hub layout like this:

hub wires

Test and Close It Up

With each new component wired up, double-check your connections and plug it in. Initially, my first test failed and Windows complained about a malfunctioning USB device (I tested it on an old PC, just in case I shorted out the computer’s USB controller. I’d rather fry an old computer than my new iMac!) The key to making everything work properly was to reconnect those two shared ground wires from early on – the keyboard must have a common ground with the controller and hub!

completed wiring

Once it works, secure all the wires and boards. I used a few short pieces of electrical tape to stop everything from bouncing around, too. Snap the plastic top back on, replace all the screws, and enjoy your USB 2.0 MacAlly IceKey!

Boot Camp Drivers for iMac (Early 2009)

June 14, 2009

Apple’s newest iMacs are a fast set of machines and run Windows faster than any PC I’ve ever used, but unfortunately, Apple has yet to update Boot Camp with the required drivers to support the latest and greatest components. Mac OS X ships with the necessary software and works as expected, but Windows XP is met with some trouble. Right away, you’ll notice that your graphics resolution is set to a paltry 800x600, and you have no sound output as well. Here’s how to get those systems working until Apple can provide an “official” fix:

Graphics Drivers

Visit nVidia and download the “GeForce 9M Series (Notebooks)” driver package, as this is graphics chipset in the Early 2009 iMacs. Run the downloaded setup utility, next-next-nexting your way through the steps, and reboot at the end when prompted. Upon restart, you’ll be able to properly max out your display to the iMac’s native resolution.

Audio Drivers

Boot Camp 2.1 actually ships with RealTek HD audio drivers, as evidenced by the lack of a yellow exclamation mark for this system in Windows’ Device Manager, but they don’t seem to work properly, since there’s no sound output. Visit RealTek and download the “High Definition Audio Codecs” driver package for your OS. In this instance, I downloaded “Windows 2000, Windows XP/2003(32/64 bits) Driver only (Executable file)”, since I’m running Windows XP Pro SP2. Run this setup utility as well, rebooting again when done. After restarting, you should be greeted with Windows’ standard login sound, confirming the install worked.

Update: The Mac OS X 10.6 Snow Leopard disc includes Boot Camp drivers for these iMacs. The Snow Leopard disc is a hybrid image: it provides the Mac OS X installer when viewed under a Mac OS X system, but shows Windows drivers when viewed in Windows. Just run the setup in Windows right off the disc, and you should be set.

Dig into iPhone Apps

March 22, 2009

So you’re curious about the contents of iPhone and iPod Touch apps, including artwork, sounds, and more? Here’s how to dig into an application and see what goodies are hidden inside. Standard copyrights still apply.

Sync Your Apps with iTunes

Assuming you already have the target application on your iPhone or iPod Touch (just “iPhone” from this point forward for brevity’s sake), simply sync your iPhone with your Mac or PC. Doing so will backup your device and transfer any purchased applications in both directions. With the target application now on your computer, navigate to your iTunes “Mobile Applications” folder, where iTunes typically does its own file housekeeping. Under Mac OS X, the default location is /Users/yourname/Music/iTunes/Mobile Applications/.

Unzip an App

Copy your target .ipa-suffixed application to a different location, ensuring that the original stays in the Mobile Applications folder to keep iTunes happy. To get inside the application, rename its extension to .zip. Open the zip file, and you will have access to the guts of the app (except the source code, of course).

High-res App Artwork

Directly inside the unzipped application folder, you’ll find a file named iTunesArtwork, with no extension. A hex editor revealed that the file is typically a jpeg image, so rename it to include .jpg at the end, and you’ll end up with the same 512x512 pixel artwork displayed by iTunes when browsing downloaded Applications. To get at other resources, open up the adjacent “Payload” folder, and you’ll find a .app file – the application bundle that runs on the iPhone. Right- or Control-click on the .app, and choose “Show Package Contents” to open up the bundle.

Sounds

Sounds are typically found among the many resources directly inside the application as files with extensions like .caf, .mp3, .aif, and .m4a. At this point, the organizational structure is up to the application’s developer, so you may need to look around a little. Leopard’s QuickLook feature is a boon in times like this, helping assess a file’s purpose without opening half a dozen applications.

Other Graphics

Also nestled inside iPhone applications are many of the graphics used throughout the app. It’s possible that some may be drawn by code, but complex graphics are generally stored as images. However, viewing the images isn’t as easy as renaming the files as before. This will be a bit trickier, as the iPhone works some magic on the images before finishing the app build process, leaving images in an iPhone-optimized state. Fortunately, the process can be reversed with a little bit of Terminal trickery:

  1. Copy all .png images to a new folder elsewhere. Images of other formats (.jpg, .gif, etc.) should be readily viewable.
  2. Download David Watanabe’s modified iPhonePNG command-line application, unzip the archive, and open up Terminal from your /Applications/Utilities folder.
  3. Type cd , then drop the iPhonePNG folder into the Terminal, and tap Return to switch to that folder.
  4. Type ./iPhonePNG , drop the folder of encoded images into the Terminal, and tap Return to decode the whole folder full of images.
  5. The output folder sites beside iPhonePNG, so type open . and tap Return (open space dot) to open the current folder (a dot, in Unix terms) in the Finder. Open the decoded images folder and have a look around!
Mastodon