I'm working with uVision 5.15 and RL-USB with RTX to develop a USB
CDC application. I used the function USBD_CDC_ACM_DataSend to send
data over the USB com port. The application continuously (250ms step)
sends a keepalive message through the USB com port to the host, the
problem is that if the com port is closed after some messages the
USBD_CDC_ACM_DataSend stops to work and also return 0 as byte sent,
also opening the connection does not solve the problem. Someone knows
how to solve this problem? Is this a RL-USB bug?
> I'm working with uVision 5.15 and RL-USB
Sound like you are working on the old RL-USB using the latest
The RL-USB interfaces and implementations had changed a lot at MDK
USBD_CDC_ACM_DataSend() was replaced with
Differences to RL-USB
I remember we had discussed on a problem of the OUT
(host->device) endpoint at buffer full in the CDC of the old
I'm not sure, the IN (device->host) endpoint would also have any
> if the com port is closed after some messages the
USBD_CDC_ACM_DataSend stops to work and also return 0 as byte
Maybe your PC is a Linux (or Mac) box, which polls the CDC bulk IN
endpoint just while the COM port opens. Windows CDC driver always
polls the IN endpoint, regardless of open/close of the COM port.
A couple of workaround suggestions,
a) Endpoint status
Your firmware may read out the endpoint status directly from the USB
hardware register. This method depends on your MCU, tell us the type
number of your MCU for further discussion. While the IN endpoint is
still occupied by the last packet, don't call
b) DTR signaling to know open/close of COM port
In most of OS, PC serial library raises DTR at COM port open, it
drops DTR at close. If your library wouldn't, your PC application
could explicitly flip DTR signaling at open/close. Your firmware can
catch DTR change by USBD_CDC_ACM_PortSetControlLineState() callback.
While DTR drops, don't send the heart-beat message.
Hi Tsuneo! How can you set the control line for USBD CDC? I've asked similar questions https://community.arm.com/developer/tools-software/tools/f/keil-forum/47289/lpc1768-architecture-questions . I'm working with the VirtualCOM USBD sample for lpc1768, I can connect to the PC but can't seem to read data that I send from the MCU to the PC in C#. I can however, using teraterm. Any hints at what might be wrong?
Kev said:can't seem to read data that I send from the MCU to the PC in C#. I can however, using teraterm
Check your control signal settings - DTR, RTS ...
You could also use something like https://www.eltima.com/products/serial-port-monitor/ to see what's happening at the PC end - and where you C# differs from Teraterm ...
I'm not affiliated with nor sponsored by Eltima - but I have used their Serial Port Monitor with success in debugging such things.
If TermTerm can read/write on the PC side, then it's probably your code rather than the VCP/CDC
Look for other examples, and try those, don't see your code so can't suggest what's wrong there. In C one typically needs to use CreateFile() and Get/SetCommState(), data can then be moved via Read/WriteFile(). If the port is truly virtual the baud rate has no real meaning/effect.
Given the age of the LPC1768 I'd have to imagine there are several VCP/CDC class examples that could be found, along with the expected set of functionality and descriptors.
Great idea man thanks keep it up all the time. am very happy to see your standard. MyAARPMedicare Login
View all questions in Keil forum