USBUART Com Port Open Detection

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

cross mob
Anonymous
Not applicable

Is there a way to check if the PC has opened the com port? I can determine whether the USB is connected and I can get all the port settings (baud, etc), but I want to know if the user on the PC has opened the com port with a terminal or other program.

This is on a PSoc5 with the USBUART component. I am using the feature to send data, but only want to send it if a user has actually opened the port.

0 Likes
1 Solution
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

One possible way to check that Com port is open is to use an expiration counter, see e.g.

Re: PSOC5 USB UART buffer when no program is reading the data

/odissey1 

View solution in original post

0 Likes
4 Replies
Anonymous
Not applicable

Thanks for the reply.

That appears to be a good way to see if the port was opened initially, but I am not sure how to determine the port state after a few open/closes. Sometimes the line coding changes due to baudrate or DTR, RTS, etc changes.

I am looking for a something to put inside ...

state = USBUART_1_IsLineChanged();

if (state & USBUART_1_LINE_CODING_CHANGED)

{

     // did the port open?

}

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

One possible way to check that Com port is open is to use an expiration counter, see e.g.

Re: PSOC5 USB UART buffer when no program is reading the data

/odissey1 

0 Likes
Anonymous
Not applicable

Thanks,

That seems like a good work around.

0 Likes