                             transmitRate: BaudRate,
                             minimumBytesToRead: Int,
                             timeout: Int = 0, /* 0 means wait indefinitely */
-                            enableParity: Bool = false,
+                            parityType: ParityType = .none,
                             sendTwoStopBits: Bool = false, /* 1 stop bit is the default */
                             dataBitsSize: DataBitsSize = .bits8,
                             useHardwareFlowControl: Bool = false,

        cfsetispeed(&settings, receiveRate.speedValue)
        cfsetospeed(&settings, transmitRate.speedValue)

        // Set parity enable flag
        if enableParity {
            settings.c_cflag |= ~tcflag_t(PARENB)
        } else {
            settings.c_cflag &= ~tcflag_t(PARENB)
        }

        // Set stop bit flag
        if sendTwoStopBits {

            return tcflag_t(CS8)
        }
    }

}

public enum ParityType {
	case none
	case even
	case odd

	var parityValue: tcflag_t {
        switch self {
        case .none:
            return 0
        case .even:
            return tcflag_t(PARENB)
        case .odd:
            return tcflag_t(PARENB | PARODD)
        }
    }
}

public enum PortError: Int32, Error {
