#! /usr/bin/env python3 """ # PinPadWriteDisplay.py: display a text on a pinpad # Copyright (C) 2021 Ludovic Rousseau """ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, see . from smartcard.System import readers from smartcard.pcsc.PCSCPart10 import (SCARD_SHARE_DIRECT, SCARD_LEAVE_CARD, FEATURE_CCID_ESC_COMMAND, getFeatureRequest, hasFeature) reader = readers()[0] print("Using reader:", reader) cardConnection = reader.createConnection() cardConnection.connect(mode=SCARD_SHARE_DIRECT, disposition=SCARD_LEAVE_CARD) feature_list = getFeatureRequest(cardConnection) ccid_esc_command = hasFeature(feature_list, FEATURE_CCID_ESC_COMMAND) if ccid_esc_command is None: raise Exception("FEATURE_CCID_ESC_COMMAND is not supported or allowed") clear_screen = [0xB6] res = cardConnection.control(ccid_esc_command, clear_screen) print(res) set_text = [0x68] + list(map(ord, "0123456789ABCDEF0123456789ABCDEF")) print(set_text) res = cardConnection.control(ccid_esc_command, set_text) print(res)