From: He.David <Dav...@IG...> - 2011-01-25 01:44:32
|
Hi, Does anyone can help me to figure out why I got this compiler error? How to pass the call back function in this case? void transfer_cb_fn (libusb_transfer* transfer){ cout<<"call back function called"<<endl; } Void main(...){ ... libusb_transfer* transfer; libusb_fill_interrupt_transfer (transfer, dev_handle, 129, data, 20, transfer_cb_fn, user_data, 10000); } Error message: error C2664: 'libusb_fill_interrupt_transfer' : cannot convert parameter 6 from 'void (__cdecl *)(libusb_transfer *)' to 'libusb_transfer_cb_fn' 2> None of the functions with this name in scope match the target type Thanks. David |
From: Tim R. <ti...@pr...> - 2011-01-25 01:47:14
|
He.David wrote: > > Hi, Does anyone can help me to figure out why I got this compiler > error? How to pass the call back function in this case? > > > > voidtransfer_cb_fn (libusb_transfer* transfer){ > > cout<<"call back function called"<<endl; > > } > > > > Void main(…){ > > … > > libusb_transfer* transfer; > > libusb_fill_interrupt_transfer (transfer, dev_handle, 129, data, 20, > transfer_cb_fn, user_data, 10000); > > > > } > > > > Error message: > > error C2664: 'libusb_fill_interrupt_transfer' : cannot convert > parameter 6 from 'void (__cdecl *)(libusb_transfer *)' to > 'libusb_transfer_cb_fn' > > 2> None of the functions with this name in scope match the > target type > Try declaring it as C linkage: extern "C" void cb_fn( libusb_transfer* transfer ); -- Tim Roberts, ti...@pr... Providenza & Boekelheide, Inc. |
From: Michael P. <mic...@gm...> - 2011-01-25 02:15:10
|
Tim Roberts wrote: >> > Error message: >> > >> > error C2664: 'libusb_fill_interrupt_transfer' : cannot convert >> > parameter 6 from 'void (__cdecl *)(libusb_transfer *)' to >> > 'libusb_transfer_cb_fn' >> > >> > 2> None of the functions with this name in scope match the >> > target type >> > >> >> Try declaring it as C linkage: >> >> extern "C" void cb_fn( libusb_transfer* transfer ); You probably need that too if you're doing C++, but you definitely need the proper calling convention, as specified both in the definition of libusb_transfer_cb_fn in libsub.h (see the error message you pasted): typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer); AND in the examples, such as dpfp.c: static void LIBUSB_CALL cb_irq(struct libusb_transfer *transfer) libusb_fill_interrupt_transfer(irq_transfer, devh, EP_INTR, irqbuf, sizeof(irqbuf), cb_irq, NULL, 0); (the static part isn't necessarily needed; that's your choice) Michael |
From: Michael P. <mic...@gm...> - 2011-01-25 02:32:28
|
Michael Plante wrote: >> typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer); Hrm, interestingly: http://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga62afeef38ae1003e 14d2e8eb06462f25 leaves out the LIBUSB_CALL. The last doxygen run was Apr 19 2010. Now 1.0.8 didn't include this change, but, even so, the 1.0.8 tag is dated May 4 2010. Should we try to keep doxygen up to releases or to latest git? Note that this change *is* in libusb.git, even though libusb.git isn't quite right for Windows yet. >> in libsub.h (and of course that's a typo) Michael |
From: Peter S. <pe...@st...> - 2011-01-25 02:17:33
|
Tim Roberts wrote: > > Error message: > > > > error C2664: 'libusb_fill_interrupt_transfer' : cannot convert > > parameter 6 from 'void (__cdecl *)(libusb_transfer *)' to > > 'libusb_transfer_cb_fn' .. > Try declaring it as C linkage: > > extern "C" void cb_fn( libusb_transfer* transfer ); Throw in a LIBUSB_CALL there as well. //Peter |
From: He.David <Dav...@IG...> - 2011-01-26 00:14:09
|
Thanks for the help. It passes the complier; but the call back function never got called; does anyone know how come the call back function never got called? static void LIBUSB_CALL transfer_cb_fn (struct libusb_transfer* transfer){ cout<<"call back function called"<<endl; } Void main(...){ ... libusb_fill_interrupt_transfer (transfer, dev_handle, 0x81, data, sizeof(data), transfer_cb_fn, NULL, 0); libusb_submit_transfer(transfer); ... } Thanks. David -----Original Message----- From: Peter Stuge [mailto:pe...@st...] Sent: Monday, January 24, 2011 6:17 PM To: lib...@li... Subject: Re: [Libusb-devel] how to use function libusb_fill_interrupt_transfer(...) Tim Roberts wrote: > > Error message: > > > > error C2664: 'libusb_fill_interrupt_transfer' : cannot convert > > parameter 6 from 'void (__cdecl *)(libusb_transfer *)' to > > 'libusb_transfer_cb_fn' .. > Try declaring it as C linkage: > > extern "C" void cb_fn( libusb_transfer* transfer ); Throw in a LIBUSB_CALL there as well. //Peter ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Libusb-devel mailing list Lib...@li... https://lists.sourceforge.net/lists/listinfo/libusb-devel |
From: Peter S. <pe...@st...> - 2011-01-26 12:13:26
|
He.David wrote: > Thanks for the help. It passes the complier; but the call back > function never got called; does anyone know how come the call back > function never got called? Are you doing event handling? Please have a look at the 1.0 API docs for more details. Feel free to ask if something is unclear. //Peter |
From: Alan S. <st...@ro...> - 2011-01-26 15:07:43
|
On Tue, 25 Jan 2011, He.David wrote: > Thanks for the help. It passes the complier; but the call back function never got called; does anyone know how come the call back function never got called? > > static void LIBUSB_CALL transfer_cb_fn (struct libusb_transfer* transfer){ > cout<<"call back function called"<<endl; > } > > Void main(...){ > > ... > libusb_fill_interrupt_transfer (transfer, dev_handle, 0x81, > data, sizeof(data), transfer_cb_fn, NULL, 0); > > libusb_submit_transfer(transfer); > ... > > } Maybe your callback function never gets called because the transfer never completes. In other words, maybe the device never sends any interrupt packets. You could find out what's happening by using a USB sniffer program. Alan Stern |
From: Segher B. <se...@ke...> - 2011-01-27 01:02:17
|
>> static void LIBUSB_CALL transfer_cb_fn (struct libusb_transfer* >> transfer){ >> cout<<"call back function called"<<endl; >> } >> >> Void main(...){ >> >> ... >> libusb_fill_interrupt_transfer (transfer, dev_handle, 0x81, >> data, sizeof(data), transfer_cb_fn, NULL, 0); >> >> libusb_submit_transfer(transfer); >> ... >> >> } > > Maybe your callback function never gets called because the transfer > never completes. In other words, maybe the device never sends any > interrupt packets. It sounds more like he never calls libusb_handle_events() or similar. Segher |