x-cube-azrtos-f4 icon indicating copy to clipboard operation
x-cube-azrtos-f4 copied to clipboard

Why ux_slave_class_name of ux_slave_interface_next_interface is NULL?

Open FengChendian opened this issue 2 years ago • 0 comments

Describe the set-up

I try to migrate USBX CDC ACM to STM32F407ZGT6. Now USB Device can be recognized by Computer as STM32 USB Device.

image

But I can't read any data from PC host. And I found ux_utility_memory_compare is not right.

  /* Compares two memory blocks ux_slave_class_name and _ux_system_slave_class_cdc_acm_name */
  ux_status = ux_utility_memory_compare(data_interface->ux_slave_interface_class->ux_slave_class_name,
                                        _ux_system_slave_class_cdc_acm_name,
                                        ux_utility_string_length_get(_ux_system_slave_class_cdc_acm_name));

ux_status is always return 255. data_interface->ux_slave_interface_class is NULL. image

The full read code is like:

void usbx_cdc_acm_read_thread_entry(ULONG arg)
{
  UX_SLAVE_DEVICE *device;
  UX_SLAVE_INTERFACE *data_interface;
  UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
  ULONG actual_length;
  ULONG ux_status = UX_SUCCESS;
  ULONG senddataflag = 0;

  /* Get device */
  device = &_ux_system_slave->ux_system_slave_device;

  while (1)
    {

      /* Check if device is configured */
      if (device->ux_slave_device_state == UX_DEVICE_CONFIGURED)
        {
          /* Get Data interface */
          data_interface = device->ux_slave_device_first_interface->ux_slave_interface_next_interface;

          /* Compares two memory blocks ux_slave_class_name and _ux_system_slave_class_cdc_acm_name */
          ux_status = ux_utility_memory_compare(data_interface->ux_slave_interface_class->ux_slave_class_name,
                                                _ux_system_slave_class_cdc_acm_name,
                                                ux_utility_string_length_get(_ux_system_slave_class_cdc_acm_name));

          /* Check Compares success */
           if (ux_status == UX_SUCCESS)
            {
              cdc_acm =  data_interface->ux_slave_interface_class_instance;

              /* Set transmission_status to UX_FALSE for the first time */
              cdc_acm -> ux_slave_class_cdc_acm_transmission_status = UX_FALSE;

              /* Read the received data in blocking mode */
              ux_device_class_cdc_acm_read(cdc_acm, (UCHAR *)UserRxBufferFS, 3,
                                           &actual_length);
              if (actual_length != 0)
                {
                  /* Send the data via UART */
//                  if (HAL_UART_Transmit_DMA(&huart3, (uint8_t *)UserRxBufferFS,
//                                            actual_length) != HAL_OK)
//                    {
//                      /* Transfer error in reception process */
//                      Error_Handler();
//                    }

                  /* Wait until the requested flag TX_NEW_TRANSMITTED_DATA is received */
                  if (tx_event_flags_get(&EventFlag, TX_NEW_TRANSMITTED_DATA, TX_OR_CLEAR,
                                         &senddataflag, TX_WAIT_FOREVER) != TX_SUCCESS)
                    {
                      Error_Handler();
                    }
                }
            }
        }
      else
        {
          tx_thread_sleep(1);
        }
    }
}

STM32CUBEMX 6.6.1 Firmware FW_F4_V1.27.0

Question Are there any reasons for "next interface.ux_slave_class_name is NULL"? I can't find any error in my code. Because USB device has been configured correctly. ux_app_parameters_change(VOID *cdc_acm) is also called when connected.

Screenshots

image

Here is my cubemx screenshots. image

FengChendian avatar Dec 06 '22 03:12 FengChendian