Fix serial port logic for Mac