Changes in / [f5246b6:3c775adb] in mainline


Ignore:
Location:
uspace
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/hiddev.c

    rf5246b6 r3c775adb  
    206206        assert(endpoint_mapping[0].interface != NULL);
    207207       
    208         /*
    209          * Save polling interval
    210          */
    211         hid_dev->poll_interval = endpoint_mapping[0].descriptor->poll_interval;
    212         assert(hid_dev->poll_interval > 0);
    213        
    214208        rc = usbhid_dev_get_report_descriptor(hid_dev,
    215209            descriptors, descriptors_size,
  • uspace/drv/usbhid/hiddev.h

    rf5246b6 r3c775adb  
    5757        usb_endpoint_pipe_t poll_pipe;
    5858       
    59         short poll_interval;
    60        
    6159        uint16_t iface;
    6260       
  • uspace/drv/usbhid/kbddev.c

    rf5246b6 r3c775adb  
    593593
    594594        while (true) {
     595                async_usleep(1000 * 10);
     596
    595597                sess_rc = usb_endpoint_pipe_start_session(
    596598                    &kbd_dev->hid_dev->poll_pipe);
     
    633635                usb_log_debug("Calling usbhid_kbd_process_data()\n");
    634636                usbhid_kbd_process_data(kbd_dev, buffer, actual_size);
    635                
    636                 async_usleep(kbd_dev->hid_dev->poll_interval);
    637637        }
    638638
  • uspace/drv/usbhub/usbhub.c

    rf5246b6 r3c775adb  
    233233        dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");
    234234        usb_endpoint_pipe_start_session(&result->endpoints.control);
    235         opResult = usb_request_set_configuration(&result->endpoints.control, 1);
    236         assert(opResult == EOK);
    237 
    238235        opResult = usb_request_get_descriptor(&result->endpoints.control,
    239236                        USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE,
     
    246243                dprintf(USB_LOG_LEVEL_ERROR, "failed when receiving hub descriptor, badcode = %d",opResult);
    247244                free(serialized_descriptor);
    248                 free(result);
    249                 return NULL;
     245                return result;
    250246        }
    251247        dprintf(USB_LOG_LEVEL_DEBUG2, "deserializing descriptor");
     
    253249        if(descriptor==NULL){
    254250                dprintf(USB_LOG_LEVEL_WARNING, "could not deserialize descriptor ");
    255                 free(result);
    256                 return NULL;
     251                result->port_count = 1;///\TODO this code is only for debug!!!
     252                return result;
    257253        }
    258254
     
    290286
    291287        usb_hub_info_t * hub_info = usb_create_hub_info(dev);
    292         if(!hub_info){
    293                 return EINTR;
    294         }
    295288
    296289        int opResult;
     
    301294        opResult = usb_hub_process_configuration_descriptors(hub_info);
    302295        if(opResult != EOK){
    303                 dprintf(USB_LOG_LEVEL_ERROR,"could not get configuration descriptors, %d",
     296                dprintf(USB_LOG_LEVEL_ERROR,"could not get condiguration descriptors, %d",
    304297                                opResult);
    305298                return opResult;
  • uspace/drv/usbmouse/main.c

    rf5246b6 r3c775adb  
    7474int main(int argc, char *argv[])
    7575{
    76         usb_log_enable(USB_LOG_LEVEL_DEBUG2, NAME);
     76        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    7777
    7878        return ddf_driver_main(&mouse_driver);
  • uspace/drv/usbmouse/mouse.c

    rf5246b6 r3c775adb  
    3737#include <usb/debug.h>
    3838#include <errno.h>
    39 #include <str_error.h>
    4039#include <ipc/mouse.h>
    4140
     
    6564
    6665                size_t actual_size;
    67                 int rc;
    6866
    69                 /*
    70                  * Error checking note:
    71                  * - failure when starting a session is considered
    72                  *   temporary (e.g. out of phones, next try might succeed)
    73                  * - failure of transfer considered fatal (probably the
    74                  *   device was unplugged)
    75                  * - session closing not checked (shall not fail anyway)
    76                  */
     67                /* FIXME: check for errors. */
     68                usb_endpoint_pipe_start_session(&mouse->poll_pipe);
    7769
    78                 rc = usb_endpoint_pipe_start_session(&mouse->poll_pipe);
    79                 if (rc != EOK) {
    80                         usb_log_warning("Failed to start session, will try again: %s.\n",
    81                             str_error(rc));
    82                         continue;
    83                 }
    84 
    85                 rc = usb_endpoint_pipe_read(&mouse->poll_pipe,
     70                usb_endpoint_pipe_read(&mouse->poll_pipe,
    8671                    buffer, buffer_size, &actual_size);
    8772
    8873                usb_endpoint_pipe_end_session(&mouse->poll_pipe);
    89 
    90                 if (rc != EOK) {
    91                         usb_log_error("Failed reading mouse input: %s.\n",
    92                             str_error(rc));
    93                         break;
    94                 }
    95 
    96                 usb_log_debug2("got buffer: %s.\n",
    97                     usb_debug_str_buffer(buffer, buffer_size, 0));
    9874
    9975                uint8_t butt = buffer[0];
     
    139115        }
    140116
    141         /*
    142          * Device was probably unplugged.
    143          * Hang-up the phone to the console.
    144          * FIXME: release allocated memory.
    145          */
    146         async_hangup(mouse->console_phone);
    147         mouse->console_phone = -1;
    148 
    149         usb_log_error("Mouse polling fibril terminated.\n");
    150 
    151117        return EOK;
    152118}
  • uspace/lib/usb/include/usb/debug.h

    rf5246b6 r3c775adb  
    7979        usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__)
    8080
    81 const char *usb_debug_str_buffer(uint8_t *, size_t, size_t);
    8281
    8382
  • uspace/lib/usb/src/debug.c

    rf5246b6 r3c775adb  
    252252}
    253253
    254 
    255 #define REMAINDER_STR_FMT " (%zu)..."
    256 /* string + terminator + number width (enough for 4GB)*/
    257 #define REMAINDER_STR_LEN (5 + 1 + 10)
    258 #define BUFFER_DUMP_GROUP_SIZE 4
    259 #define BUFFER_DUMP_LEN 240 /* Ought to be enough for everybody ;-). */
    260 static fibril_local char buffer_dump[BUFFER_DUMP_LEN];
    261 
    262 /** Dump buffer into string.
    263  *
    264  * The function dumps given buffer into hexadecimal format and stores it
    265  * in a static fibril local string.
    266  * That means that you do not have to deallocate the string (actually, you
    267  * can not do that) and you do not have to save it agains concurrent
    268  * calls to it.
    269  * The only limitation is that each call rewrites the buffer again.
    270  * Thus, it is necessary to copy the buffer elsewhere (that includes printing
    271  * to screen or writing to file).
    272  * Since this function is expected to be used for debugging prints only,
    273  * that is not a big limitation.
    274  *
    275  * @warning You cannot use this function twice in the same printf
    276  * (see detailed explanation).
    277  *
    278  * @param buffer Buffer to be printed (can be NULL).
    279  * @param size Size of the buffer in bytes (can be zero).
    280  * @param dumped_size How many bytes to actually dump (zero means all).
    281  * @return Dumped buffer as a static (but fibril local) string.
    282  */
    283 const char *usb_debug_str_buffer(uint8_t *buffer, size_t size,
    284     size_t dumped_size)
    285 {
    286         /*
    287          * Remove previous string (that might also reveal double usage of
    288          * this function).
    289          */
    290         bzero(buffer_dump, BUFFER_DUMP_LEN);
    291 
    292         if (buffer == NULL) {
    293                 return "(null)";
    294         }
    295         if (size == 0) {
    296                 return "(empty)";
    297         }
    298         if ((dumped_size == 0) || (dumped_size > size)) {
    299                 dumped_size = size;
    300         }
    301 
    302         /* How many bytes are available in the output buffer. */
    303         size_t buffer_remaining_size = BUFFER_DUMP_LEN - 1 - REMAINDER_STR_LEN;
    304         char *it = buffer_dump;
    305 
    306         size_t index = 0;
    307 
    308         while (index < size) {
    309                 /* Determine space before the number. */
    310                 const char *space_before;
    311                 if (index == 0) {
    312                         space_before = "";
    313                 } else if ((index % BUFFER_DUMP_GROUP_SIZE) == 0) {
    314                         space_before = "  ";
    315                 } else {
    316                         space_before = " ";
    317                 }
    318 
    319                 /*
    320                  * Add the byte as a hexadecimal number plus the space.
    321                  * We do it into temporary buffer to ensure that always
    322                  * the whole byte is printed.
    323                  */
    324                 int val = buffer[index];
    325                 char current_byte[16];
    326                 int printed = snprintf(current_byte, 16,
    327                     "%s%02x", space_before, val);
    328                 if (printed < 0) {
    329                         break;
    330                 }
    331 
    332                 if ((size_t) printed > buffer_remaining_size) {
    333                         break;
    334                 }
    335 
    336                 /* We can safely add 1, because space for end 0 is reserved. */
    337                 str_append(it, buffer_remaining_size + 1, current_byte);
    338 
    339                 buffer_remaining_size -= printed;
    340                 /* Point at the terminator 0. */
    341                 it += printed;
    342                 index++;
    343 
    344                 if (index >= dumped_size) {
    345                         break;
    346                 }
    347         }
    348 
    349         /* Add how many bytes were not printed. */
    350         if (index < size) {
    351                 snprintf(it, REMAINDER_STR_LEN,
    352                     REMAINDER_STR_FMT, size - index);
    353         }
    354 
    355         return buffer_dump;
    356 }
    357 
    358 
    359254/**
    360255 * @}
Note: See TracChangeset for help on using the changeset viewer.