9 #define PROGNAME "libusbip"
48 if (portst_strings[
i].
num == status)
49 return portst_strings[
i].
desc;
51 return "Unknown Status";
57 if (speed_strings[
i].num == num)
58 return speed_strings[
i].
desc;
60 return "Unknown Speed";
64 #define DBG_UDEV_INTEGER(name)\
65 dbg("%-20s = %x", to_string(name), (int) udev->name)
67 #define DBG_UINF_INTEGER(name)\
68 dbg("%-20s = %x", to_string(name), (int) uinf->name)
77 dbg(
"%-20s = %s",
"Interface(C/SC/P)", buff);
85 dbg(
"%-20s = %s",
"path", udev->
path);
86 dbg(
"%-20s = %s",
"busid", udev->
busid);
92 dbg(
"%-20s = %s",
"Device(C/SC/P)", buff);
99 dbg(
"%-20s = %s",
"Vendor/Product", buff);
104 dbg(
"%-20s = %s",
"speed",
115 struct sysfs_attribute *
attr;
119 snprintf(attrpath,
sizeof(attrpath),
"%s/%s", dev->path, name);
121 attr = sysfs_open_attribute(attrpath);
123 dbg(
"sysfs_open_attribute failed: %s", attrpath);
127 ret = sysfs_read_attribute(attr);
129 dbg(
"sysfs_read_attribute failed");
133 ret =
sscanf(attr->value, format, &num);
135 dbg(
"sscanf failed");
140 sysfs_close_attribute(attr);
149 struct sysfs_attribute *
attr;
153 snprintf(attrpath,
sizeof(attrpath),
"%s/%s", dev->path,
"speed");
155 attr = sysfs_open_attribute(attrpath);
157 dbg(
"sysfs_open_attribute failed: %s", attrpath);
161 ret = sysfs_read_attribute(attr);
163 dbg(
"sysfs_read_attribute failed");
167 ret =
sscanf(attr->value,
"%s\n", speed);
169 dbg(
"sscanf failed");
173 sysfs_close_attribute(attr);
176 if (!
strcmp(speed, speed_strings[
i].speed))
177 return speed_strings[
i].
num;
183 #define READ_ATTR(object, type, dev, name, format)\
184 do { (object)->name = (type) read_attr_value(dev, to_string(name), format); } while (0)
209 sscanf(sdev->name,
"%u-%u", &busnum, &devnum);
218 char busid[SYSFS_BUS_ID_SIZE];
219 struct sysfs_device *sif;
223 sif = sysfs_open_device(
"usb", busid);
225 dbg(
"sysfs_open_device(\"usb\", \"%s\") failed", busid);
233 sysfs_close_device(sif);
250 const char *prod, *
vend;
254 prod =
"unknown product";
259 vend =
"unknown vendor";
261 snprintf(buff, size,
"%s : %s (%04x:%04x)", vend, prod, vendor, product);
266 const char *
c, *
s, *
p;
268 if (
class == 0 && subclass == 0 && protocol == 0) {
269 snprintf(buff, size,
"(Defined at Interface level) (%02x/%02x/%02x)",
class, subclass, protocol);
275 p =
"unknown protocol";
279 s =
"unknown subclass";
285 snprintf(buff, size,
"%s / %s / %s (%02x/%02x/%02x)", c, s, p,
class, subclass, protocol);