Implement reading from the serial port. Better error checking

This PR implement reading from the serial port. This is a simple (unique) callback driven mechanism, so the javascript app will have to continuously re-poll the serial port after getting data or a timeout (buffer with length = 0). A better mechanism would be to trigger "onData" events.

Also, added more checks on the state of the serial port, so that in case a Cordova app attempts read/write/close operations on ports that were not previously opened, the app does not crash but calls the error callback.