Cpp code to handle serial communication.