USBUART component: When continuously sending data to the host and the host port is connected but not open, the PSoC5 application will hang.

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

cross mob
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

I've developed code that uses the recommended while((USBUART_CDCIsReady()) == 0){} before sending new data to the host.

All is working great if the host is connected and the port is open.  As soon as a close the host port, eventually the PSoC app code hangs on the while() statement shown above.

Is there a proper way to detect if the port is open to accept new data?

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
1 Solution

Ekta,

Thank you.  You method works if you have implemented a non-blocking task structure.

As it turns out, I've created a routine that works in a blocking mode or non-blocking mode depending on which you select.

See this link for the solution: PSoC5LP : USBUART component detects port close

The solution uses the SysTick timer @ 1ms to detect if the host is non-responsive within less than 2ms.  If non-responsive, the routine kicks out and drops the transmitted bytes just as it would if it were a true UART.

Len

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
2 Replies