Added some functions to handle serialcommunication