USB Serial Driver – detect consumer on the other end?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
datenwolf
Posts: 11
Joined: Mon Mar 25, 2013 11:12 pm

USB Serial Driver – detect consumer on the other end?

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

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

Post 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
colin
Posts: 149
Joined: Thu Dec 22, 2011 7:44 pm

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

Post 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...
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

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

Post 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
Post Reply