這是錯誤。你對這個Python錯誤做了什麼?
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 295, in 'calling callback function'
File "USB2.py", line 454, in ff
self.drv_locked = False
SystemError: Objects/cellobject.c:24: bad argument to internal function
下面是涉及的Python代碼。
def drv_send(self, data, size):
if not self.Connected():
return
def f():
self.drv_locked = True
buffer = ''.join(chr(c) for c in data[:size])
out_buffer = cast(buffer, POINTER(c_uint8))
request_handle = (OPENUSB_REQUEST_HANDLE * 1)()
request = (OPENUSB_INTR_REQUEST * 1)()
request_handle[0].dev = self.usbhandle
request_handle[0].interface = INTERFACE_ID
request_handle[0].endpoint = LIBUSB_ENDPOINT_OUT + 1
request_handle[0].type = USB_TYPE_INTERRUPT
request_handle[0].req.intr = request
def f(req):
print req[0].req.intr[0].result.status, req[0].req.intr[0].result.transferred_bytes
self.drv_locked = False # Line 454
request_handle[0].cb = REQUEST_CALLBACK(f)
request_handle[0].arg = None
request[0].payload = out_buffer
request[0].length = size
request[0].timeout = 5000
request[0].flags = 0
request[0].next = None
r = lib.openusb_xfer_aio(request_handle)
print "result", r
self.command_queue.put(f)
以下是涉及的Python源代碼。
PyObject *
PyCell_Get(PyObject *op)
{
if (!PyCell_Check(op)) {
PyErr_BadInternalCall(); // Line 24
return NULL;
}
Py_XINCREF(((PyCellObject*)op)->ob_ref);
return PyCell_GET(op);
}
什麼是「自我」? – 2009-08-22 08:26:13