-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnfc_reader.py
More file actions
47 lines (25 loc) · 909 Bytes
/
nfc_reader.py
File metadata and controls
47 lines (25 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import ctypes
import ctypes.util
from nfc_types import *
from functions import *
def list_devices():
context = Context()
contextpnt = pointer(context)
nfc_init(byref(contextpnt))
print nfc_version()
device = nfc_open(contextpnt, None)
if device:
print "ok"
else:
print "no device"
exit()
errorcode = nfc_initiator_init(device)
print nfc_device_get_name(device)
target = Target()
targetTypes = Modulation * 1;
modulationTargets = targetTypes(Modulation(ModulationType.NMT_ISO14443A, BaudRate.NBR_106))
target = Target()
print nfc_initiator_poll_target(device, byref(modulationTargets), ctypes.c_size_t(1), ctypes.c_uint8(50), ctypes.c_uint8(2), byref(target))
uid = " ".join([str(hex(target.nti.nai.abtUid[i])).replace("0x", "") for i in range(target.nti.nai.szUidLen)])
print uid
list_devices()