Changeset 64d138b in mainline for uspace/app/tmon/main.c


Ignore:
Timestamp:
2017-12-15T17:21:49Z (8 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
73b0773
Parents:
a8723748
Message:

usbdiag: finalize IPC ops for tmon, simple demo waiting for test

File:
1 edited

Legend:

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

    ra8723748 r64d138b  
    3636
    3737#include <stdio.h>
     38#include <loc.h>
    3839#include <usb/diag/diag.h>
     40#include <usb/diag/iface.h>
     41#include <devman.h>
     42#include <errno.h>
    3943
    4044#define NAME "tmon"
     
    4347{
    4448        printf(NAME ": hello USB transfers!\n\n");
     49}
     50
     51static void print_list_item(service_id_t svc)
     52{
     53        int rc;
     54        devman_handle_t diag_handle = 0;
     55
     56        if ((rc = devman_fun_sid_to_handle(svc, &diag_handle))) {
     57                printf(NAME ": Error resolving handle of device with SID %ld, skipping.\n", svc);
     58                return;
     59        }
     60}
     61
     62static int print_list()
     63{
     64        category_id_t diag_cat;
     65        service_id_t *svcs;
     66        size_t count;
     67        int rc;
     68
     69        if ((rc = loc_category_get_id(USB_DIAG_CATEGORY, &diag_cat, 0))) {
     70                printf(NAME ": Error resolving category '%s'", USB_DIAG_CATEGORY);
     71                return 1;
     72        }
     73
     74        if ((rc = loc_category_get_svcs(diag_cat, &svcs, &count))) {
     75                printf(NAME ": Error getting list of host controllers.\n");
     76                return 1;
     77        }
     78
     79        for (unsigned i = 0; i < count; ++i) {
     80                print_list_item(svcs[i]);
     81        }
     82
     83        free(svcs);
     84        return 0;
    4585}
    4686
     
    5292        }
    5393
    54         int out;
    55         const int rc = usb_diag_test(0, &out);
    56         if (rc) {
    57                 printf("Error: %d\n", rc);
    58         } else {
    59                 printf("The number is %d.\n", out);
    60         }
    61 
    62         return 0;
     94        return print_list();
    6395}
    6496
Note: See TracChangeset for help on using the changeset viewer.