Fix seg fault by p sp under mingw environment

p <an instance of SerialPort> causes segmentation fault. Wrapping fh addresses the fault. Please review the code.