iCurlHTTP – cURL for iPhone and iPad

iCurlHTTP

HTTP Server Response Diagnostic Tool

I love cURL.  Systems engineers, developers, administrators, QA engineers and web operations specialist everywhere have used the curl tool to help troubleshoot web server responses.  It gives a quick view into exactly what is being sent from a web server to a browser.

On a commute home from work I started to think how handy it would be if the small computer I was holding, my iPhone, had a simple to use app like curl to do the same troubleshooting.  I always wanted to write my own iPhone app so I started researching how I could do that.

My Xcode Adventure

I fired up Xcode on my Snow Leopard equipped MacBook Pro for the first time.  I found a few great iOS development books on SafariOnline and started learning Objective-C.  After a few chapters I started going off the page and adding views and controllers.  I wanted to deploy my test apps to my iPhone so that required that I sign up as an Apple Developer (and $100!).  I soon discovered that my Xcode version was too out of date to work with my iOS 6.1 devices so I attempted to upgrade, only to discover that I needed to upgrade my OS.   Now on to Xcode 4.6 and suddenly my projects were running on my iPhone and iPad.

My libcurl Adventure

I discovered the NSURL class and started trying to get raw responses from web servers to display to the textview.  It was too digested and would require a lot of effort to simulate a raw curl session.  I started looking at the NSStream class when a friend suggested that I investigate a precompiled version of libcurl (the cURL library from Daniel Stenberg) for the ARM processor.  Instead, I found a great post by Nick Zitzmann where he shows how he compiled libcurl and even provides a binary: http://seiryu.home.comcast.net/~seiryu/libcurl-ios.html

I managed to get the latest version of libcurl to compile and also included the Apple SecureTransport library (–with-darwinsll in libcurl config):

#!/bin/bash
cd curl-7.29.0
export IPHONEOS_DEPLOYMENT_TARGET="4.3"
export CC="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2"
export CFLAGS="-arch armv7 -arch armv7s -pipe -Os -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk"
export LDFLAGS="-arch armv7 -arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk"
./configure --disable-shared --enable-static --with-darwinssl --disable-dependency-tracking --host="armv7-apple-darwin" --prefix=~/Code/curl/device
make -j `sysctl -n hw.logicalcpu_max`
make install

I added the libcurl.a library to my Xcode project and started using the easy interface API via CURLcode curl_easy_perform(CURL * handle ). The realtime feel of iCurlHTTP comes from the use of the CURLOPT_WRITEFUNCTION option to push realtime code into a view controller method that renders to the textview object. It required  periodically having the thread give up time to the mainRunLoop (via message to NSRunLoop) in order to allow the display to render and respond to user events.

iCurlHTTP v1.0 Born

iCurlHTTP was born.  It was a simple, easy to use iOS app that allowed you to run simple cURL like tests, simulating different web browsers to retrive the raw HTTP headers and HTML response from the web servers.

icurlhttp-v1.0

OpenSSL Anyone?  iCurlHTTP v1.1

The SecureTransport library works great but provided less details on SSL connections than what I was accustomed to seeing with curl.  I wanted more x509 decoded information, specifcially SSL certificate details about expiration date.  The OpenSSL library would allow for this so I began another search to get  OpenSSL library for ARM7.  To get what I wanted, I cross-compiled both OpenSSL and libcurl together. With that I was able to get the great openssl detail in the output, including cert info:

icurlhttp-cert

I managed to cross compile libcurl and openssl separately for armv7, armv7s and i386 architectures but later found a great GitHub project script created by Miyabi Kazamatsuri that does both.  I forked his code and updated it to work with Xcode 5 (clang for iPhoneOS and iPhoneSimulator) and added the 64-bit arm64 and x86_64 architectures.  The script is available on my GitHub:  https://github.com/jasonacox/cURL-SSL-for-iOS

UPDATE: I later put together a much better build script for openssl+libcurl that creates libraries for Mac, iOS and tvOS (Apple TV) targets: https://github.com/jasonacox/Build-OpenSSL-cURL

