On Thu, Sep 6, 2012 at 5:22 PM, John Chen <john...@gmail.com> wrote:

> Hi,
>
> The device I am working right now demanding sending and receiving data in
> unsigned int, and every bit has to be in exact position, in windows it is
> easy as the DeviceIoContorl takes a void pointer, but in libusb, both
> libusb_bulk_transfer and libusb_fill_bulk_transfer only takes unsigned
> char*.
>
> when writing, I am combine all the unsigned int into string<unsigned
> char>, (no sure if this will work or not) but when reading, there could be
> so many different combinations, e.g. if libusb returns the following:
> 125
> 126
> 210
>
> how do I know how to pack the data into unsigned int and how many unsigned
> int?
>
>
You can't do "string<unsigned char>". The string class is not a template,
it is an instantiation of basic_string defined as "typedef
basic_string<char> string". So you could do "basic_string<unsigned char>".
 But I'm not sure why you would want to. You are not working with "strings"
here, it sounds like you are working with integers. Why don't you just
allocate enough memory (get a void*) and copy your ints to the memory
location pointed to by the void*, then cast the void * to an unsigned * and
pass it to libusb_bulk_transfer. The length parameter would be (number of
ints you have)*(sizeof(unsigned int)/sizeof(unsigned char)).

Dave
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to