Add a 'request' function to API to wait for responses to commands.

Progress towards #157