当前位置: 技术问答>linux和unix
Libusb 如何输出SN及其它信息。
来源: 互联网 发布时间:2016-10-25
本文导语: 使用LibUSB 1.0 快完成任务了,但是有些信息需要显示。不知道如何输出 程序ll使用了unicode wxString strTemp; struct libusb_device_descriptor desc; char szBuf[512]; nRet= libusb_get_device_descriptor(deviceIt->GetDevice(), &desc); ...
使用LibUSB 1.0 快完成任务了,但是有些信息需要显示。不知道如何输出
程序ll使用了unicode
wxString strTemp;
struct libusb_device_descriptor desc;
char szBuf[512];
nRet= libusb_get_device_descriptor(deviceIt->GetDevice(), &desc);
sprintf(szBuf,"Deivce IDrnVID = %04xrn",desc.idVendor);
strTemp += szBuf;
sprintf(szBuf,"PID = %04xrn",desc.idProduct);
strTemp += szBuf;
这样只能够输出一个地址,不知首怎么输出字符串。
sprintf(szBuf,"Serial Number = %drn",desc.iSerialNumber);
strTemp += szBuf;
已经有查看文档 ,但是还是知如何输出SN.
struct libusb_config_descriptor {
/** Size of this descriptor (in bytes) */
uint8_t bLength;
/** Descriptor type. Will have value
* ref libusb_descriptor_type::LIBUSB_DT_CONFIG LIBUSB_DT_CONFIG
* in this context. */
uint8_t bDescriptorType;
/** Total length of data returned for this configuration */
uint16_t wTotalLength;
/** Number of interfaces supported by this configuration */
uint8_t bNumInterfaces;
/** Identifier value for this configuration */
uint8_t bConfigurationValue;
/** Index of string descriptor describing this configuration */
uint8_t iConfiguration;
/** Configuration characteristics */
uint8_t bmAttributes;
/** Maximum power consumption of the USB device from this bus in this
* configuration when the device is fully opreation. Expressed in units
* of 2 mA. */
uint8_t MaxPower;
/** Array of interfaces supported by this configuration. The length of
* this array is determined by the bNumInterfaces field. */
const struct libusb_interface *interface;
/** Extra descriptors. If libusb encounters unknown configuration
* descriptors, it will store them here, should you wish to parse them. */
const unsigned char *extra;
/** Length of the extra descriptors, in bytes. */
int extra_length;
};
还请各位仁兄指点。不胜感激。
程序ll使用了unicode
wxString strTemp;
struct libusb_device_descriptor desc;
char szBuf[512];
nRet= libusb_get_device_descriptor(deviceIt->GetDevice(), &desc);
sprintf(szBuf,"Deivce IDrnVID = %04xrn",desc.idVendor);
strTemp += szBuf;
sprintf(szBuf,"PID = %04xrn",desc.idProduct);
strTemp += szBuf;
这样只能够输出一个地址,不知首怎么输出字符串。
sprintf(szBuf,"Serial Number = %drn",desc.iSerialNumber);
strTemp += szBuf;
已经有查看文档 ,但是还是知如何输出SN.
struct libusb_config_descriptor {
/** Size of this descriptor (in bytes) */
uint8_t bLength;
/** Descriptor type. Will have value
* ref libusb_descriptor_type::LIBUSB_DT_CONFIG LIBUSB_DT_CONFIG
* in this context. */
uint8_t bDescriptorType;
/** Total length of data returned for this configuration */
uint16_t wTotalLength;
/** Number of interfaces supported by this configuration */
uint8_t bNumInterfaces;
/** Identifier value for this configuration */
uint8_t bConfigurationValue;
/** Index of string descriptor describing this configuration */
uint8_t iConfiguration;
/** Configuration characteristics */
uint8_t bmAttributes;
/** Maximum power consumption of the USB device from this bus in this
* configuration when the device is fully opreation. Expressed in units
* of 2 mA. */
uint8_t MaxPower;
/** Array of interfaces supported by this configuration. The length of
* this array is determined by the bNumInterfaces field. */
const struct libusb_interface *interface;
/** Extra descriptors. If libusb encounters unknown configuration
* descriptors, it will store them here, should you wish to parse them. */
const unsigned char *extra;
/** Length of the extra descriptors, in bytes. */
int extra_length;
};
还请各位仁兄指点。不胜感激。
|
uint8_t iSerialNumber;
这就是数字的吧
这就是数字的吧
|
uint8_t是8位无符号整数吧,取值范围只不过0~255而已,不太可能直接保存序列号。
注释说Index of string descriptor,大概是在另外什么地方有一个表以字符串的形式保存了序列号,这里的整数是那个表的索引,需要查表把序列号取出来
|
注释里多次提到Index of string descriptor,可能manufacturer和product也是用这种查表的方式。这样比较节省程序的空间。
|
同意这位同学的说法,注释多次提到这是Index而不是真正的值
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。