  In astronomy and microscopy, distortions in the wavefront affect the dynamic
range of a high contrast imaging system. These aberrations are either imposed
by a turbulent medium such as the atmosphere, by static or thermal aberrations
in the optical path, or by imperfectly phased subapertures in a segmented
mirror. Active and adaptive optics (AO), consisting of a wavefront sensor and a
deformable mirror, are employed to address this problem. Nevertheless, the
non-common-path between the wavefront sensor and the science camera leads to
persistent quasi-static speckles that are difficult to calibrate and which
impose a floor on the image contrast. In this paper we present the first
experimental demonstration of a novel wavefront sensor requiring only a minor
asymmetric obscuration of the pupil, using the science camera itself to detect
high order wavefront errors from the speckle pattern produced. We apply this to
correct errors imposed on a deformable microelectromechanical (MEMS) segmented
mirror in a closed loop, restoring a high quality point spread function (PSF)
and residual wavefront errors of order $\sim 10$ nm using 1600 nm light, from a
starting point of $\sim 300$ nm in piston and $\sim 0.3$ mrad in tip-tilt. We
recommend this as a method for measuring the non-common-path error in
AO-equipped ground based telescopes, as well as as an approach to phasing
difficult segmented mirrors such as on the \emph{James Webb Space Telescope}
primary and as a future direction for extreme adaptive optics.