HTTP Timing and iOS 7 support added to iCurlHTTP v1.2

Curl has the ability to provide timing data for DNS lookup, TCP Connect, SSL Handshake, First Byte and Total time.  For example…

curl -k -s -o /dev/null -w '%{time_namelookup} %{time_connect} %{time_appconnect} %{time_pretransfer} %{time_redirect} %{time_starttransfer} %{time_total}n' https://jasonacox.com

I wanted to add this to iCurlHTTP to give a mobile perspective on these numbers.  In v1.2, I added this in the detail response view and as timing data points listed along the bottom of the UI.

icurlhttp-timing3

The v1.2 version also includes the iOS 7 SDK updates and the new minimalist UI look and feel.

iCurlHTTP 1.3 Wish List 

Thanks to great feedback, I captured several feature requests from the iCurlHTTP user base that became the goal for version 1.3:

  1. Custom Headers – Allow more and customized browser emulations via a customized option.
  2. Print, Copy or Email Output – Add a one-button feature to send the output to the clipboard, printer, email, post, etc.
  3. Customized Post – Allow customized post data to simulate a POST form submit.

This meant I needed to be able to have a User Settings pop-up screen to allow users to enter custom fields for headers and posts.  I also wanted to allow the ability to have a custom user-agent, http authentication (user/password), SSL options and possibly others in the future.

