Adding conditional logic to use RS232 or serialport