CH552-DAPLink icon indicating copy to clipboard operation
CH552-DAPLink copied to clipboard

CDC_write is blocking

Open dunarri opened this issue 6 months ago • 4 comments

First off a big thank you for creating this and putting it on github!

I created a board with a CH551 on it to use as a build in SWD, however the DAPLink would become unresponsive. After some debugging I realized this was because my target was sending serial data to the CH551 UART, but I didn't have a serial monitor connected. This caused CDC_write to hang at the following line:

https://github.com/wagiminator/CH552-DAPLink/blob/c7975f84171129db54b3eef053588d27d78ec935/software/src/usb_cdc.c#L73

My quick and dirty fix was to use the DTR flag to decide if it should try to write the data to the CDC, so I changed line 97 of daplink.c to: if(CDC_getDTR() && UART_available()) {

This of course requires the serial monitor to set DTR, but it solved the problem for me. With no terminal connected the UART just continues happily overwriting the old data in buffer.

dunarri avatar Dec 11 '23 20:12 dunarri