Fixed serial port logging

Before writing on the serial port, the port must be open.

Closes-Bug: #1376819
Change-Id: I630c6807f1c19070aa2981708a0d85f9a12e370a