- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good evening. I have a test project running on CY8CKIT_059 that uses both the USB UART and the UART (Kitprog port). The protocol used by both ports is configurable.
I am able to read data from PSOC on the two ports at the same time with two PUTTY sessions. Problem is that when I turn off the session reading from USB COM port, the other port will halt sending commands.
This is because I write to both ports, and on USB side there's the 'classic' cycle that waits the USB to be ready for transfer:
while (0u == USBCOM_CDCIsReady());
USBCOM_PutString(s);
This does not happen on the serial port.
What's the best strategy to detect full buffer (or better COM port not open by any program/not active)? Also is there a way to detect port reopening as to suspend send and clear the buffers befrore restarting the serial stream?
Thanks
Marco
Solved! Go to Solution.
- Labels:
-
PSoC 5 Device Programming
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Marco,
try to put expiration counter before PutString. It no connection it simply skips sending data until re-connected
void DisplayData(void) // output to terminal
{
sprintf(buff, ".... \r\n", ....); // your data
uint16 ctr = 0;
while(USBUART_1_CDCIsReady() == 0u) {ctr++; if (ctr > 400) return; } // prevent buffer overflow if COM stopped
//USBUART_Check_CDC_Init(); //check if USBUART initialized
USBUART_1_PutString(buff); // Send data to PC
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Marco,
try to put expiration counter before PutString. It no connection it simply skips sending data until re-connected
void DisplayData(void) // output to terminal
{
sprintf(buff, ".... \r\n", ....); // your data
uint16 ctr = 0;
while(USBUART_1_CDCIsReady() == 0u) {ctr++; if (ctr > 400) return; } // prevent buffer overflow if COM stopped
//USBUART_Check_CDC_Init(); //check if USBUART initialized
USBUART_1_PutString(buff); // Send data to PC
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your answer. This is similar to my first logic 'always try to send'. I thought about some event/status that could directly tell this situation of USB non used/read by the computer. This is to avoid a useless loop. By the way, where does 400 come from? Any timing logic behind (clock/datarate)? Also could be implemented with a variable length wait (if last send was successful, try hard, otherwise skip earlier)
Bye
Marco
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Marco,
I don't have better solution. The 400 was empirically deducted, I believe that 200 was not enough when I used it.
/odissey1