Changeset 5ea75f0 in mainline for uspace/app/sportdmp/sportdmp.c


Ignore:
Timestamp:
2012-07-29T23:28:08Z (12 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4bbba4a
Parents:
0aa300d
Message:

sportdmp: Use first service from serial category instead of hardcoded name by default.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sportdmp/sportdmp.c

    r0aa300d r5ea75f0  
    4242int main(int argc, char **argv)
    4343{
    44         const char* svc_path = "devices/\\hw\\pci0\\00:01.0\\com1\\a";
    4544        sysarg_t baud = 9600;
     45        service_id_t svc_id;
    4646       
    4747        int arg = 1;
     48        int rc;
    4849               
    4950        if (argc > arg && str_test_prefix(argv[arg], "--baud=")) {
     
    6667       
    6768        if (argc > arg) {
    68                 svc_path = argv[arg];
     69                rc = loc_service_get_id(argv[arg], &svc_id, 0);
     70                if (rc != EOK) {
     71                        fprintf(stderr, "Cannot find device service %s\n",
     72                            argv[arg]);
     73                        return 1;
     74                }
    6975                arg++;
     76        }
     77        else {
     78                category_id_t serial_cat_id;
     79               
     80                rc = loc_category_get_id("serial", &serial_cat_id, 0);
     81                if (rc != EOK) {
     82                        fprintf(stderr, "Failed getting id of category "
     83                            "'serial'\n");
     84                        return 1;
     85                }
     86               
     87                service_id_t *svc_ids;
     88                size_t svc_count;
     89               
     90                rc = loc_category_get_svcs(serial_cat_id, &svc_ids, &svc_count);                if (rc != EOK) {
     91                        fprintf(stderr, "Failed getting list of services\n");
     92                        return 1;
     93                }
     94               
     95                if (svc_count == 0) {
     96                        fprintf(stderr, "No service in category 'serial'\n");
     97                        free(svc_ids);
     98                        return 1;
     99                }
     100               
     101                svc_id = svc_ids[0];
     102                free(svc_ids);
    70103        }
    71104       
     
    76109        }
    77110       
    78         service_id_t svc_id;
    79         int rc = loc_service_get_id(svc_path, &svc_id, 0);
    80         if (rc != EOK) {
    81                 fprintf(stderr, "Cannot find device service %s\n", svc_path);
    82                 return 1;
    83         }
    84111       
    85112        async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id,
    86113            IPC_FLAG_BLOCKING);
    87114        if (!sess) {
    88                 fprintf(stderr, "Failed connecting to service %s\n", svc_path);
     115                fprintf(stderr, "Failed connecting to service\n");
    89116        }
    90117       
Note: See TracChangeset for help on using the changeset viewer.