def getATR(reader):
    """Return the ATR of the card inserted into the reader."""
    connection = reader.createConnection()
    atr = ""
    try:
        connection.connect()
        atr = smartcard.util.toHexString(connection.getATR())
        connection.disconnect()
    except smartcard.Exceptions.NoCardException:
        atr = "no card inserted"
    return atr