I knew I wanted a table based form to allow for formatting, scrolling and auto-positioning.  I considered using the Settings bundle but I needed multi-line UITextView input (especially for custom headers).  There are several great open source solutions  but my favorite version was FXForms, written by Nick Lockwood  (https://github.com/jasonacox/FXForms).  I used a simple plist for settings persistence.

icurlhttp-settings

The following features are added in version 1.3:

  • Share Feature – Send output to Clipboard, Printer and Email
  • User Settings – Set Custom User-Agent, Custom Headers (replace defaults or add new ones), POST Data, Authentication and SSL Mode selection
  • Updates – New libcurl and openssl libraries.

iCurlHTTP 1.4 Enhanced History

The goal of the 1.4 update was to enhance the URL dropdown history by adding HEADER and POST data for easy repeated testing.  I used simple (h) and (p) symbols to denote header and post respectively:

Screen Shot 2016-03-05 at 8.53.39 AM

iCurlHTTP 1.5 Redirect

I had several requests to add a “follow redirect” features (similar to curl -L command) to make it easier for users to test.  I didn’t want this to be purely  automatic because it would defeat the purpose of the granular detail that cURL provides so I present the user with a popup dialog when a 301 or 302 redirect response is received and list the redirection URL they can follow.  In this version, I also replace the ugly text “User” (settings) and “Share” buttons with the well known icons to help make it more intuitive.

Screen Shot 2016-03-05 at 9.30.53 AM

I’m amazed at how this small and simple project continues to grow (both in users as well as feature requests).  It has been a fun adventure! I frequently recommend other try building their own apps.  iCurlHTTP is written in Objective-C but I would definitely recommend trying out Swift.  I’m in the process of porting iCurlHTTP to the Apple TV (seems ridiculous, I know but I have to do it just for fun) and hope to try my hand at Swift.

iCurlHTTP 1.6 & 1.7 – HTTP/2.0 and IPv6 Update

For those wanting the libcurl, openssl and nghttp2 (HTTP2) libraries for iOS or tvOS (AppleTV), I have posted a build script on github: https://github.com/jasonacox/Build-OpenSSL-cURL

Thanks to request from users, I added the following features:

  • Certificate Chain Details for HTTPS Sessions (Detail Mode)
  • Support for Authentication Credentials in URL (e.g. https://user:pass@jasonacox.com/gettest.php)
  • DNS Resolve Spoof Option for Manual Address Resolution (eg. HOST:PORT:ADDRESS)

iCurlHTTP 1.8 & 1.9 – Performance Improvements

  • Performance Improvements and Reported Bug Fixes
  • Added user defined DNS lookup & connection timeout setting (default 5s)

THANK YOU!

Thanks for your great feedback and support!  I really appreciate the kind words and critical advice.  Please send more!

iCurlHTTP Website:  www.jasonacox.com/icurlhttp

Download on the App Store

 

Reference and Thanks!

 

Yamaha Clavinova CLP-440

I wanted a music workstation synthesizer and my wife wanted a real acoustic piano that looks like beautiful furniture.  We compromised by getting the Yamaha Clavinova CLP-440.  It looks, sounds and feels like a real piano with enough tech (MIDI, USB, voices) to make a armchair techy musician like me happy.  The PDF documentation covers most of the details you will need to start using the nice features, but there are a few things lacking so I’ll record some of my discoveries in this post.

USB Files

The piano has a USB port that will easily accommodate a thumb drive or external hard drive.  It stores and reads MIDI and WAV files.

Files created by the Clavinova will be stored in the “User Files” folder with a name USERSONG??.MID for MIDI files and USERAUDIO??.WAV for Audio files saved from the Clavinova.  The ?? is the number of the song selected from the Clavinova LED interface.  Here is an example listing of files on the USB drive:

USB Host with iPad

I wanted to be able to use my iPad to link to the piano for added voices and sequencing.  There are several MIDI options available for the iPad, but since the CLP-440 has a USB host port, I was able to use an iPad camera kit (essentially an adapter to allow the iPad to view pictures from a SD card or USB camera).   The Apple version and third party version should work fine.  Using that, I found that several apps could see and control the CLP-440.

iPad Apps for the CLP-440

Searching the Apple iTunes store for app to work with the Clavinova wasn’t easy.  I’ll record a few good apps that I found.

GarageBand
http://itunes.apple.com/us/app/garageband/id408709785?mt=8 – This $5 app from Apple is amazing on its own but it works great with MIDI from the Clavinova.

Midi Monitor
http://iosmidi.com/apps/midi-monitor/ – This app shows the iPad connecting to the Clavinova and the events coming from the keyboard (as well as driving action back to the keyboard through the iPad interface).  Useful for troubleshooting.

Alchemy mobile Synth App
http://www.camelaudio.com/AlchemyMobile.php – This great app from CamelAudio adds a great selection of synth voices to be controlled by the Clavinova.  As their site says, “Turn your iPhone/iPad into a powerful synthesizer! Alchemy Mobile includes everything from evolving soundscapes and fat basses to lush pads and pulsing arpeggios, and is available for free from the iTunes App store.”

 

 

Simple LED Flasher using Transistors

Simple LED Flasher Project

I wanted to put together a simple two LED flasher circuit that would use the fewest parts and low power.  My first project of this type used the NE555 timer IC but besides the chip, it requires more power than what I would like to use.   Using a couple low-power NPN transistors, the circuit should be able to run for hours on a 9v battery.

The Circuit

I decided to use two 2N3904 transistors (a low power NPN transistor).  This design uses only 10 components but I added additional resistor to inline with the power source.  It could be removed and the other resistors adjusted to lower the power.

I used a free copy of LTSpice from Linear Technology to create the circuit (most SPICE packages do not have LED components for some reason) – you can download it here:  http://www.linear.com/designtools/software/ltspice.jsp

Which LED will light first?

The Breadboard

I assembled the circuit using a low cost breadboard I picked up at Fry’s Electronics.   Using a breadboard allowed me to play around with different components, especially the capacitors and resistors to tweak the flash rate and brightness.

Single LED Flasher

The simplest single LED Flasher circuit I have found uses a single transistor (NPN), 2 resistors and 1 capacitor.  This circuit uses the transistor as a Negistor using the NDR (negative differential resistance) effect.  The transitor will block current until the voltage threshold charging on C1 reach something close to 9v, at which point the voltage will become large enough to get the emitter-base junction to avelanche and drain the current through the LED.

Click here for the video:
http://jasonacox.com/images/IMG_2022.MOV

Reference

http://wild-bohemian.com/electronics/flasher.html

http://en.wikipedia.org/wiki/2N3904

http://www.linear.com/designtools/software/  (LTspice – Nice circuit design tool based on Spice)

http://jlnlabs.online.fr/cnr/negosc.htm

http://www.cappels.org/dproj/simplest_LED_flasher/Simplest_LED_Flasher_Circuit.html

The Samsung B630 LCD TV

The Amazing Samsung B630 LCD TV

On 6/20/09, we purchased a Samsung B630 40″ LCD TV.  The B630 has an amazing picture.  The 120Hz and high contrast features make this 1080p LCD monitor simply a delight.   The unit comes with 4 HDMI inputs as well as two standard A/V inputs for game consoles (great for the kid’s Wii and Playstatation2).  It also has a network port that pulls in news and weather feeds so you can hit an “info” button the remote and get semi-transparent overlay info boxes while watching your favorite show or movie.  Yes, this is more of a gee-whiz feature than actually useful though we have used it to check the local weather–its accuracy hasn’t been very impressive.

The set has an audio optical out.  I have this fed in to the Samsung DVD home theater system we purchased with the TV.  As expected, the sound is great but activating it always generates a pause while the TV and receiver sync up.  The set also has a USB port on the side that allows you to play media files (pictures, music and movies) from thumb drives and external hard drives.  It is a fantastic feature and providing you have a good quality USB drive, it will stream beautiful full 1080p video.

HDMI Problems

Just over 2 months after buying the unit, our cable suddenly stopped working on our new Samsung B630 LCD TV.  After some quick troubleshooting I discovered that it was only the HDMI-1 input that the cable box was using.  The Samsung DVD Player on the 2nd HDMI port worked fine and the Cable would work when plugged in to any of the other inputs.

I notice another strange behavior.  When the Cable and DVD cables were plugged in to HDMI-2 and HDMI-3, only one of the source inputs would work.  If you select 2 or 3, you would still see the same thing (the Cable which was plugged in to HDMI-3).   Moving things around to the other ports, I was able to do the same thing with the DVD.  This mean that we were not able to use the 2nd or 3rd ports to have HD signal from both the Cable and DVD player.   I eventually hooked up the component cables for the Cable box to the TV so that we could continue to view the up-conversion HD quality of our DVDs.

Samsung Support

The Sumsung website let’s you register and request repair for your Samsung products.  Besides the Samsung LCD TV and Home Theater System, we purchased  and registered our Samsung washer and dryer.   The website can be very frustrating at times.  It is slow and will frequently glitch.  At one point, I encountered a page that had a huge listing of products, complete with their serial numbers and details from other customers.  I didn’t drill in to see if it would present me with customer PII data, but clearly it shows that their web development team has work to do.

I did manage to report the HDMI problem via the website.  It does require that you upload the original receipt.  Unfortunately we had lost this (yes, not a good thing) but we had purchased this at Sears and the sears.com site will allow customers who used their Sears credit to view transaction receipts online.  This allowed me to copy/paste into a Word document and upload that to the Samsung site.    The site let us pick a date for the in-home repair and selected Monday.   We received a call the next morning from the repair team. After getting the details of the problem, they moved the schedule to Tuesday and said they would bring the components that they felt would fix the HDMI problem.

Repair Visit #1

The in-home repair technicians arrived and brought the mainboard replacement.  It looks like a small PC motherboard and is located in the lower left hand corner of the back of the TV, behind the connectors.  I took a picture as the techs were installing the new motherboard.

Back of Samsung B630 40

After installing the new motherboard, the TV flashed a red error message at the top of the set.  The tech attempted to reset the unit using various menu options (picture, firmware, etc.) but it would not clear.  He said that the new mainboard was defective and he would need to order a new one.  He re-installed the old mainboard.

Samsung B630 LCD TV Mainboard

Samsung B630 LCD TV Mainboard

After installing the old mainboard, the HMDI ports started working again!   I asked what they did and he said that it looks like the mainboard has a faulty connector that caused the outage.  He said that it does need to be replaced and they would order a new mainboard.  Until then, the HDMI may or may not stay working. Hopefully it will keep working until they return for their second visit.

It is interesting that Samsung would not quality check their mainboards before sending them out in to the field.  It seems to be a bit inefficient and if our old main-board had not mysteriously started working, it would be very frustrating for the customer.  But I will say that the repair technicians were very good.  They were friendly and quick.

Repair Visit #2

The technicians returned in two weeks to install the new mainboard.  Thankfully the HDMI port did not go out again before the second visit.

References

Samsung B630 LCD TV Manual

Samsung Website for B630 (firmware updates, FAQs, manuals, etc.)

GeForce FX 5200 Problems

I have a e-Geforce FX 5200, 128MB, DDR, AGP Video Controller (p/n 128-A8-N303-L2).  We started having video glitches (blue screens, static and bad lagency on video games).  I took out the controller and noticed that 3 of the capactiors had popped.  Two are FZ72 1000 16V caps and one is a FZ75 1000 6.3V.

iWoz: Computer Geek to Cult Icon

This autobiography of Steve Wozniak is a delightful recount of the birth of the personal computer. 

Before cell phones that fit in the palm of your hand and slim laptops that fit snugly into briefcases, computers were like strange, alien vending machines. They had cryptic switches, punch cards and pages of encoded output. But in 1975, a young engineering wizard named Steve Wozniak had an idea: What if you combined computer circuitry with a regular typewriter keyboard and a video screen? The result was the first true personal computer, the Apple I, a widely affordable machine that anyone could understand and figure out how to use.

Wozniak’s life—before and after Apple—is a “home-brew” mix of brilliant discovery and adventure, as an engineer, a concert promoter, a fifth-grade teacher, a philanthropist, and an irrepressible prankster. From the invention of the first personal computer to the rise of Apple as an industry giant, iWoz presents a no-holds-barred, rollicking, firsthand account of the humanist inventor who ignited the computer revolution. 16 pages of illustrations.

Animation

Introduction

I had just started my programming journey into the digital world when TRON appeared in theaters in 1982.  The movie inspired me to pursue my hobby and eventually my career in Computer Science. 

3D Modeling

I have always had a love for 3D modeling.  I assembled my first 3D modeling tool during my Sophomore year in college using C++, X11 Motif and Sun hardware.   Recently I discovered POV-Ray, an open source ray-tracing program that uses a simple Scene Description Language to model primitives.  Naturally, this fits well with the models in TRON so I spent a few hours render various TRON-world objects.   Click Here to see my TRON section.

Tools

Modeling Programs:  Wings3d (freeware), Silo3d (trial-ware), Blender3d (open source)

Converters between 3D formats
Anthony D’Agostino’s Python Scripts for Blender
ExtremeUV

Free renderers
Povray
Yafray
Art of Illusion
Pixie (RIB)
3Delight (RIB) (free for non-commercial use)

Free 3D programs
Anim8or
Art of Illusion
Blender3D
Wings3D

Information about Music and Sound: http://www.jasonacox.com/wordpress/?p=23

Beyond AI: Creating the Conscience of the Machine

I have always been fascinated with the study of Artificial Intelligence.  I began my interest as many computer science majors by simulating intelligence through maze solving LISP automated mice.  These are brute force methods that appear to be intelligent by recursively exploring every possible solution.  This is not intelligence.  It is merely programmatic problem solving.

What is Artificial Intelligence?  How do we copy the creation that is the human mind and intellect, and impress that upon silicon and wires?  Is it even possible? 

Book

Beyond AI: Creating the Conscience of the Machine
by J. Storrs Hall

Artificial intelligence (AI) is now advancing at such a rapid clip that it has the potential to transform our world in ways both exciting and disturbing. Computers have already been designed that are capable of driving cars, playing soccer, and finding and organizing information on the Web in ways that no human could. With each new gain in processing power, will scientists soon be able to create supercomputers that can read a newspaper with understanding, or write a news story, or create novels, or even formulate laws? And if machine intelligence advances beyond human intelligence, will we need to start talking about a computer’s intentions?

This book contemplates several interesting topics related to artificial intelligence, including the consequences of actually creating a systems that is intelligent.  A lot of what is intelligence appears to be search and pattern matching.  It seems that we build complex associations that help us grapple with our environment and interact with others in an intelligent fashion. 

What is intelligence?  I believe that we will continue to see progress in developing artificial minds.  Predictive expert systems already provide a sense of “smarts” but they are not creating anything new.  Attempts to build systems that take inputs, learn and even postulate solutions (as in mathematical proofs) have been limited in their success.  It seems that these intelligent systems hit a “glass ceiling” beyond which they are unable to produce anything new.  

Tools, Programs and Links

SHRDLU is a program for understanding natural language, written by Terry Winograd at the M.I.T. Artificial Intelligence Laboratory in 1968-70. – http://hci.stanford.edu/~winograd/shrdlu/

Bob Iger on Disney Technology

Bob Iger, CEO of TWDC, talks about the emphasis of Disney on online technologies…

Transcript:

We’re not really embracing technology, we’re embracing consumers. Consumers are using technology in order for us to be relevant to them. We have to keep the consumer in mind and use technology to make the product either more valuable or more accessible or just better.

On the social networking side, it’s an experience online that you’re either entertaining yourself with others or participating in social networking experiences. Social networking is not just among Gen X and Gen Y, but even younger people. We saw a company called Club Penguin that was doing it quite well. It’s an online gaming world that you can do with others, and you can use your success or lack thereof in games to acquire currency and create a better life for yourself.

We bought Club Penguin and are using the creative team and technology to build other online virtual worlds and social networking experiences for other Disney franchises. We have a coterie of rich franchises, and people want to engage with or as part of them. This will allow them to be immersed even more in their franchise world.

We’re doing it with Pirates Online, and we’re going to do it with the new franchise we’re developing called Fairies. We’re also doing it with Princesses, and you can see that happening with a number of other Disney properties. We’re embracing the consumer and using technology to do so.

This is a little laboratory of a business for us. It’s a billion-dollar business that generates digital revenue at the company. It’s not just domestically but globally, we’re rolling out versions of Disney Calm in the UK, Japan, China, Australia, and France. This will not only grow revenue but also grow the brand in the association.

In three years, the 1 billion-dollar business will be much bigger. It will create a fair amount of growth for us, and some of that will be cannibalistic of current business, but a lot of it will be incremental. We’re going to reach more people in more ways, and as people spend more time engaging with entertainment on a global basis and more money, that’s a great thing for us.

Social media for us will continue to grow, but the business that will do online or digital equations will come in from many different revenue streams, such as subscription services, direct sale video on demand, micro payments, and advertising. We’ve spent a lot of time developing ways that we can enable advertisers to reach people with our product in new platforms.

Social media is not just about the 20-year-old or the 25-year-old or the 18-year-old going on Facebook or MySpace. It’s about kids using their computers and broadband-enabled computers for entertainment much more than the generations before them. We believe that the broadband-enabled computer will be a primary source of entertainment for kids in the years ahead.

Nano Technology

What is the future of Nano Technology? 

In 1959, a scientist named Richard Feynman predicted the future of nanotechnology. He predicted what needed to be done and how it might be done, all before anyone had really seen an atom with a microscope. Feynman looked into the future and predicted how technology might make things smaller and smaller. He didn’t know the exact size of atoms, but he did know that computing machines are very large and fill rooms. He wondered if it was possible to make them very small, making them little wires, little elements. By little he meant little for instance the wires should be 10 or 100 atoms in diameter today the smallest parts inside a computer chip are about 100 nanometers. What’s a nanometer one billion of a meter that means if you laid 1 million of these computer parts side-by-side they would measure only one inch across. He wondered if in the future, these parts will be only a few atoms computers will be hundreds of times faster. He also considered the final question as to whether ultimately in the great future we can arrange the atoms the way we want. In 1989, Don Eichler and his colleagues at IBM did just that, they moved individual atoms to spell out IBM 40 years after Fineman predicted the future. Today, scientists are using nanotechnology and making things smaller and smaller.