0

我在 Mac Lion 上安装了 NFCPY、pyUSB 和 libusb。我正在使用常见的 ACR122U NFC 读卡器,当我尝试运行任何示例时,它都会崩溃。我知道很多人都在使用同一个阅读器和 NFCPY,我不知道为什么它对我不起作用。

Python 不会打印任何错误,但是我可以在日志文件中看到此堆栈跟踪:

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

任何帮助将不胜感激,我坚持了很多天

4

2 回答 2

1

查看 libusb 中的源代码darwin_reset_device(),并考虑到它在函数中崩溃的时间有多早(只有 10 个字节),我的猜测是,要么传递给,dev_handle要么dev_handle->dev传递给darwin_reset_device()NULL。

弄清楚为什么会发生这种情况很复杂——有很多代码和层需要排除故障(libusb、pyusb、nfcpy)。也许您可以了解其他人是否在 Lion 上成功运行 nfcpy,以及他们在做什么不同(Xcode 版本、nfcpy 版本等)

另一个建议(根据我在 Mac 上使用 USB 驱动程序的经验):拔下连接到计算机的每个USB 设备。这包括任何第三方鼠标/键盘。

于 2012-02-20T07:48:50.917 回答
1

使用 ACR122U 和 python 的最佳工具是pyscardRFIDIOt,它们是 pyscard 和 libnfc 的包装器。pyscard 可以很好地处理它,这里有一个例子:

http://ludovicrousseau.blogspot.com.br/2010/04/pcsc-sample-in-python.html

于 2013-03-06T18:36:38.127 回答