Changeset 47a728e1 in mainline for uspace/app/sportdmp/sportdmp.c
- Timestamp:
- 2012-08-01T21:59:40Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cb4a66d2
- Parents:
- 23db8aa (diff), 9bcdbc5 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sportdmp/sportdmp.c
r23db8aa r47a728e1 37 37 static void syntax_print(void) 38 38 { 39 fprintf(stderr, "Usage: sportdmp <baud> <device_service>\n");39 fprintf(stderr, "Usage: sportdmp [--baud=<baud>] [device_service]\n"); 40 40 } 41 41 42 42 int main(int argc, char **argv) 43 43 { 44 const char* svc_path = "devices/\\hw\\pci0\\00:01.0\\com1\\a";45 44 sysarg_t baud = 9600; 45 service_id_t svc_id; 46 46 47 if (argc > 1) { 47 int arg = 1; 48 int rc; 49 50 if (argc > arg && str_test_prefix(argv[arg], "--baud=")) { 51 size_t arg_offset = str_lsize(argv[arg], 7); 52 char* arg_str = argv[arg] + arg_offset; 53 if (str_length(arg_str) == 0) { 54 fprintf(stderr, "--baud requires an argument\n"); 55 syntax_print(); 56 return 1; 57 } 48 58 char *endptr; 49 baud = strtol(arg v[1], &endptr, 10);59 baud = strtol(arg_str, &endptr, 10); 50 60 if (*endptr != '\0') { 51 61 fprintf(stderr, "Invalid value for baud\n"); … … 53 63 return 1; 54 64 } 65 arg++; 55 66 } 56 67 57 if (argc > 2) { 58 svc_path = argv[2]; 68 if (argc > 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 } 75 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); 59 103 } 60 104 61 if (argc > 3) { 105 if (argc > arg) { 106 fprintf(stderr, "Too many arguments\n"); 62 107 syntax_print(); 63 108 return 1; 64 109 } 65 110 66 service_id_t svc_id;67 int rc = loc_service_get_id(svc_path, &svc_id, IPC_FLAG_BLOCKING);68 if (rc != EOK) {69 fprintf(stderr, "Cannot find device service %s\n", svc_path);70 return 1;71 }72 111 73 112 async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id, 74 113 IPC_FLAG_BLOCKING); 75 114 if (!sess) { 76 fprintf(stderr, "Failed connecting to service %s\n", svc_path);115 fprintf(stderr, "Failed connecting to service\n"); 77 116 } 78 117
Note:
See TracChangeset
for help on using the changeset viewer.