cancel
Showing results for 
Search instead for 
Did you mean: 

USBX CDC ACM Write problem

Misterxyz83
Associate II

Hello everyone,

I'm developing an application using USBX CDC ACM class in standalone mode. I've written an execution loop for scheduling USB stack operations and there are no problem with READ transaction; i'm able to receive correctly every data from my host pc.

There is a problem or perhaps my misunderstanding on WRITE transaction (i mean from STM32 device to host pc). I'm not sure how to interpret state returned by ux_device_class_cdc_acm_write_run function. 

The device receive a packet (few bytes from host) and it has to answer back few bytes. On first packet, my host receive every byte sent by device but when the host send another packet, the device will send back data but nothing is received; i need to send another packet to "push" data to host.

It is not very clear (for me) what is the correct behavior in respect of ux_device_class_cdc_acm_write_run exit status.

  • when device has to send N bytes so the write_run function is called with requested_length == N;
  • the write_run function returns UX_STATUS_WAIT with actual_length == 0, i don't understand why because it has sent every byte (following with debugger in source code);
  • my firmware will run again on the same block because of actual_length == 0, so i cannot move forward on my buffer and on the second call of write_run (with same data and length!) it returns UX_STATUS_NEXT with actual_length == N, so i will move forward my buffer but it stucks because i sent all data needed.
  • The host will receive all N bytes correctly;
  • after that, when it need to send other N bytes it calls again write_run but in this case the host will not receive nothing; the internal state machine seems to be in a non-reset status and i will pass over.

I'm not sure on how to use that write_run function. I've used the ZLP define on ux_user.h but no change.

Everyone can help me to understand how to handle UX_STATUS_WAIT and UX_STATUS_NEXT status? 

How does should be used in standalone mode the write process?

Thanks in advance

0 REPLIES 0