Dan K


Discussion created by Dan K on Jun 20, 2015
Latest reply on Jun 22, 2015 by Iva Susnova

Using the latest Freescale Kinetis Software Development Kit (Kinetis SDK 1.2.0) for USB CDC virtual COM port, I discovered that the USB_APP_CDC_SERIAL_STATE_NOTIF operation in the example application USB_App_Class_Callback() function (see virtual_com.c in the cdc/virtual_com demo_apps examples) is non-functional. When the USB host sends the appropriate request associated with changing the RTS or DTR signals, the "data" pointer referenced is always a NULL. Without any data, it is very difficult for the user to "add your own code for serial_state notify event" as stated in the code comments.


Investigating this, I determined that there appears to be a problem with the USB_Service_Cdc_Notif() function in the usb_cdc.c file. In this function, the callback call (lines 434 to 438) always initializes the "data" and "size" pointers to NULL being passed to the callback function (eventually calling the application's USB_App_Class_Callback() function). I was able to get it to work by changing the following lines: (shown in bold)


433       uint8_t event_type = USB_APP_CDC_SERIAL_STATE_NOTIF;
434       cdc_obj_ptr->class_specific_callback.callback(event_type,
435       USB_REQ_VAL_INVALID,              
436       &event->buffer_ptr,// was NULL, DLK made this bug fix
437&event->len,// was NULL, DLK made this bug fix


With those changes, the 10 bytes of data now available is typically similar to the following:

  0xa1 0x20 0x00 0x00 0x00 0x00 0x02 0x00 0x02 0x00

with the two least significant bits of the next to last byte determined by the RTS and DTR settings from the USB host's communications application.