- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
"Engineering is an Art. The Art of Compromise."
Solved! Go to Solution.
- Labels:
-
PSoC 5 Architecture
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Len,
As per my understanding you need to check when the Port is open in order to receive data, meanwhile you do not want the code to be suck in the while loop so as to carry on other functionalities.
In such a case you can try setting a flag inside the an if condition such as:
if (USBUART_CDCIsReady==0)
{
flag =1;
}
else
{
flag=0;
}
You need to check for this flag before transmitting any data and transmit the data only if the flag is set to 0.
This will prevent the code from getting stuck in a loop.
Please feel free to correct me if my understanding is not clear.
Also could you provide more details about your application?
Best Regards
Ekta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
"Engineering is an Art. The Art of Compromise."