Fix serial port write scope