ux_device_class_cdc_acm_write is thread safe ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MaFa_974161
Level 5
Level 5
100 sign-ins 50 replies posted 50 questions asked

Hello.

I'm using CYW943907AEVAL1F eval board.

I have to develop a project that creates a thread that

waits USB request using "ux_device_class_cdc_acm_read" and sends USB answer using "ux_device_class_cdc_acm_write".

Requests are small packets (8 bytes), answers are small packets (8 bytes).

In another thread I have send 512byte packets every ms (512kBps) using "ux_device_class_cdc_acm_write".

Since "ux_device_class_cdc_acm_write" is called from two different threads ... I have to use Mutex ?

Or "ux_device_class_cdc_acm_write" is thread safe ?

Is there a way to create two endpoints and sends answers in one endpoint and packets in the other ?

0 Likes
1 Solution
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Hi,

"ux_device_class_cdc_acm_write" is a standard device class API of USBx stack. This function is called when an application needs to write to the IN data pipe (IN from the host, OUT from the device). It is blocking in nature. You can easily find this function's implementation in usbx repository in github. I provide you the link for the same-->

usbx/ux_device_class_cdc_acm_write.c at master · azure-rtos/usbx · GitHub

In the implementation, you'll find the function "_ux_utility_mutex_on" and "_ux_utility_mutex_off". So, I suppose it's thread safe and you won't need mutex implementation. The API is a standard API from a third party stack, so you can probably go through their documentation for more information. I hope this helps!

Thanks

Aditi

View solution in original post

3 Replies
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Hi,

"ux_device_class_cdc_acm_write" is a standard device class API of USBx stack. This function is called when an application needs to write to the IN data pipe (IN from the host, OUT from the device). It is blocking in nature. You can easily find this function's implementation in usbx repository in github. I provide you the link for the same-->

usbx/ux_device_class_cdc_acm_write.c at master · azure-rtos/usbx · GitHub

In the implementation, you'll find the function "_ux_utility_mutex_on" and "_ux_utility_mutex_off". So, I suppose it's thread safe and you won't need mutex implementation. The API is a standard API from a third party stack, so you can probably go through their documentation for more information. I hope this helps!

Thanks

Aditi

Thankyou... Is there an example to setup two interfaces?

0 Likes
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Hi,

Unfortunately, we don't have the example to show setup of two interfaces as per your requirement. But you can make use of the functions provided in the usb_device_cdc_acm_read_write example given in snip folder in WICED studio.

Location: 43xxx_Wi-Fi\apps\snip\usbx_usb_device\usb_device_cdc_acm_read_write

Thanks

Aditi