Thursday 14 January 2016

My Payphone Runs Linux

For the 20th anniversary of the Movie “Hackers” [Jamie Zawinski], owner of DNA Lounge in San Francisco, threw an epic party – screening the movie, setting up skating ramps and all that jazz. One of the props he put up was an old payphone, but he didn’t have time to bring it alive. The one thing he didn’t want this phone to do was to be able to make calls. A couple of weeks later, he threw another party, this time screening “Tank Girl” instead. For this gathering he had enough time to put a Linux computer inside the old payphone. When the handset is picked up, it “dials” a number which brings up a voice mail system that announces the schedule of events and other interactive stuff. As usual, this project looked simple enough to start with, but turned out way more complicated than he anticipated. Thankfully for us, he broke down his build in to bite sized chunks to make it easy for us to follow what he did.

This build is a thing of beauty, so let’s drill down into what the project involved:

sewing-needles-making-connectionsKeypad

His plan was to connect wires from the payphone keypad to a USB numeric keyboard. These wires were soldered to the through hole via’s on the old payphone keypad PCB. Hooking up these wires to the USB keypad required drilling 0.5mm holes spaced 1mm apart using his Dremel on a piece of acrylic, lots of sewing needles, super glue, Sugru and a couple of days to track down dodgy connections.

Handset

Working late at night, and without a TRRS jack handy, he chopped off an old cable and somehow managed to solder its ultra-thin wires to a pin header. A corresponding socket was soldered to the four wires from the headset for the speaker and the microphone. And lots of epoxy goop to hold it all together.

Computer

The Raspberry Pi 2 B doesn’t have an audio input, so he needed a Cirrus Logic audio hat for the Pi. He had trouble getting ALSA to tango with the Audio hat, so he eventually wrote some of his own code to detect keyboard buttons and play or record messages.

Hook switch

Finally, he needed to detect the hook switch status. Sounds simple, but it took him a few more days to get it to work. Turns out the audio hat was causing all unused GPIO pins to act “floating” no matter which way he tried. Finally, after trial and error, he bent one pin on the Pi so it wouldn’t connect to the audio hat, and wired the hook switch to it directly.

Software

His main code was in Perl. In the version of Raspbian he was using, reading pin states worked in Python, but not in Perl – they would always appear floating. Since the underlying BCM2835 library is written in C, he tried writing his code in C, and that didn’t work either. As usual, python was doing its magic under the hood. So he called the Python script from his Perl code to do that, but not before running everything under “root” since that was the only way he could read the status of the pins. Take a closer look by reading section 3 of his blog post, which includes a link to the code.

He had thoughts on adding more features, but having got this much working, he decided to wrap it all up before things headed south. We think there’s more than enough accomplished here for him to be proud of. If you need some introduction to [jwz] as he is known, he’s the guy who worked on emacs, Netscape and Mozilla and has been hacking away since 1985.

Thanks [dr Memals] for sending in this tip.


Filed under: phone hacks, Raspberry Pi

from raspberry pi – Hackaday http://ift.tt/1Q90mj3
via Hack a Day

No comments:

Post a Comment

Amazon

Donate

Donate Towards More Raspberry PI's for Projects