Solved

How can 2 applications share a serial port in Windows 2000 ?

Posted on 2003-11-26
8
189 Views
Last Modified: 2010-04-13
Hi experts,

I am migrating an old 16 bit windows app. thas does direct serial port handling in order to  take full advantage of a specialized printer. I have already programmed an interface using Win32 apis that takes care of this.

There is also a DOS application, running on a DOS window, that prints thru the system printer, which happens to be the same serial printer. So, it requires the printer driver to be installed.

It is mandatory to have both applications running on the same machine.

The problem is that whenever the driver is installed, the port seems to be unavailable for my interface, which gets an "invalid_operation" return code for all of its requests. As soon as I remove the printer driver from the system, my interface works OK.

So far I have tried to set the serial port as a multiport ans as a regular port, but the problem remains the same.

The question is what more settings can I try to fix the problem, or if there is any other printer driver that doesn´t block the port

Here is some specific information:
old environment: Pentium I w/Windows 95
new environment: Pentium IV w/Windows 2000
serial printer: Epson TM - H5000

Best regards


0
Comment
Question by:juliogonzalez
  • 3
  • 2
8 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 9837386
Only a quick thought from something I did some while back.  The DOS program should be able to talk to a printer on LPT1: without having it installed in Windows so maybe you could change the port in the program to use LPT1: instead of COM1: (hoping it is editable...) and use a MODE LPT1:=COM1: type command to redirect it?

Alternatively could the Windows App not talk to the printer driver rather than direct to the serial port, I assume you are saying that the Windows program is the one that isn't working when the driver is installed, not the DOS one?

I was only passing through this TA looking for a solution to something myself, will keep an eye on this one though as I'm curious!

Steve
0
 

Author Comment

by:juliogonzalez
ID: 9838295
Hi Steve,

I´ll find out if the DOS program can switch to LPT1: and try with the mode command.
As for the Windows app, it´s very hard to make it change its printer approach because it dinamically loads data containing ESC sequences, a legacy from an earlier DOS version.

Thanks

Julio
0
 

Author Comment

by:juliogonzalez
ID: 9957948
Hi Steve,

Unfortunately, this DOS pgm. is a black box and doesn´t let me switch it to LPT1

I´ve found something weird, but helpful to me I didn´t make it clear before, but I was testing my win32 interface not directly from the 16 bit app. but from a test pgm. which ia a win32 console app. The pitfall was that this program was prompting the user in order to let me select COM1 or COM2 by using the C function getch(), which now seems to be the conflictive one. After commenting all getch()s, the test program started printing and the conflict with the driver is over.
I still get the INVALID_OPERATION return code for all api calls other than cretefile, readfile and writefile, and even the readfile ends alvays in timeout, but the printer is printing both ways (direct and driver).

Yet, I´m still interested having successfull readfile calls to get the printer status (paper out, etc), but I can live without this.

The compiler I am using is VC++ .Net.


Regards

Julio

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:juliogonzalez
ID: 10778855
Hi,

To me, this problem got solved when I realized what I explain on my comment
dated 12/17/2003 12:05PM PET above. To be more specific, the conflict generated by the C function getch().

"After commenting all getch()s, the test program started printing and the conflict with the driver is over".  
 
The complete code of the test program can fe found under the following question :

SERIAL PORT WORKS ON WIN/NT AND NOT IN WIN2K
http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_20803035.html

Regards

Julio


0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 10778998
As a passer by expert I didn't help at all here but the asker's own comments must be worth a PAQ/REFUND?

Steve
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
ID: 10798108
Closed, 500 points refunded.
Lunchy
Friendly Neighbourhood Community Support Moderator
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now