Changeset 5e168be1 in mainline
- Timestamp:
- 2011-04-14T10:22:06Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fa0f53b
- Parents:
- 8989f48f
- Location:
- uspace/lib/usb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/devpoll.h
r8989f48f r5e168be1 40 40 41 41 typedef struct { 42 /** Level of debugging messages from auto polling. 43 * 0 - nothing 44 * 1 - inform about errors and polling start/end 45 * 2 - also dump every retrieved buffer 46 */ 47 int debug; 42 48 /** Maximum number of consecutive errors before polling termination. */ 43 49 size_t max_failures; -
uspace/lib/usb/src/devpoll.c
r8989f48f r5e168be1 36 36 #include <usb/request.h> 37 37 #include <usb/debug.h> 38 #include <usb/classes/classes.h> 38 39 #include <errno.h> 39 40 #include <str_error.h> … … 45 46 /** Data needed for polling. */ 46 47 typedef struct { 48 int debug; 47 49 size_t max_failures; 48 50 useconds_t delay; … … 73 75 = polling_data->dev->pipes[polling_data->pipe_index].pipe; 74 76 75 usb_log_debug("Pipe interface number: %d, protocol: %d, subclass: %d, max packet size: %d\n", 76 polling_data->dev->pipes[polling_data->pipe_index].interface_no, 77 polling_data->dev->pipes[polling_data->pipe_index].description->interface_protocol, 78 polling_data->dev->pipes[polling_data->pipe_index].description->interface_subclass, 79 pipe->max_packet_size); 77 if (polling_data->debug > 0) { 78 usb_endpoint_mapping_t *mapping 79 = &polling_data->dev->pipes[polling_data->pipe_index]; 80 usb_log_debug("Poll0x%x: started polling of `%s' - " \ 81 "interface %d (%s,%d,%d), %zuB/%zu.\n", 82 polling_data, 83 polling_data->dev->ddf_dev->name, 84 (int) mapping->interface->interface_number, 85 usb_str_class(mapping->interface->interface_class), 86 (int) mapping->interface->interface_subclass, 87 (int) mapping->interface->interface_protocol, 88 polling_data->request_size, pipe->max_packet_size); 89 } 80 90 81 91 size_t failed_attempts = 0; … … 86 96 rc = usb_pipe_read(pipe, polling_data->buffer, 87 97 polling_data->request_size, &actual_size); 98 99 if (polling_data->debug > 1) { 100 if (rc == EOK) { 101 usb_log_debug( 102 "Poll0x%x: received: '%s' (%zuB).\n", 103 polling_data, 104 usb_debug_str_buffer(polling_data->buffer, 105 actual_size, 16), 106 actual_size); 107 } else { 108 usb_log_debug( 109 "Poll0x%x: polling failed: %s.\n", 110 polling_data, str_error(rc)); 111 } 112 } 88 113 89 114 /* If the pipe stalled, we can try to reset the stall. */ … … 129 154 } 130 155 131 if (failed_attempts > 0) {132 usb_log_error(133 "Polling of device `%s' terminated: recurring failures.\n",134 polling_data->dev->ddf_dev->name);135 }136 137 156 if (polling_data->on_polling_end != NULL) { 138 157 polling_data->on_polling_end(polling_data->dev, 139 158 failed_attempts > 0, polling_data->custom_arg); 159 } 160 161 if (polling_data->debug > 0) { 162 if (failed_attempts > 0) { 163 usb_log_error( 164 "Polling of device `%s' terminated: %s.\n", 165 polling_data->dev->ddf_dev->name, 166 "recurring failures"); 167 } else { 168 usb_log_debug( 169 "Polling of device `%s' terminated by user.\n", 170 polling_data->dev->ddf_dev->name 171 ); 172 } 140 173 } 141 174 … … 186 219 } 187 220 221 auto_polling->debug = 1; 188 222 auto_polling->auto_clear_halt = true; 189 223 auto_polling->delay = 0; … … 252 286 polling_data->custom_arg = arg; 253 287 288 polling_data->debug = polling->debug; 254 289 polling_data->max_failures = polling->max_failures; 255 290 if (polling->delay >= 0) {
Note:
See TracChangeset
for help on using the changeset viewer.