Virtual COM port, bluetooth and printing

Virtual COM port, bluetooth and printing

Post by Bostjan Erze » Sun, 04 Aug 2002 03:06:40



Hi!

I'm using iPAQ 3870 and Winconnect bluetooth print adapter
for wireless printing. I print to virtual COM port 8 with
one problem. If I close the port immediately after
successful WriteFile, nothing is printed. Sleeping for "a
while" before CloseHandle helps, but that is not good
solution. FlushFileBuffers doesn't help either. I suppose
driver should take the care that port isn't closed until
all data is sended but this obviously is not the case.
What can I do to make printing reliable?

Thanks,
Bostjan

 
 
 

Virtual COM port, bluetooth and printing

Post by Paul G. Tobe » Sun, 04 Aug 2002 05:36:44


Can you use ClearCommError() and check the size of the output queue, waiting
for it to reach zero.  It doesn't seem like this should work (it's always
zero when WriteFile on a real COM port returns), but who knows...

Paul T.


Quote:> Hi!

> I'm using iPAQ 3870 and Winconnect bluetooth print adapter
> for wireless printing. I print to virtual COM port 8 with
> one problem. If I close the port immediately after
> successful WriteFile, nothing is printed. Sleeping for "a
> while" before CloseHandle helps, but that is not good
> solution. FlushFileBuffers doesn't help either. I suppose
> driver should take the care that port isn't closed until
> all data is sended but this obviously is not the case.
> What can I do to make printing reliable?

> Thanks,
> Bostjan


 
 
 

Virtual COM port, bluetooth and printing

Post by Andrew Rogers [MS » Sun, 04 Aug 2002 06:36:04


You might try using the SetCommEvent() and WaitCommEvent() APIs (see MSDN)
to wait for the EV_TXEMPTY event. Though I've never used this on a virtual
COM port as you are, the event is supposed to be signaled once all data in
the output buffer is sent.

code something like this:

// open port hPort

SetCommMask(hPort, EV_TXEMTPY);

// send your data

// replace your Sleep() statement with this:
DWORD mask;
WaitCommEvent(hPort, &mask, NULL);

CloseHandle(hPort);


Quote:> Hi!

> I'm using iPAQ 3870 and Winconnect bluetooth print adapter
> for wireless printing. I print to virtual COM port 8 with
> one problem. If I close the port immediately after
> successful WriteFile, nothing is printed. Sleeping for "a
> while" before CloseHandle helps, but that is not good
> solution. FlushFileBuffers doesn't help either. I suppose
> driver should take the care that port isn't closed until
> all data is sended but this obviously is not the case.
> What can I do to make printing reliable?

> Thanks,
> Bostjan

 
 
 

Virtual COM port, bluetooth and printing

Post by Bostjan Erze » Sun, 04 Aug 2002 19:12:02


Unfortunatelly this doesn't work. I also tried
ClearCommError but that always report zero for
nonoverlapped writing. Since PocketPC doesn't support
overlapped writing this has no use.

Bostjan

>-----Original Message-----
>You might try using the SetCommEvent() and WaitCommEvent
() APIs (see MSDN)
>to wait for the EV_TXEMPTY event. Though I've never used
this on a virtual
>COM port as you are, the event is supposed to be signaled
once all data in
>the output buffer is sent.

>code something like this:

>// open port hPort

>SetCommMask(hPort, EV_TXEMTPY);

>// send your data

>// replace your Sleep() statement with this:
>DWORD mask;
>WaitCommEvent(hPort, &mask, NULL);

>CloseHandle(hPort);



>> Hi!

>> I'm using iPAQ 3870 and Winconnect bluetooth print
adapter
>> for wireless printing. I print to virtual COM port 8
with
>> one problem. If I close the port immediately after
>> successful WriteFile, nothing is printed. Sleeping
for "a
>> while" before CloseHandle helps, but that is not good
>> solution. FlushFileBuffers doesn't help either. I
suppose
>> driver should take the care that port isn't closed until
>> all data is sended but this obviously is not the case.
>> What can I do to make printing reliable?

>> Thanks,
>> Bostjan

>.

 
 
 

Virtual COM port, bluetooth and printing

Post by Paul G. Tobe » Wed, 07 Aug 2002 04:04:41


Sounds like the driver isn't working properly to me.

Paul T.


> Unfortunatelly this doesn't work. I also tried
> ClearCommError but that always report zero for
> nonoverlapped writing. Since PocketPC doesn't support
> overlapped writing this has no use.

> Bostjan

> >-----Original Message-----
> >You might try using the SetCommEvent() and WaitCommEvent
> () APIs (see MSDN)
> >to wait for the EV_TXEMPTY event. Though I've never used
> this on a virtual
> >COM port as you are, the event is supposed to be signaled
> once all data in
> >the output buffer is sent.

> >code something like this:

> >// open port hPort

> >SetCommMask(hPort, EV_TXEMTPY);

> >// send your data

> >// replace your Sleep() statement with this:
> >DWORD mask;
> >WaitCommEvent(hPort, &mask, NULL);

> >CloseHandle(hPort);



> >> Hi!

> >> I'm using iPAQ 3870 and Winconnect bluetooth print
> adapter
> >> for wireless printing. I print to virtual COM port 8
> with
> >> one problem. If I close the port immediately after
> >> successful WriteFile, nothing is printed. Sleeping
> for "a
> >> while" before CloseHandle helps, but that is not good
> >> solution. FlushFileBuffers doesn't help either. I
> suppose
> >> driver should take the care that port isn't closed until
> >> all data is sended but this obviously is not the case.
> >> What can I do to make printing reliable?

> >> Thanks,
> >> Bostjan

> >.