John Chen wrote: > > 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*.
You may treat those two types (void* and unsigned char*) as identical. Partly, this is historical. The whole "void" type concept was not introduced to C until the standardization process. Before that, "unsigned char *" was the way you identified a generic buffer of unknown type. For some people, old habits die hard. Don't assign too much meaning to the word "char". In C, it does not refer to letters and numbers. It refers to a unit of memory one byte in size, with no other inherent meaning. > 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? If you have your data as an unsigned int, and you need to send that as a 4-byte quantity to your device, just use (unsigned char *) &myUnsignedInt You need to be aware of endianness issues, however. Windows is exclusively little-endian, so your device might be the same, but Linux runs on systems that are big-endian. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. ------------------------------------------------------------------------------ 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