pcscd协议更改,但atr不更改

2024-04-25 00:23:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在研究hid omnikey 5325cl并试图得到ATR值。我在Ubuntu上使用pcscd和pyscard库。系统使用T0协议自动获取ATR,但我需要原始返回。在windows上,使用helloprox或omnikey的官方软件我可以得到我需要的东西,但是在ubuntu上,尽管我改变了协议,但ATR没有改变。在

下面是我使用的代码:

class PrintObserver(CardObserver):

"""A simple card observer that is notified
when cards are inserted/removed from the system and
prints the list of cards
"""

def update(self, observable, actions):
    (addedcards, removedcards) = actions
    for card in addedcards:
       card.connection=card.createConnection()
       card.connection.connect(protocol=CardConnection.RAW_protocol)

    binary_atr=bin(int(toHexString(card.connection.getATR()).replace(" ",""), 16))

       binary_atr=binary_atr[len(binary_atr)-24:len(binary_atr)-1]
       print int(binary_atr,2)

    for card in removedcards:
        print "-Removed: ", toHexString(card.atr)


if __name__ == '__main__':
    cardmonitor = CardMonitor()
    cardobserver = PrintObserver()
    cardmonitor.addObserver(cardobserver)

#Get Ports
config=ConfigParser.ConfigParser()
config.read('../config.ini')
Read_Port=int(config.get('CardReaderSocketPorts','Read',0))
Write_Port=int(config.get('CardReaderSocketPorts','Write',0))

# Initialise socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_address = ('localhost', Read_Port)
return_address = ('localhost', Write_Port)
sock.bind(server_address)

while 1:
  message, address = sock.recvfrom(4096)
  if message:
    parsed_json=json.loads(message)

    #Single Line
    if parsed_json['set'].upper()=="Stop":
        sock.sendto('{"success":"True"}',return_address)        
        break


# don't forget to remove observer, or the
# monitor will poll forever...
cardmonitor.deleteObserver(cardobserver)

Tags: theconfigifportaddresssocketconnectioncard
2条回答

一些可能有帮助的考虑因素,即使它们不能补充完整的答案:

  • 您正在使用非接触式卡或标签
  • 根据ATQB协议的不同,ATQB的结构完全不同。在
  • PCSC是一个过时的软件概念,它严格要求ATR
  • 因此,非接触式读卡器制造商必须根据从读卡器中获取的信息,发明一种ATR
  • 你的软件接收到的“ATR”就是这项发明的结果。在
  • Omnikey显然使用Windows注册表来控制发明过程,这显然是一种不可移植的方法。在

所以从我的建议出发,如何联系Omnix支持。根据我的经验,他们是合作的。在

联系Omnikey支持后,问题解决了。 在developer guide中,我正在查找配置文件“/etc/cmrfid.ini文件“更改前置器格式。文件名已更改为“/etc”/万能钥匙.ini““

相关问题 更多 >