Reputation: 3474
I installed NFCPY, pyUSB and libusb on Mac Lion. I am using the common ACR122U NFC card reader and when I tried to run any of the examples it crashes. I know many people are using this same reader with NFCPY, I don't know why it doesn't work for me.
Python doesn't print any error, however I can see this stack trace in the log file:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libusb-1.0.dylib 0x000000010f799bda darwin_reset_device + 10 (darwin_usb.c:1213)
1 libffi.dylib 0x00007fff87b2fe7c ffi_call_unix64 + 76
2 libffi.dylib 0x00007fff87b30ae9 ffi_call + 728
3 _ctypes.so 0x000000010f78033f _ctypes_callproc + 735
4 _ctypes.so 0x000000010f77afd2 0x10f777000 + 16338
5 org.python.python 0x000000010f360d32 PyObject_Call + 97
6 org.python.python 0x000000010f3e0f63 PyEval_EvalFrameEx + 14353
7 org.python.python 0x000000010f3e3cd8 PyEval_EvalCodeEx + 1996
8 org.python.python 0x000000010f381abf 0x10f359000 + 166591
9 org.python.python 0x000000010f360d32 PyObject_Call + 97
10 org.python.python 0x000000010f3e15ec PyEval_EvalFrameEx + 16026
11 org.python.python 0x000000010f3e3cd8 PyEval_EvalCodeEx + 1996
12 org.python.python 0x000000010f3e3e6c 0x10f359000 + 568940
13 org.python.python 0x000000010f3e0e0a PyEval_EvalFrameEx + 14008
14 org.python.python 0x000000010f3e3df7 0x10f359000 + 568823
15 org.python.python 0x000000010f3e0e0a PyEval_EvalFrameEx + 14008
16 org.python.python 0x000000010f3e3df7 0x10f359000 + 568823
17 org.python.python 0x000000010f3e0e0a PyEval_EvalFrameEx + 14008
18 org.python.python 0x000000010f3e3cd8 PyEval_EvalCodeEx + 1996
19 org.python.python 0x000000010f381abf 0x10f359000 + 166591
20 org.python.python 0x000000010f360d32 PyObject_Call + 97
21 org.python.python 0x000000010f36f6e9 0x10f359000 + 91881
22 org.python.python 0x000000010f360d32 PyObject_Call + 97
23 org.python.python 0x000000010f3ab484 0x10f359000 + 337028
24 org.python.python 0x000000010f3a5b7a 0x10f359000 + 314234
25 org.python.python 0x000000010f360d32 PyObject_Call + 97
26 org.python.python 0x000000010f3e0f63 PyEval_EvalFrameEx + 14353
27 org.python.python 0x000000010f3e3df7 0x10f359000 + 568823
28 org.python.python 0x000000010f3e0e0a PyEval_EvalFrameEx + 14008
29 org.python.python 0x000000010f3e3cd8 PyEval_EvalCodeEx + 1996
30 org.python.python 0x000000010f3e3e6c 0x10f359000 + 568940
31 org.python.python 0x000000010f3e0e0a PyEval_EvalFrameEx + 14008
32 org.python.python 0x000000010f3e3cd8 PyEval_EvalCodeEx + 1996
33 org.python.python 0x000000010f381abf 0x10f359000 + 166591
34 org.python.python 0x000000010f360d32 PyObject_Call + 97
35 org.python.python 0x000000010f36f6e9 0x10f359000 + 91881
36 org.python.python 0x000000010f360d32 PyObject_Call + 97
37 org.python.python 0x000000010f3ab484 0x10f359000 + 337028
38 org.python.python 0x000000010f3a5b7a 0x10f359000 + 314234
39 org.python.python 0x000000010f360d32 PyObject_Call + 97
40 org.python.python 0x000000010f3e0f63 PyEval_EvalFrameEx + 14353
41 org.python.python 0x000000010f3e3df7 0x10f359000 + 568823
42 org.python.python 0x000000010f3e0e0a PyEval_EvalFrameEx + 14008
43 org.python.python 0x000000010f3e3cd8 PyEval_EvalCodeEx + 1996
44 org.python.python 0x000000010f3e3d4d PyEval_EvalCode + 54
45 org.python.python 0x000000010f3fb08f 0x10f359000 + 663695
46 org.python.python 0x000000010f3fb14f PyRun_FileExFlags + 157
47 org.python.python 0x000000010f3fc2a2 PyRun_SimpleFileExFlags + 392
48 org.python.python 0x000000010f40c2af Py_Main + 2715
49 org.python.python 0x000000010f34ee88 0x10f34e000 + 3720
Thread 1:: org.libusb.device-detach
0 libsystem_kernel.dylib 0x00007fff90e2967a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff90e28d71 mach_msg + 73
2 com.apple.CoreFoundation 0x00007fff90082b6c __CFRunLoopServiceMachPort + 188
3 com.apple.CoreFoundation 0x00007fff9008b2d4 __CFRunLoopRun + 1204
4 com.apple.CoreFoundation 0x00007fff9008aae6 CFRunLoopRunSpecific + 230
5 com.apple.CoreFoundation 0x00007fff9009a7ff CFRunLoopRun + 95
6 libusb-1.0.dylib 0x000000010f79e997 event_thread_main + 631 (darwin_usb.c:369)
7 libsystem_c.dylib 0x00007fff903888bf _pthread_start + 335
8 libsystem_c.dylib 0x00007fff9038bb75 thread_start + 13
Thread 2:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff90e2b7e6 kevent + 10
1 libdispatch.dylib 0x00007fff92d9e5be _dispatch_mgr_invoke + 923
2 libdispatch.dylib 0x00007fff92d9d14e _dispatch_mgr_thread + 54
Thread 3:
0 libsystem_kernel.dylib 0x00007fff90e2b192 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff9038a594 _pthread_wqthread + 758
2 libsystem_c.dylib 0x00007fff9038bb85 start_wqthread + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x000000010f7a2320 rbx: 0x0000000000000000 rcx: 0x000000010f985f80 rdx: 0x0000000000000000
rdi: 0x0000000000000000 rsi: 0x0000000000000001 rbp: 0x00007fff6ef4baa0 rsp: 0x00007fff6ef4ba90
r8: 0x000000010f48e840 r9: 0x0000000000000000 r10: 0x00007fff6ef4ba00 r11: 0x000000010f795340
r12: 0xffffffffffffffff r13: 0x0000000000000001 r14: 0x0000000000000000 r15: 0x00007fff6ef4bab0
rip: 0x000000010f799bda rfl: 0x0000000000010246 cr2: 0x0000000000000058
Logical CPU: 1
Any help would be very appreciated, I am stuck with this for many days
Upvotes: 0
Views: 1450
Reputation: 2488
The best tools for working with the ACR122U and python are pyscard and RFIDIOt, which is a wrapper for pyscard and libnfc. pyscard can handle it pretty well, here's an example:
http://ludovicrousseau.blogspot.com.br/2010/04/pcsc-sample-in-python.html
Upvotes: 1
Reputation: 3236
Looking at the source of darwin_reset_device()
in libusb, and given how early in the function it crashes (only 10 bytes in), my guess is that either dev_handle
or dev_handle->dev
being passed to darwin_reset_device()
is NULL.
Figuring out why this happens is complicated--there's a lot of code and layers to troubleshoot (libusb, pyusb, nfcpy). Maybe you can find out if anyone else is successfully running nfcpy on Lion, and what they're doing differently (Xcode versions, nfcpy version, etc.)
One other suggestion (from my experience with USB drivers on the Mac): unplug every USB device connected to your computer. This includes any third-party mice/keyboards.
Upvotes: 1