Added support to handle openning and close of Serial port

Small change to support the close and openning of the serial port, this
is used when the dip switched are changed and a new configuration is
needed for the setup.