Changeset 4a7a8d4 in mainline for uspace/app/lsusb/main.c


Ignore:
Timestamp:
2011-05-13T10:31:54Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aca3489
Parents:
05e21ffc (diff), c372e03 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with usb/development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/lsusb/main.c

    r05e21ffc r4a7a8d4  
    4444#include <devman.h>
    4545#include <devmap.h>
     46#include <usb/hub.h>
    4647#include <usb/host.h>
    4748
    4849#define NAME "lsusb"
    4950
    50 #define MAX_FAILED_ATTEMPTS 4
     51#define MAX_FAILED_ATTEMPTS 10
    5152#define MAX_PATH_LENGTH 1024
     53
     54static 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}
     59static 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
     65static 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}
    5293
    5394int main(int argc, char *argv[])
     
    69110                        continue;
    70111                }
    71                 printf(NAME ": host controller %zu is `%s'.\n",
    72                     class_index, path);
     112                print_found_hc(class_index, path);
     113                print_hc_devices(hc_handle);
    73114        }
    74115
Note: See TracChangeset for help on using the changeset viewer.