我一直在工作hid omnikey 5325 cl,并试图获得ATR值。我在Ubuntu上使用pcscd和pyscard库。系统使用T0协议自动获取ATR,但我需要RAW返回。在使用helloprox或omnikey的官方软件的Windows上,我可以得到我所需要的,但在Ubuntu上,即使我已经更改了协议,但ATR不会改变。pcscd协议的变化,但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)
我有点不确定,你试图达到什么目的。卡与阅读器之间的通信总是T = 0,T = 1或T = CL。所选择的协议取决于ATR,通常意味着使用T = 0来寻址支持T = 0和T = 1的卡。 (我从来没有听说过在原始模式下通信的卡)。换言之,您必须更改ATR以实现不同的行为,但不幸的是完全取决于所使用的卡。 – guidot
对不起,我让我明白我的问题。我正在尝试实现以更改ATR解码格式。在Windows中,我使用“Omnikey Workbench”,允许更改ATR解码格式。在Ubuntu中默认是H10301。 此外还有一个选项可以使用“原始解码格式”,这在工作台中对我来说更容易处理。 H10301 ATR:3B 06 01 00 18 02 87 04原始解码ATR:3B 05 00 02 24 E0 40我需要获取位于卡背面的卡号1208352。使用后者非常容易,但我无法用第一个弄清楚。感谢您的回复@guidot –
其实我要找的是[版本]的[版本](http://www.isecuretech.com/download/SmartCardReader/OMNIKEY/driver/OK5x21/OK5x25_Prox_ATRDecode.pdf)。由于此代码将运行在几台设备上,如果可能的话,用python命令改变它。 @guidot –