Sets up serial port by connecting to phsyical or software port.

    Depending on command line options, this function will either connect to a
    SerialTestClass() port for loopback testing or to the specified port from
    the command line option. If loopback is True it overrides the physical port
    specification.

    Args:
        loopback: argparse option
        port: argparse option

    Returns:
        serialPort: Pyserial serial port instance

def setupSerialPort(loopback, port):
    """Sets up serial port by connecting to phsyical or software port.

    Depending on command line options, this function will either connect to a
    SerialTestClass() port for loopback testing or to the specified port from
    the command line option. If loopback is True it overrides the physical port
    specification.

    Args:
        loopback: argparse option
        port: argparse option

    Returns:
        serialPort: Pyserial serial port instance
    """
    if loopback:
        # Implement loopback software serial port
        testSerial = SerialTestClass()
        serialPort = testSerial.serialPort
    else:
        # TODO enable serial port command line options (keep simple for user!)
        serialPort = serial.Serial(port, 115200, timeout=0)

    return serialPort