Page 1 of 1

USB Serial Driver – detect consumer on the other end?

Posted: Fri Aug 09, 2013 12:11 am
by datenwolf
In my current project I'm quite successfully using the USB Serial Driver; apart from using it for a shell the system also emits various log messages. Now as long as there's a program consuming the transmitted bytes on the other ends everything is well. But it nothing reads from the USB Serial port write operations on the serial driver's sequential stream will block; which is a problem, because if message printing blocks the whole system eventually comes to a standstill.

Now I was wondering if there might be some way to detect if there's actually some program consuming the transmitted bytes on the USB host computer? The next best solution would be, that the USB Serial Driver offered some option to (silently) discard anything queued for submission if the transmit buffer is full (either hard, or by some timeout).

Is either in any way possible?

Re: USB Serial Driver – detect consumer on the other end?

Posted: Fri Aug 09, 2013 7:52 am
by Giovanni
Hi,

It is not possible, you may try writing on the output queue using a timeout, this way the program would not hang forever, you may try something like 10 milliseconds.

Giovanni

Re: USB Serial Driver – detect consumer on the other end?

Posted: Thu Aug 15, 2013 8:15 am
by colin
Maple has the same prpblem .


Can't you tell if the USB device is enumerated with a host? I would think there is some way to tell...

Re: USB Serial Driver – detect consumer on the other end?

Posted: Thu Aug 15, 2013 8:36 am
by Giovanni
That is easy, check the "state" field of the USBDriver structure.

But enumerated does not mean that there is an application on the host side consuming the data.

Giovanni