Adjust serial open, write and close

Serial open and close should separated from write data.
I then add open and close button to deal with connection.
With available connection, writing data is allowed then.