Changeset 5dfee52 in mainline
- Timestamp:
- 2011-05-08T13:39:20Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 19065c7, 7b6f116
- Parents:
- df25ab6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/lsusb/main.c
rdf25ab6 r5dfee52 44 44 #include <devman.h> 45 45 #include <devmap.h> 46 #include <usb/hub.h> 46 47 #include <usb/host.h> 47 48 48 49 #define NAME "lsusb" 49 50 50 #define MAX_FAILED_ATTEMPTS 451 #define MAX_FAILED_ATTEMPTS 10 51 52 #define MAX_PATH_LENGTH 1024 53 54 static void print_found_hc(size_t class_index, const char *path) 55 { 56 // printf(NAME ": host controller %zu is `%s'.\n", class_index, path); 57 printf("Bus %02zu: %s\n", class_index, path); 58 } 59 static void print_found_dev(usb_address_t addr, const char *path) 60 { 61 // printf(NAME ": device with address %d is `%s'.\n", addr, path); 62 printf(" Device %02d: %s\n", addr, path); 63 } 64 65 static void print_hc_devices(devman_handle_t hc_handle) 66 { 67 int rc; 68 usb_hc_connection_t conn; 69 70 usb_hc_connection_initialize(&conn, hc_handle); 71 rc = usb_hc_connection_open(&conn); 72 if (rc != EOK) { 73 printf(NAME ": failed to connect to HC: %s.\n", 74 str_error(rc)); 75 return; 76 } 77 usb_address_t addr; 78 for (addr = 1; addr < 5; addr++) { 79 devman_handle_t dev_handle; 80 rc = usb_hc_get_handle_by_address(&conn, addr, &dev_handle); 81 if (rc != EOK) { 82 continue; 83 } 84 char path[MAX_PATH_LENGTH]; 85 rc = devman_get_device_path(dev_handle, path, MAX_PATH_LENGTH); 86 if (rc != EOK) { 87 continue; 88 } 89 print_found_dev(addr, path); 90 } 91 usb_hc_connection_close(&conn); 92 } 52 93 53 94 int main(int argc, char *argv[]) … … 69 110 continue; 70 111 } 71 print f(NAME ": host controller %zu is `%s'.\n",72 class_index, path);112 print_found_hc(class_index, path); 113 print_hc_devices(hc_handle); 73 114 } 74 115
Note:
See TracChangeset
for help on using the changeset viewer.